Skip to content

Commit

Permalink
doc updats
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 committed Aug 5, 2024
1 parent f10b50e commit 0754e57
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 23 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ Initialize the AgentOps client and automatically get analytics on every LLM call
import agentops

# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init( < INSERT
YOUR
API
KEY
HERE >)
agentops.init( < INSERT YOUR API KEY HERE >)

...

Expand Down
4 changes: 2 additions & 2 deletions agentops/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def async_wrapper(*args, session: Optional[Session] = None, **kwargs):
if session is None:
if Client().is_multi_session:
raise ValueError(
"If multiple sessions exists, `session` is a required parameter in the function decorated by @record_function"
"If multiple sessions exists, `session` is a required parameter in the function decorated by @record_action"
)
func_args = inspect.signature(func).parameters
arg_names = list(func_args.keys())
Expand Down Expand Up @@ -100,7 +100,7 @@ def sync_wrapper(*args, session: Optional[Session] = None, **kwargs):
if session is None:
if Client().is_multi_session:
raise ValueError(
"If multiple sessions exists, `session` is a required parameter in the function decorated by @record_function"
"If multiple sessions exists, `session` is a required parameter in the function decorated by @record_action"
)
func_args = inspect.signature(func).parameters
arg_names = list(func_args.keys())
Expand Down
8 changes: 4 additions & 4 deletions docs/v1/concepts/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ The `ActionEvent` is a generic event for recording events that do not fit into t
| logs | str | None | "Executed action successfully" | Logs generated during the action event |
| screenshot | str | None | "/path/to/screenshot.png" | Path to screenshot captured during the action event |

An action event can be used the [same way as other events](/v1/usage/recording-events) but also with the `record_function`
decorator.
An action or tool event can be used the [same way as other events](/v1/usage/recording-events) but also with the `record_action` or `record_tool`
decorators.

<CodeGroup>
```python python
from agentops import record_function
from agentops import record_action

@record_function()
@record_action()
def some_action(params):
return "some response"
```
Expand Down
4 changes: 2 additions & 2 deletions docs/v1/examples/notebooks/openai-gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ <h1 id="events">Events</h1>
</div>
<div id="b45754a57148eed1" class="cell code" data-collapsed="false">
<div class="sourceCode" id="cb7"><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> agentops <span class="im">import</span> record_function</span>
class="sourceCode python"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> agentops <span class="im">import</span> record_action</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="at">@record_function</span>(<span class="st">&quot;add numbers&quot;</span>)</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="at">@record_action</span>(<span class="st">&quot;add numbers&quot;</span>)</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> add(x, y):</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> x <span class="op">+</span> y</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a></span>
Expand Down
6 changes: 3 additions & 3 deletions docs/v1/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ import EnvTooltip from '/snippets/add-env-tooltip.mdx'
<CardGroup cols={1}>

<Card icon="code" title="Decorate Functions">
You can instrument other functions inside your code with the handy `@record_function`
You can instrument other functions inside your code with the handy `@record_action`
decorator, which will record an `action_type`, the parameters, and the returns. You
will see these function calls alongside your LLM calls from instantiating the AgentOps client.
```python python
# (record specific functions)
@agentops.record_function('sample function being record')
@agentops.record_action('sample function being record')
def sample_function(...):
...
```
Expand Down Expand Up @@ -94,7 +94,7 @@ import agentops
agentops.init(<INSERT YOUR API KEY HERE>)

# (record specific functions)
@agentops.record_function('sample function being record')
@agentops.record_action('sample function being record')
def sample_function(...):
...

Expand Down
23 changes: 20 additions & 3 deletions docs/v1/usage/recording-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ description: "Log events such as agent actions, LLM calls, tool calls, and error
To get the most out of AgentOps, it is best to carefully consider what events to record -
not simply record whatever your agent is logging. AgentOps offers two ways to record events:

## `@record_function` Decorator
## `@record_action` Decorator

- **`event_type`** (str): Type of the event.

To make AgentOps easier to integrate, we also provide a function decorator to automatically creates
and records an event for your function.
To make AgentOps easier to integrate, we also provide a function decorator to automatically create
and record an event for your function.

```python python
from agentops import record_action
Expand All @@ -23,6 +23,23 @@ def sample_function(...):

The decorator will record the function's parameters, returns, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several openai calls, then each openai call will show in the replay graph as a child of the decorated function.

## `@record_tool` Decorator

- **`tool_name`** (str): The name of the tool represented by the python function

Additionally, we provide a function decorator to automatically create tool events for python functions.

```python python
from agentops import record_tool

@record_tool('SampleToolName')
def sample_tool(...):
...
```

The decorator will record the function's parameters, returns, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several openai calls, then each openai call will show in the replay graph as a child of the decorated function.


## `record()` Method

From this point, simply call the .record() method in the AgentOps client:
Expand Down
4 changes: 2 additions & 2 deletions examples/openai-gpt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@
},
"outputs": [],
"source": [
"from agentops import record_function\n",
"from agentops import record_action\n",
"\n",
"\n",
"@record_function(\"add numbers\")\n",
"@record_action(\"add numbers\")\n",
"def add(x, y):\n",
" return x + y\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/recording-events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
},
"outputs": [],
"source": [
"from agentops import record_function\n",
"from agentops import record_action\n",
"\n",
"\n",
"@record_function(\"add numbers\")\n",
"@record_action(\"add numbers\")\n",
"def add(x, y):\n",
" return x + y\n",
"\n",
Expand Down

0 comments on commit 0754e57

Please sign in to comment.