-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |