Skip to content

Commit

Permalink
update anthropic docs
Browse files Browse the repository at this point in the history
  • Loading branch information
areibman committed Nov 9, 2024
1 parent 630bd46 commit aab764b
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ agentops.end_session('Success')

Track agents built with the Anthropic Python SDK (>=0.32.0).

- [AgentOps integration guide](examples/anthropic_examples/anthropicguide.md)
- [AgentOps integration guide](https://docs.agentops.ai/v1/integrations/anthropic)
- [Official Anthropic documentation](https://docs.anthropic.com/en/docs/welcome)

<details>
Expand Down
120 changes: 120 additions & 0 deletions docs/v1/integrations/anthropic.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
title: Anthropic
description: "AgentOps provides first class support for Anthropic's Claude"
---

import CodeTooltip from '/snippets/add-code-tooltip.mdx'
import EnvTooltip from '/snippets/add-env-tooltip.mdx'

<Note>
This is a living integration. Should you need any added functionality, message us on [Discord](https://discord.gg/UgJyyxx7uc)!
</Note>

<Card title="Anthropic" icon="robot" href="https://www.anthropic.com">
First class support for Claude
</Card>

<Steps>
<Step title="Install the AgentOps SDK">
<CodeGroup>
```bash pip
pip install agentops anthropic
```
```bash poetry
poetry add agentops anthropic
```
</CodeGroup>
</Step>
<Step title="Add 3 lines of code">
<CodeTooltip/>
<span className="api-key-container">
<CodeGroup>
```python python
import agentops
from anthropic import Anthropic
agentops.init(<INSERT YOUR API KEY HERE>)
client = Anthropic()
...
# End of program (e.g. main.py)
agentops.end_session("Success") # Success|Fail|Indeterminate
```
</CodeGroup>
</span>
<EnvTooltip />
<span className="api-key-container">
<CodeGroup>
```python .env
AGENTOPS_API_KEY=<YOUR API KEY>
ANTHROPIC_API_KEY=<YOUR ANTHROPIC API KEY>
```
</CodeGroup>
Read more about environment variables in [Advanced Configuration](/v1/usage/advanced-configuration)
</span>
</Step>
<Step title="Run your Agent">
Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Agent! 🕵️
<Tip>
After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard
</Tip>
<div/>
<Frame type="glass" caption="Clickable link to session">
<img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/link-to-session.gif?raw=true" />
</Frame>
</Step>
</Steps>

## Full Examples

<CodeGroup>
```python sync
from anthropic import Anthropic
import agentops
agentops.init(<INSERT YOUR API KEY HERE>)
client = Anthropic()
message = client.messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[{
"role": "user",
"content": "Write a haiku about AI and humans working together"
}]
)
print(message.content)
agentops.end_session('Success')
```

```python async
from anthropic import AsyncAnthropic
import agentops
import asyncio
async def main():
agentops.init(<INSERT YOUR API KEY HERE>)
client = AsyncAnthropic()
message = await client.messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[{
"role": "user",
"content": "Write a haiku about AI and humans working together"
}]
)
print(message.content)
agentops.end_session('Success')
asyncio.run(main())
```
</CodeGroup>

<script type="module" src="/scripts/github_stars.js"></script>
<script type="module" src="/scripts/link_to_api_button.js"></script>
<script type="module" src="/scripts/scroll-img-fadein-animation.js"></script>
<script type="module" src="/scripts/button_heartbeat_animation.js"></script>
<script type="css" src="/styles/styles.css"></script>
<script type="module" src="/scripts/adjust_api_dynamically.js"></script>

0 comments on commit aab764b

Please sign in to comment.