-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs] OpenAI Integration docs for the website (#549)
* minor fix in anthropic doc * add openai docs in integrations section * divert step for installation with tooltip * additional step for installing cohere sdk * change `params` to `logs` in `ActionEvent` * fix incorrect version mention * add section for `ollama` installation` * arrange integrations alphabetically and add `openai.mdx` * remove Python * modify link to openai.com * cleaner sections * add openai branding images * add sync example notebook * minor fix * minor correction in description * add async example notebook * something * updated examples `README.md` * add a `README.md` (kinda) to the `openai_examples` directory * minor correction * replace link --------- Co-authored-by: reibs <[email protected]>
- Loading branch information
Showing
14 changed files
with
714 additions
and
12 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,195 @@ | ||
--- | ||
title: OpenAI | ||
description: "AgentOps provides first class support for OpenAI's GPT family of models" | ||
--- | ||
|
||
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="OpenAI" icon="robot" href="https://www.openai.com"> | ||
First class support for GPT family of models | ||
</Card> | ||
|
||
<Steps> | ||
<Step title="Install the AgentOps SDK"> | ||
<CodeGroup> | ||
```bash pip | ||
pip install agentops | ||
``` | ||
```bash poetry | ||
poetry add agentops | ||
``` | ||
</CodeGroup> | ||
</Step> | ||
<Step title="Install the OpenAI SDK"> | ||
<Note> | ||
`openai<1.0.0` has limited support while `openai>=1.0.0` is continuously supported. | ||
</Note> | ||
<CodeGroup> | ||
```bash pip | ||
pip install openai | ||
``` | ||
```bash poetry | ||
poetry add openai | ||
``` | ||
</CodeGroup> | ||
|
||
To install `openai<1.0.0`, use the following: | ||
<CodeGroup> | ||
```bash pip | ||
pip install "openai<1.0.0" | ||
``` | ||
```bash poetry | ||
poetry add "openai<1.0.0" | ||
``` | ||
</CodeGroup> | ||
</Step> | ||
<Step title="Add 3 lines of code"> | ||
<CodeTooltip/> | ||
<span className="api-key-container"> | ||
<CodeGroup> | ||
```python python | ||
import agentops | ||
from openai import OpenAI | ||
|
||
agentops.init(<INSERT YOUR API KEY HERE>) | ||
client = OpenAI() | ||
... | ||
# 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> | ||
OPENAI_API_KEY=<YOUR OPENAI 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://raw.githubusercontent.com/AgentOps-AI/agentops/refs/heads/main/docs/images/external/app_screenshots/session-replay.png?raw=true" /> | ||
</Frame> | ||
</Step> | ||
</Steps> | ||
|
||
## Full Examples | ||
|
||
<CodeGroup> | ||
```python sync | ||
from openai import OpenAI | ||
import agentops | ||
|
||
agentops.init(<INSERT YOUR API KEY HERE>) | ||
client = OpenAI() | ||
|
||
response = client.chat.completions.create(( | ||
model="gpt-4o-mini", | ||
messages=[{ | ||
"role": "user", | ||
"content": "Write a haiku about AI and humans working together" | ||
}] | ||
) | ||
|
||
print(response.choices[0].message.content) | ||
agentops.end_session('Success') | ||
``` | ||
|
||
```python async | ||
from openai import AsyncOpenAI | ||
import agentops | ||
import asyncio | ||
|
||
async def main(): | ||
agentops.init(<INSERT YOUR API KEY HERE>) | ||
client = AsyncOpenAI() | ||
|
||
response = await client.chat.completions.create( | ||
model="gpt-4o-mini", | ||
messages=[{ | ||
"role": "user", | ||
"content": "Write a haiku about AI and humans working together" | ||
}] | ||
) | ||
|
||
print(response.choices[0].message.content) | ||
agentops.end_session('Success') | ||
|
||
asyncio.run(main()) | ||
``` | ||
|
||
</CodeGroup> | ||
|
||
### Streaming examples | ||
|
||
<CodeGroup> | ||
```python sync | ||
from openai import OpenAI | ||
import agentops | ||
|
||
agentops.init(<INSERT YOUR API KEY HERE>) | ||
client = OpenAI() | ||
|
||
stream = client.chat.completions.create( | ||
model="gpt-4o-mini", | ||
stream=True, | ||
messages=[{ | ||
"role": "user", | ||
"content": "Write a haiku about AI and humans working together" | ||
}], | ||
) | ||
|
||
for chunk in stream: | ||
print(chunk.choices[0].delta.content or "", end="") | ||
|
||
agentops.end_session('Success') | ||
``` | ||
|
||
```python async | ||
from openai import AsyncOpenAI | ||
import agentops | ||
import asyncio | ||
|
||
async def main(): | ||
agentops.init(<INSERT YOUR API KEY HERE>) | ||
client = AsyncOpenAI() | ||
|
||
stream = await client.chat.completions.create( | ||
model="gpt-4o-mini", | ||
stream=True, | ||
messages=[{ | ||
"role": "user", | ||
"content": "Write a haiku about AI and humans working together" | ||
}], | ||
) | ||
|
||
async for chunk in stream: | ||
print(chunk.choices[0].delta.content or "", end="") | ||
|
||
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> |
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
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,21 @@ | ||
# OpenAI integration with AgentOps | ||
|
||
AgentOps supports observability for OpenAI's API for both version 0.0.x and version 1.x. | ||
|
||
To learn more about OpenAI visit [here!](https://www.openai.com) and their documentation [here](https://platform.openai.com/docs/introduction). | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
* An AgentOps account with an API key | ||
* An OpenAI API key | ||
|
||
Refer to the [AgentOps documentation](https://docs.agentops.ai/getting-started/api-key) for more information on how to get an API key. | ||
|
||
### Documentation | ||
The documentation for the OpenAI integration can be found [here](https://docs.agentops.ai/integrations/openai). | ||
|
||
The example notebooks are present in the [openai_examples](./openai_examples/) directory. | ||
|
||
### License | ||
This project is released under the MIT License. |
Oops, something went wrong.