Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
areibman committed Nov 5, 2024
1 parent fb2b531 commit c23fb6f
Showing 1 changed file with 55 additions and 29 deletions.
84 changes: 55 additions & 29 deletions docs/v1/integrations/ai21.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ description: "Use AI21's latest models with AgentOps including:
Jamba 1.5, Jamba Instruct, and specialized task models"
---

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

## AI21

From [AI21's docs](https://docs.ai21.com/):
Expand All @@ -14,42 +17,65 @@ AI21 provides state-of-the-art language models through a simple API, offering:
- Chat and completion endpoints
- Enterprise-grade reliability and support

AI21 supports several [models](https://docs.ai21.com/reference/models) including Jamba 1.5, Jamba Instruct, and task-specific models.
AI21 supports several including Jamba 1.5, Jamba Instruct, and task-specific models.

## Using AgentOps with AI21

### Requires `ai21>=2.0.0`

AgentOps works seamlessly with AI21's Python SDK. Here's how to use it:

```python
from ai21 import AI21Client
from ai21.models.chat import ChatMessage
import agentops

# Initialize clients
client = AI21Client(api_key="your-api-key")
agentops.init("your-agentops-key")

# Create your messages
messages = [
ChatMessage(
content="You are a world renowned poet in the style of Edgar Allan Poe.",
role="system",
),
ChatMessage(
content="Write me a short poem about AI agents.",
role="user",
),
]

# Make the API call
response = client.chat.completions.create(
messages=messages,
model="jamba-1.5-mini",
)
print(response.choices[0].message.content)
```
<Steps>
<Step title="Install the AgentOps SDK">
<CodeGroup>
```bash pip
pip install agentops
```
```bash poetry
poetry add agentops
```
</CodeGroup>
</Step>
<Step title="Add AgentOps to your code">
<CodeTooltip/>
<span className="api-key-container">
<CodeGroup>
```python python
from ai21 import AI21Client
from ai21.models.chat import ChatMessage
import agentops
# Initialize clients
agentops.init(<INSERT YOUR API KEY HERE>)
client = AI21Client(api_key="your-api-key")
# Your AI21 code here...
agentops.end_session("Success") # Success|Fail|Indeterminate
```
</CodeGroup>
</span>
<EnvTooltip />
<span className="api-key-container">
<CodeGroup>
```python .env
AGENTOPS_API_KEY=<YOUR 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/>{/* Intentionally blank div for newline */}
<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>

### Streaming Support

Expand Down

0 comments on commit c23fb6f

Please sign in to comment.