Skip to content

Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI

[Docs] Update and clean existing docs for better readability (#558)

Pratyush Shukla7bbda270e712
diff --git a/docs/images/external/ai21/ai21-session.png b/docs/images/external/ai21/ai21-session.png
new file mode 100644
index 00000000..f93d09a8
Binary files /dev/null and b/docs/images/external/ai21/ai21-session.png differ
diff --git a/docs/images/external/anthropic/anthropic_icon_ivory.png b/docs/images/external/anthropic/anthropic_icon_ivory.png
new file mode 100644
index 00000000..0996de43
Binary files /dev/null and b/docs/images/external/anthropic/anthropic_icon_ivory.png differ
diff --git a/docs/images/external/anthropic/anthropic_icon_slate.png b/docs/images/external/anthropic/anthropic_icon_slate.png
new file mode 100644
index 00000000..7ce130f7
Binary files /dev/null and b/docs/images/external/anthropic/anthropic_icon_slate.png differ
diff --git a/docs/images/external/anthropic/anthropic_wordmark_ivory.png b/docs/images/external/anthropic/anthropic_wordmark_ivory.png
new file mode 100644
index 00000000..5453b056
Binary files /dev/null and b/docs/images/external/anthropic/anthropic_wordmark_ivory.png differ
diff --git a/docs/images/external/anthropic/anthropic_wordmark_slate.png b/docs/images/external/anthropic/anthropic_wordmark_slate.png
new file mode 100644
index 00000000..a2ea2702
Binary files /dev/null and b/docs/images/external/anthropic/anthropic_wordmark_slate.png differ
diff --git a/docs/images/external/cohere/Cohere-Logo-Color-RGB.png b/docs/images/external/cohere/Cohere-Logo-Color-RGB.png
new file mode 100644
index 00000000..fc3264c2
Binary files /dev/null and b/docs/images/external/cohere/Cohere-Logo-Color-RGB.png differ
diff --git a/docs/images/external/cohere/Cohere-Logo-Mono Marble White-RGB.png b/docs/images/external/cohere/Cohere-Logo-Mono Marble White-RGB.png
new file mode 100644
index 00000000..9769a318
Binary files /dev/null and b/docs/images/external/cohere/Cohere-Logo-Mono Marble White-RGB.png differ
diff --git a/docs/images/external/cohere/Cohere-Logo-Mono Volcanic Black-RGB.png b/docs/images/external/cohere/Cohere-Logo-Mono Volcanic Black-RGB.png
new file mode 100644
index 00000000..b1bdc271
Binary files /dev/null and b/docs/images/external/cohere/Cohere-Logo-Mono Volcanic Black-RGB.png differ
diff --git a/docs/images/external/groq/groq_session.png b/docs/images/external/groq/groq_session.png
new file mode 100644
index 00000000..4a18dcd4
Binary files /dev/null and b/docs/images/external/groq/groq_session.png differ
diff --git a/docs/images/external/mistral/mistral-ai-icon.png b/docs/images/external/mistral/mistral-ai-icon.png
new file mode 100644
index 00000000..c67d0371
Binary files /dev/null and b/docs/images/external/mistral/mistral-ai-icon.png differ
diff --git a/docs/images/external/mistral/mistral_session.png b/docs/images/external/mistral/mistral_session.png
new file mode 100644
index 00000000..c7f9c8fe
Binary files /dev/null and b/docs/images/external/mistral/mistral_session.png differ
diff --git a/docs/mint.json b/docs/mint.json
index c534fc6a..9f6ae7ad 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -87,12 +87,15 @@
{
"group": "Integrations",
"pages": [
+ "v1/integrations/ai21",
"v1/integrations/anthropic",
"v1/integrations/autogen",
"v1/integrations/cohere",
"v1/integrations/crewai",
+ "v1/integrations/groq",
"v1/integrations/langchain",
"v1/integrations/litellm",
+ "v1/integrations/mistral",
"v1/integrations/multion",
"v1/integrations/ollama",
"v1/integrations/openai",
diff --git a/docs/v1/examples/examples.mdx b/docs/v1/examples/examples.mdx
index 85b4583d..df665188 100644
--- a/docs/v1/examples/examples.mdx
+++ b/docs/v1/examples/examples.mdx
@@ -6,34 +6,60 @@ mode: "wide"
## Explore our example code to see AgentOps in action!
+### Agent Examples
<CardGroup cols={2}>
<Card title="Simple Agent" icon="microchip-ai" iconType="solid" href="/v1/examples/simple_agent">
Jupyter Notebook with sample code that you can run! Start here!
</Card>
- <Card title="Crew.ai Example" icon="ship" href="/v1/integrations/crewai">
- CrewAI multi-agent framework with AgentOps support
+ <Card title="Multi-Agent" icon="people-arrows" iconType="duotone" href="/v1/examples/multi_agent">
+ Jupyter Notebook with a simple multi-agent design
+ </Card>
+ <Card title="Multi Session" icon="computer" href="/v1/examples/multi_session">
+ Manage multiple sessions at the same time
+ </Card>
+</CardGroup>
+
+### Integration Examples
+<CardGroup cols={2}>
+ <Card title="AI21" icon="brain" href="/v1/integrations/ai21">
+ Integration with AI21's language models
+ </Card>
+ <Card title="Anthropic" icon={<img src="https://www.github.com/agentops-ai/agentops/blob/main/docs/images/external/anthropic/anthropic_icon_ivory.png?raw=true" alt="Anthropic" />} iconType="image" href="/v1/integrations/anthropic">
+ Track observations from Claude, Haiku and Sonnet series of models
</Card>
<Card title="AutoGen" icon="microsoft" href="/v1/integrations/autogen">
AutoGen multi-agent conversible workflow with tool usage
</Card>
- <Card title="Multi-Agent Code Example" icon="people-arrows" iconType="duotone" href="/v1/examples/multi_agent">
- Jupyter Notebook with a simple multi-agent design
+ <Card title="Cohere" icon={<img src="https://www.github.com/agentops-ai/agentops/blob/main/docs/images/external/cohere/Cohere-Logo-Mono Marble White-RGB.png?raw=true" alt="Cohere" />} iconType="image" href="/v1/integrations/cohere">
+ First class support for Command-R-Plus and chat streaming
+ </Card>
+ <Card title="Crew.ai" icon="ship" href="/v1/integrations/crewai">
+ CrewAI multi-agent framework with AgentOps support
</Card>
- <Card title="LangChain Example" icon="crow" href="/v1/examples/langchain">
+ <Card title="Groq" icon="bolt" href="/v1/integrations/groq">
+ Ultra-fast LLM inference with Groq Cloud
+ </Card>
+ <Card title="LangChain" icon="crow" href="/v1/examples/langchain">
Jupyter Notebook with a sample LangChain integration
</Card>
- <Card title="FastAPI Example" icon="bolt-lightning" href="/v1/examples/fastapi">
- Create a REST server that performs and observes agent tasks
+ <Card title="LiteLLM" icon="wand-magic-sparkles" href="/v1/integrations/litellm">
+ Unified interface for multiple LLM providers
</Card>
- <Card title="Multi Session Example" icon="computer" href="/v1/examples/multi_session">
- Manage multiple sessions at the same time
+ <Card title="Mistral" icon={<img src="https://www.github.com/agentops-ai/agentops/blob/main/docs/images/external/mistral/mistral-ai-icon.png?raw=true" alt="Mistral" />} iconType="image" href="/v1/integrations/mistral">
+ Support for Mistral AI's open-weight models
</Card>
- <Card title="MultiOn Example" icon="atom" href="/v1/examples/multion">
+ <Card title="MultiOn" icon="atom" href="/v1/examples/multion">
Create an autonomous browser agent capable of navigating the web and extracting information
</Card>
- <Card title="Ollama Example" icon={<img src="https://www.github.com/agentops-ai/agentops/blob/main/docs/images/external/ollama/ollama-icon.png?raw=true" alt="Ollama" />} iconType="image" href="/v1/examples/ollama">
+ <Card title="Ollama" icon={<img src="https://www.github.com/agentops-ai/agentops/blob/main/docs/images/external/ollama/ollama-icon.png?raw=true" alt="Ollama" />} iconType="image" href="/v1/examples/ollama">
Simple Ollama integration with AgentOps
</Card>
+ <Card title="OpenAI" icon={<img src="https://www.github.com/agentops-ai/agentops/blob/main/docs/images/external/openai/openai-white-logomark.png?raw=true" alt="OpenAI" />} iconType="image" href="/v1/integrations/openai">
+ First class support for GPT family of models
+ </Card>
+ <Card title="REST API" icon="bolt-lightning" href="/v1/examples/restapi">
+ Create a REST server that performs and observes agent tasks
+ </Card>
</CardGroup>
## Video Guides
@@ -58,7 +84,6 @@ mode: "wide"
</CardGroup>
<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="module" src="/scripts/adjust_api_dynamically.js"></script>
diff --git a/docs/v1/examples/langchain.mdx b/docs/v1/examples/langchain.mdx
index b8065e25..d7712d62 100644
--- a/docs/v1/examples/langchain.mdx
+++ b/docs/v1/examples/langchain.mdx
@@ -3,7 +3,7 @@ title: 'LangChain Example'
description: 'Using the LangChain Callback Handler'
mode: "wide"
---
-_View Notebook on <a href={'https://github.com/AgentOps-AI/agentops/blob/48ae12d4e4e085eed57346f1c40a054097431937/examples/langchain_examples.ipynb'} target={'_blank'}>Github</a>_
+_View Notebook on <a href={'https://github.com/AgentOps-AI/agentops/blob/main/examples/langchain_examples.ipynb'} target={'_blank'}>Github</a>_
{/* SOURCE_FILE: examples/langchain_examples/langchain_examples.ipynb */}
@@ -149,181 +149,4 @@ Finally, check your run on [AgentOps](https://app.agentops.ai)
Now if we look in the AgentOps dashboard, you will see a session recorded with the LLM calls and tool usage.
## Langchain V0.1 Example
-This example is out of date. You can uncomment all the following cells and the example will run but AgentOps is deprecating support.
-
-
-```python
-# %pip install langchain==0.1.6
-```
-
-
-```python
-# import os
-# from langchain_openai import ChatOpenAI
-# from langchain.agents import initialize_agent, AgentType
-# from langchain.agents import tool
-```
-
-The only difference with using AgentOps is that we'll also import this special Callback Handler
-
-
-```python
-# from agentops.partners.langchain_callback_handler import (
-# LangchainCallbackHandler as AgentOpsLangchainCallbackHandler,
-# )
-```
-
-Next, we'll grab our two API keys.
-
-
-```python
-# from dotenv import load_dotenv
-
-# load_dotenv()
-```
-
-This is where AgentOps comes into play. Before creating our LLM instance via Langchain, first we'll create an instance of the AO LangchainCallbackHandler. After the handler is initialized, a session will be recorded automatically.
-
-Pass in your API key, and optionally any tags to describe this session for easier lookup in the AO dashboard.
-
-
-```python
-# AGENTOPS_API_KEY = os.environ.get("AGENTOPS_API_KEY")
-# OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
-
-# agentops_handler = AgentOpsLangchainCallbackHandler(
-# api_key=AGENTOPS_API_KEY, default_tags=["Langchain Example"]
-# )
-
-# llm = ChatOpenAI(
-# openai_api_key=OPENAI_API_KEY, callbacks=[agentops_handler], model="gpt-3.5-turbo"
-# )
-```
-
-You can also retrieve the `session_id` of the newly created session.
-
-
-```python
-# print("Agent Ops session ID: " + str(agentops_handler.current_session_ids))
-```
-
-Agents generally use tools. Let's define a simple tool here. Tool usage is also recorded.
-
-
-```python
-# @tool
-# def find_movie(genre) -> str:
-# """Find available movies"""
-# if genre == "drama":
-# return "Dune 2"
-# else:
-# return "Pineapple Express"
-
-
-# tools = [find_movie]
-```
-
-For each tool, you need to also add the callback handler
-
-
-```python
-# for t in tools:
-# t.callbacks = [agentops_handler]
-```
-
-Finally, let's use our agent! Pass in the callback handler to the agent, and all the actions will be recorded in the AO Dashboard
-
-
-```python
-# agent = initialize_agent(
-# tools,
-# llm,
-# agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
-# verbose=True,
-# callbacks=[
-# agentops_handler
-# ], # You must pass in a callback handler to record your agent
-# handle_parsing_errors=True,
-# )
-```
-
-
-```python
-# agent.invoke("What comedies are playing?", callbacks=[agentops_handler])
-```
-
-## Check your session
-Finally, check your run on [AgentOps](https://app.agentops.ai)
-
-# Async Agents
-
-Several langchain agents require async callback handlers. AgentOps also supports this.
-
-
-```python
-# import os
-# from langchain.chat_models import ChatOpenAI
-# from langchain.agents import initialize_agent, AgentType
-# from langchain.agents import tool
-```
-
-
-```python
-# from agentops.partners.langchain_callback_handler import (
-# AsyncLangchainCallbackHandler as AgentOpsAsyncLangchainCallbackHandler,
-# )
-```
-
-
-```python
-# from dotenv import load_dotenv
-
-# load_dotenv()
-
-# AGENTOPS_API_KEY = os.environ.get("AGENTOPS_API_KEY")
-# OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
-```
-
-
-```python
-# agentops_handler = AgentOpsAsyncLangchainCallbackHandler(
-# api_key=AGENTOPS_API_KEY, tags=["Async Example"]
-# )
-
-# llm = ChatOpenAI(
-# openai_api_key=OPENAI_API_KEY, callbacks=[agentops_handler], model="gpt-3.5-turbo"
-# )
-
-# print("Agent Ops session ID: " + str(await agentops_handler.session_id))
-```
-
-
-```python
-# @tool
-# def find_movie(genre) -> str:
-# """Find available movies"""
-# if genre == "drama":
-# return "Dune 2"
-# else:
-# return "Pineapple Express"
-
-
-# tools = [find_movie]
-
-# for t in tools:
-# t.callbacks = [agentops_handler]
-```
-
-
-```python
-# agent = initialize_agent(
-# tools,
-# llm,
-# agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
-# verbose=True,
-# handle_parsing_errors=True,
-# callbacks=[agentops_handler],
-# )
-
-# await agent.arun("What comedies are playing?")
-```
+You can find the example in the [notebook](https://github.com/AgentOps-AI/agentops/blob/main/examples/langchain_examples.ipynb).
diff --git a/docs/v1/examples/multi_session.mdx b/docs/v1/examples/multi_session.mdx
index 794a7865..c2b073f6 100644
--- a/docs/v1/examples/multi_session.mdx
+++ b/docs/v1/examples/multi_session.mdx
@@ -3,6 +3,117 @@ title: 'Multi-Session Example'
description: 'Handling multiple sessions at the same time'
mode: "wide"
---
+
_View Notebook on <a href={'https://github.com/AgentOps-AI/agentops/blob/main/examples/multi_session_llm.ipynb'} target={'_blank'}>Github</a>_
-{ /* SOURCE_FILE: examples/multi_session_llm.ipynb */}
\ No newline at end of file
+# Multiple Concurrent Sessions
+This example will show you how to run multiple sessions concurrently, assigning LLM calls to a specific session.
+
+First let's install the required packages:
+
+```bash
+pip install -U openai
+pip install -U agentops
+pip install -U python-dotenv
+```
+
+Then import them:
+
+```python
+from openai import OpenAI
+import agentops
+from agentops import ActionEvent
+import os
+from dotenv import load_dotenv
+```
+
+Next, we'll set our API keys. There are several ways to do this, the code below is just the most foolproof way for the purposes of this example. It accounts for both users who use environment variables and those who just want to set the API Key here.
+
+[Get an AgentOps API key](https://agentops.ai/settings/projects)
+
+1. Create an environment variable in a .env file or other method. By default, the AgentOps `init()` function will look for an environment variable named `AGENTOPS_API_KEY`. Or...
+
+2. Replace `<your_agentops_key>` below and pass in the optional `api_key` parameter to the AgentOps `init(api_key=...)` function. Remember not to commit your API key to a public repo!
+
+```python
+load_dotenv()
+OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") or "<your_openai_key>"
+AGENTOPS_API_KEY = os.getenv("AGENTOPS_API_KEY") or "<your_agentops_key>"
+```
+
+Then, of course, lets init AgentOps. We're going to bypass creating a session automatically for the sake of showing it below.
+
+```python
+agentops.init(AGENTOPS_API_KEY, auto_start_session=False)
+openai = OpenAI()
+```
+
+Now lets create two sessions, each with an identifiable tag.
+
+```python
+session_1 = agentops.start_session(tags=["multi-session-test-1"])
+session_2 = agentops.start_session(tags=["multi-session-test-2"])
+
+print("session_id_1: {}".format(session_1.session_id))
+print("session_id_2: {}".format(session_2.session_id))
+```
+
+## LLM Calls
+Now lets go ahead and make our first OpenAI LLM call. The challenge with having multiple sessions at the same time is that there is no way for AgentOps to know what LLM call is intended to pertain to what active session. This means we need to do a little extra work in one of two ways.
+
+```python
+messages = [{"role": "user", "content": "Hello"}]
+```
+
+### Patching Function
+This method involves wrapping the LLM call withing a function on session. It can look a little counter-intuitive, but it easily tells us what session the call belongs to.
+
+```python
+# option 1: use session.patch
+response = session_1.patch(openai.chat.completions.create)(
+ model="gpt-3.5-turbo",
+ messages=messages,
+ temperature=0.5,
+)
+```
+
+### Create patched function
+If you're using the create function multiple times, you can create a new function with the same method
+
+```python
+observed_create = session_1.patch(openai.chat.completions.create)
+obs_response = observed_create(
+ model="gpt-3.5-turbo",
+ messages=messages,
+ temperature=0.5,
+)
+```
+
+### Keyword Argument
+Alternatively, you can also pass the session into the LLM function call as a keyword argument. While this method works and is a bit more readable, it is not a "pythonic" pattern and can lead to linting errors in the code, as the base function is not expecting a `session` keyword.
+
+```python
+# option 2: add session as a keyword argument
+response2 = openai.chat.completions.create(
+ model="gpt-3.5-turbo", messages=messages, temperature=0.5, session=session_2
+)
+```
+
+## Recording Events
+Outside of LLM calls, there are plenty of other events that we want to track. You can learn more about these events [here](https://docs.agentops.ai/v1/concepts/events).
+
+Recording these events on a session is as simple as `session.record(...)`
+
+```python
+session_1.record(ActionEvent(action_type="test event"))
+```
+
+Now let's go ahead and end the sessions
+
+```python
+session_1.end_session(end_state="Success")
+session_2.end_session(end_state="Success")
+```
+
+If you look in the AgentOps dashboard for these sessions, you will see two unique sessions, both with one LLM Event each, one with an Action Event as well.
+
diff --git a/docs/v1/examples/multion.mdx b/docs/v1/examples/multion.mdx
index 274c6ada..9200dc72 100644
--- a/docs/v1/examples/multion.mdx
+++ b/docs/v1/examples/multion.mdx
@@ -10,7 +10,7 @@ _View All Notebooks on <a href={'https://github.com/AgentOps-AI/agentops/blob/ma
{/* SOURCE_FILE: examples/multion_examples/Autonomous_web_browsing.ipynb */}
# MultiOn Tracking Web Browse Actions
-<img src="https://github.com/AgentOps-AI/agentops/blob/b4aac2d4b9fb16d6aa0a25aa9018210a94f1bef2/docs/logo/multion_integration.png?raw=true" width="250px" style="max-width: 100%; height: auto;"/>
+<img src="https://github.com/AgentOps-AI/agentops/blob/main/docs/logo/multion_integration.png?raw=true" width="250px" style="max-width: 100%; height: auto;"/>
Agents using MultiOn can launch and control remote or local web browsers to perform actions and retrieve context using natural language commands. With AgentOps, MultiOn evens such as browse, retrieve, and step are automatically tracked.
diff --git a/docs/v1/examples/fastapi.mdx b/docs/v1/examples/restapi.mdx
similarity index 86%
rename from docs/v1/examples/fastapi.mdx
rename to docs/v1/examples/restapi.mdx
index 166d3155..964a5bfc 100644
--- a/docs/v1/examples/fastapi.mdx
+++ b/docs/v1/examples/restapi.mdx
@@ -26,18 +26,13 @@ mode: "wide"
```
</CodeGroup>
</Step>
- <Step title="Install Crew from the AgentOps fork">
- <Warning>
- At this time, Crew with AgentOps integration is in pre-release. In the interim, an official fork has been
- made available. After official support is released, this fork will be deprecated and developers will
- be encouraged to use the core Crew SDK.
- </Warning>
+ <Step title="Install Crew with AgentOps">
<CodeGroup>
```bash pip
- pip install git+https://github.com/AgentOps-AI/crewAI.git@main
+ pip install 'crewai[agentops]'
```
```bash poetry
- poetry add git+https://github.com/AgentOps-AI/crewAI.git@main
+ poetry add 'crewai[agentops]'
```
</CodeGroup>
</Step>
@@ -85,7 +80,7 @@ mode: "wide"
</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" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/link-to-session.gif?raw=true" />
</Frame>
</Step>
</Steps>
diff --git a/docs/v1/integrations/ai21.mdx b/docs/v1/integrations/ai21.mdx
index aab669ab..e71c298a 100644
--- a/docs/v1/integrations/ai21.mdx
+++ b/docs/v1/integrations/ai21.mdx
@@ -1,29 +1,14 @@
---
title: AI21
-description: "Use AI21's latest models with AgentOps including:
-Jamba 1.5, Jamba Instruct, and specialized task models"
+description: "Observe AI21's latest Jamba family of models with AgentOps "
---
import CodeTooltip from '/snippets/add-code-tooltip.mdx'
import EnvTooltip from '/snippets/add-env-tooltip.mdx'
-## AI21
+AgentOps has first party support for [AI21](https://www.ai21.com) via its Python SDK. Explore development with AI21 by visiting their [docs](https://docs.ai21.com/docs).
-From [AI21's docs](https://docs.ai21.com/):
-
-AI21 provides state-of-the-art language models through a simple API, offering:
-- Multiple model sizes to balance performance and cost
-- Specialized models for specific tasks like contextual answers
-- Chat and completion endpoints
-- Enterprise-grade reliability and support
-
-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:
+## Steps to integrate AI21 with AgentOps
<Steps>
<Step title="Install the AgentOps SDK">
@@ -36,9 +21,21 @@ AgentOps works seamlessly with AI21's Python SDK. Here's how to use it:
```
</CodeGroup>
</Step>
+ <Step title="Install the AI21 SDK">
+ <Note>
+ We currently support v2.x.x of the AI21 SDK and plan to support v3.x.x in the future.
+ </Note>
+ <CodeGroup>
+ ```bash pip
+ pip install "ai21<3.0.0"
+ ```
+ ```bash poetry
+ poetry add "ai21<3.0.0"
+ ```
+ </CodeGroup>
+ </Step>
<Step title="Add AgentOps to your code">
<CodeTooltip/>
- <span className="api-key-container">
<CodeGroup>
```python python
from ai21 import AI21Client
@@ -51,92 +48,214 @@ AgentOps works seamlessly with AI21's Python SDK. Here's how to use it:
# Your AI21 code here...
- agentops.end_session("Success") # Success|Fail|Indeterminate
+ agentops.end_session("Success")
```
</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 */}
+ <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" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/external/ai21/ai21-session.png?raw=true" />
</Frame>
</Step>
</Steps>
-### Streaming Support
+## Full Examples
+
+<CodeGroup>
+ ```python sync
+ from ai21 import AI21Client
+ from ai21.models.chat import ChatMessage
+ import agentops
+
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = AI21Client(api_key="your-api-key")
+
+ 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 the AI agents co-existing within the human brain.",
+ role="user",
+ ),
+ ]
+
+ response = client.chat.completions.create(
+ messages=messages,
+ model="jamba-1.5-mini",
+ )
+
+ print(response.choices[0].message.content)
+ agentops.end_session('Success')
+ ```
+
+ ```python async
+ from ai21 import AsyncAI21Client
+ import agentops
+ import asyncio
+
+ async def main():
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = AsyncAI21Client(api_key="your-api-key")
-AI21 supports streaming responses:
+ 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 the AI agents co-existing within the human brain.",
+ role="user",
+ ),
+ ]
-```python
-response = ""
-stream_response = client.chat.completions.create(
- messages=messages,
- model="jamba-instruct",
- stream=True,
-)
+ response = await client.chat.completions.create(
+ messages=messages,
+ model="jamba-1.5-mini",
+ )
-for chunk in stream_response:
- response += str(chunk.choices[0].delta.content)
-```
+ print(response.choices[0].message.content)
+ agentops.end_session('Success')
-### Async Support
+ asyncio.run(main())
+ ```
+</CodeGroup>
-You can also use AI21 models asynchronously:
+### Streaming Examples
-```python
-from ai21 import AsyncAI21Client
+<CodeGroup>
+ ```python sync
+ from ai21 import AI21Client
+ from ai21.models.chat import ChatMessage
+ import agentops
-aclient = AsyncAI21Client(api_key="your-api-key")
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = AI21Client(api_key="your-api-key")
-async def main():
- async_response = await aclient.chat.completions.create(
- messages=messages,
- model="jamba-1.5-mini",
- )
- print(async_response.choices[0].message.content)
+ 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 the AI agents co-existing within the human brain.",
+ role="user",
+ ),
+ ]
-await main()
-```
+ complete_response = ""
+
+ response = client.chat.completions.create(
+ messages=messages,
+ model="jamba-1.5-mini",
+ stream=True,
+ )
+
+ for chunk in response:
+ complete_response += str(chunk.choices[0].delta.content)
+
+ print(complete_response)
+ agentops.end_session('Success')
+ ```
+
+ ```python async
+ from ai21 import AsyncAI21Client
+ import agentops
+ import asyncio
+
+ async def main():
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = AsyncAI21Client(api_key="your-api-key")
+
+ 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 the AI agents co-existing within the human brain.",
+ role="user",
+ ),
+ ]
+
+ complete_response = ""
+
+ response = await client.chat.completions.create(
+ messages=messages,
+ model="jamba-1.5-mini",
+ stream=True,
+ )
+
+ async for chunk in response:
+ complete_response += str(chunk.choices[0].delta.content)
+
+ print(complete_response)
+ agentops.end_session('Success')
+
+ asyncio.run(main())
+ ```
+</CodeGroup>
### Task-Specific Models
-AI21 provides specialized models for specific tasks. Here's an example using the contextual answers endpoint:
+AI21 v2.x.x provides specialized models called Task Specific Models for specific tasks.
+
+Here's an example using the contextual answers endpoint:
+
+<CodeGroup>
+ ```python
+ from ai21 import AI21Client
+ import agentops
+
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = AI21Client(api_key="your-api-key")
+
+ CONTEXT = """
+ In 2020 and 2021, enormous QE — approximately $4.4 trillion, or 18%, of 2021 gross
+ domestic product (GDP) — and enormous fiscal stimulus (which has been and
+ always will be inflationary) — approximately $5 trillion, or 21%, of 2021 GDP
+ — stabilized markets and allowed companies to raise enormous amounts of
+ capital. In addition, this infusion of capital saved many small businesses and
+ put more than $2.5 trillion in the hands of consumers and almost $1 trillion into
+ state and local coffers. These actions led to a rapid decline in unemployment,
+ dropping from 15% to under 4% in 20 months — the magnitude and speed of which were both
+ unprecedented. Additionally, the economy grew 7% in 2021 despite the arrival of
+ the Delta and Omicron variants and the global supply chain shortages, which were
+ largely fueled by the dramatic upswing in consumer spending and the shift in
+ that spend from services to goods.
+ """
+
+ response = client.answer.create(
+ context=CONTEXT,
+ question="Did the economy shrink after the Omicron variant arrived?",
+ )
+
+ print(response.answer)
+ agentops.end_session('Success')
+ ```
-```python
-response = client.answer.create(
- context="Your context text here...",
- question="Your question here?",
-)
-print(response.answer)
-```
+</CodeGroup>
-You can also stream answers:
+<Note>
+ If you want to stream the response, you can use the stream=True flag. The streaming response is handled by the AI21 SDK.
+</Note>
-```python
-response = client.answer.create(
- context="Your context text here...",
- question="Your question here?",
- stream=True,
-)
-print(response.answer)
-```
+All of these examples can be found in this [notebook](https://github.com/AgentOps-AI/agentops/blob/main/examples/ai21_examples/ai21_examples.ipynb).
<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>
diff --git a/docs/v1/integrations/anthropic.mdx b/docs/v1/integrations/anthropic.mdx
index 6b135159..e095535a 100644
--- a/docs/v1/integrations/anthropic.mdx
+++ b/docs/v1/integrations/anthropic.mdx
@@ -1,18 +1,15 @@
---
title: Anthropic
-description: "AgentOps provides first class support for Anthropic's Claude"
+description: "AgentOps provides first class support for Anthropic's latest 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>
+[Anthropic AI](https://www.anthropic.com) is a leading provider of AI tools and services, including the Claude, Haiku, and Sonnet series of models.
+Explore the [Anthropic API](https://docs.anthropic.com/en/home) for more information.
-<Card title="Anthropic" icon="robot" href="https://www.anthropic.com">
- First class support for Claude
-</Card>
+# Steps to integrate Anthropic with AgentOps
<Steps>
<Step title="Install the AgentOps SDK">
@@ -40,7 +37,6 @@ This is a living integration. Should you need any added functionality, message u
</Step>
<Step title="Add 3 lines of code">
<CodeTooltip/>
- <span className="api-key-container">
<CodeGroup>
```python python
import agentops
@@ -53,9 +49,7 @@ This is a living integration. Should you need any added functionality, message u
agentops.end_session("Success") # Success|Fail|Indeterminate
```
</CodeGroup>
- </span>
<EnvTooltip />
- <span className="api-key-container">
<CodeGroup>
```python .env
AGENTOPS_API_KEY=<YOUR API KEY>
@@ -63,7 +57,6 @@ This is a living integration. Should you need any added functionality, message u
```
</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! 🕵️
@@ -72,7 +65,7 @@ This is a living integration. Should you need any added functionality, message u
</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" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/link-to-session.gif?raw=true" />
</Frame>
</Step>
</Steps>
@@ -126,7 +119,6 @@ This is a living integration. Should you need any added functionality, message u
</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>
diff --git a/docs/v1/integrations/autogen.mdx b/docs/v1/integrations/autogen.mdx
index 0ec7d734..a9cfc412 100644
--- a/docs/v1/integrations/autogen.mdx
+++ b/docs/v1/integrations/autogen.mdx
@@ -1,14 +1,12 @@
---
title: Autogen
-description: "AgentOps provides first class support for Autogen"
+description: "Track your Autogen agents with AgentOps"
---
import CodeTooltip from '/snippets/add-code-tooltip.mdx'
import EnvTooltip from '/snippets/add-env-tooltip.mdx'
-AgentOps and Autogen teamed up to make monitoring Autogen agents dead simple.
-
-Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/docs) available as well as a great [quickstart](https://microsoft.github.io/autogen/docs/Getting-Started).
+AgentOps and Autogen teamed up to make monitoring Autogen agents dead simple. Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/docs) available as well as a great [quickstart](https://microsoft.github.io/autogen/docs/Getting-Started).
## Adding AgentOps to Autogen agents
@@ -35,7 +33,6 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do
</Step>
<Step title="Add 3 lines of code">
<CodeTooltip/>
- <span className="api-key-container">
<CodeGroup>
```python python
import agentops
@@ -45,16 +42,13 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do
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 Autogen Agent! 🕵️
@@ -63,13 +57,12 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do
</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" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/link-to-session.gif?raw=true" />
</Frame>
</Step>
</Steps>
<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>
diff --git a/docs/v1/integrations/cohere.mdx b/docs/v1/integrations/cohere.mdx
index 587adab6..8603223a 100644
--- a/docs/v1/integrations/cohere.mdx
+++ b/docs/v1/integrations/cohere.mdx
@@ -6,8 +6,10 @@ description: "AgentOps provides first class support for Cohere"
import CodeTooltip from '/snippets/add-code-tooltip.mdx'
import EnvTooltip from '/snippets/add-env-tooltip.mdx'
+[Cohere](https://cohere.com) models can now be tracked with AgentOps. Explore the [Cohere API](https://docs.cohere.com) for more information.
+
<Note>
-This is a living integration. Should you need any added functionality, message us on [Discord](https://discord.gg/UgJyyxx7uc)!
+ Cohere's [LLM University](https://cohere.com/llmu) is a great resource for learning about LLMs with a lot of hands on examples.
</Note>
<Card title="Cohere" icon="hill-rockslide" href="https://www.loom.com/share/679d65cc06f148299e8dffc459d053ab">
@@ -15,6 +17,7 @@ This is a living integration. Should you need any added functionality, message u
![thumbnail](https://cdn.loom.com/sessions/thumbnails/679d65cc06f148299e8dffc459d053ab-with-play.gif)
</Card>
+# Steps to integrate Cohere with AgentOps
<Steps>
<Step title="Install the AgentOps SDK">
<CodeGroup>
@@ -41,7 +44,6 @@ This is a living integration. Should you need any added functionality, message u
</Step>
<Step title="Add 3 lines of code">
<CodeTooltip/>
- <span className="api-key-container">
<CodeGroup>
```python python
import agentops
@@ -52,19 +54,16 @@ This is a living integration. Should you need any added functionality, message u
agentops.end_session("Success") # Success|Fail|Indeterminate
```
</CodeGroup>
- </span>
<Warning>
Requires `cohere>=5.4.0`
</Warning>
<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! 🕵️
@@ -73,7 +72,7 @@ This is a living integration. Should you need any added functionality, message u
</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" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/link-to-session.gif?raw=true" />
</Frame>
</Step>
</Steps>
@@ -119,7 +118,6 @@ This is a living integration. Should you need any added functionality, message u
</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>
diff --git a/docs/v1/integrations/crewai.mdx b/docs/v1/integrations/crewai.mdx
index c13ca2c0..5ad33222 100644
--- a/docs/v1/integrations/crewai.mdx
+++ b/docs/v1/integrations/crewai.mdx
@@ -1,20 +1,18 @@
---
title: 'CrewAI'
-description: '[CrewAI](https://crewai.io) is a framework for easily building multi-agent applications.'
+description: 'AgentOps and CrewAI teamed up to make monitoring Crew agents dead simple.'
---
import CodeTooltip from '/snippets/add-code-tooltip.mdx'
import EnvTooltip from '/snippets/add-env-tooltip.mdx'
-AgentOps and CrewAI teamed up to make monitoring Crew agents dead simple. Crew and AgentOps have a first class partnership, adding agent observability to all Crew runs with 2 lines of code.
+[CrewAI](https://crewai.io) is a framework for easily building multi-agent applications. Crew has comprehensive [documentation](https://docs.crewai.com) available as well as a great [quickstart](https://docs.crewai.com/how-to/Creating-a-Crew-and-kick-it-off/) guide.
<Card title="Crew.ai + AgentOps" icon="ship" href="https://www.loom.com/share/cfcaaef8d4a14cc7a974843bda1076bf">
CrewAI multi-agent framework with AgentOps support
![thumbnail](https://cdn.loom.com/sessions/thumbnails/cfcaaef8d4a14cc7a974843bda1076bf-1713568618224-with-play.gif)
</Card>
-Crew has comprehensive [documentation](https://docs.crewai.com) available as well as a great [quickstart](https://docs.crewai.com/how-to/Creating-a-Crew-and-kick-it-off/) guide.
-
## Adding AgentOps to Crew agents
<Steps>
@@ -40,23 +38,19 @@ Crew has comprehensive [documentation](https://docs.crewai.com) available as wel
</Step>
<Step title="Add 2 lines of code">
<CodeTooltip/>
- <span className="api-key-container">
<CodeGroup>
```python python
import agentops
agentops.init(<INSERT YOUR API KEY HERE>)
```
</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 crew">
Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Crew! 🕵️
@@ -65,7 +59,7 @@ Crew has comprehensive [documentation](https://docs.crewai.com) available as wel
</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" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/link-to-session.gif?raw=true" />
</Frame>
</Step>
</Steps>
@@ -87,7 +81,6 @@ agentops.init(skip_auto_end_session=True)
</CardGroup>
<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>
diff --git a/docs/v1/integrations/groq.mdx b/docs/v1/integrations/groq.mdx
new file mode 100644
index 00000000..87b7747f
--- /dev/null
+++ b/docs/v1/integrations/groq.mdx
@@ -0,0 +1,130 @@
+---
+title: Groq
+description: "AgentOps provides first class support for Groq"
+---
+
+import CodeTooltip from '/snippets/add-code-tooltip.mdx'
+import EnvTooltip from '/snippets/add-env-tooltip.mdx'
+
+[Groq](https://groq.com) accelerates LLM inference with its ultra-fast Language Processing Unit (LPU) that powers Groq Cloud. Explore the [Groq docs](https://console.groq.com/docs/overview) to get started with their developer console.
+
+## Steps to Integrate Groq with AgentOps
+
+<Steps>
+ <Step title="Install the AgentOps SDK">
+ <CodeGroup>
+ ```bash pip
+ pip install agentops
+ ```
+ ```bash poetry
+ poetry add agentops
+ ```
+ </CodeGroup>
+ </Step>
+ <Step title="Install the Groq SDK">
+ <CodeGroup>
+ ```bash pip
+ pip install groq
+ ```
+ ```bash poetry
+ poetry add groq
+ ```
+ </CodeGroup>
+ </Step>
+ <Step title="Initialize AgentOps and develop with Groq">
+ <CodeTooltip/>
+ <CodeGroup>
+ ```python python
+ from groq import Groq
+ import agentops
+
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = Groq(api_key="your_api_key")
+
+ # Your code here...
+
+ agentops.end_session('Success')
+ ```
+ </CodeGroup>
+ <EnvTooltip />
+ <CodeGroup>
+ ```python .env
+ AGENTOPS_API_KEY=<YOUR API KEY>
+ GROQ_API_KEY=<YOUR OPENAI API KEY>
+ ```
+ </CodeGroup>
+ Read more about environment variables in [Advanced Configuration](/v1/usage/advanced-configuration)
+ </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/main/docs/images/external/groq/groq_session.png?raw=true" />
+ </Frame>
+ </Step>
+</Steps>
+
+## Full Examples
+
+<CodeGroup>
+
+```python sync
+from groq import Groq
+import agentops
+
+agentops.init(<INSERT YOUR API KEY HERE>)
+client = Groq(api_key="your_api_key")
+
+response = client.chat.completions.create(
+ messages=[
+ {
+ "role": "user",
+ "content": "Explain the importance of low latency LLMs",
+ }
+ ],
+ model="llama3-8b-8192",
+)
+
+print(response.choices[0].message.content)
+agentops.end_session('Success')
+```
+
+```python async
+from groq import AsyncGroq
+import agentops
+import asyncio
+
+async def main() -> None:
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = AsyncGroq(api_key="your_api_key")
+
+ response = await client.chat.completions.create(
+ messages=[
+ {
+ "role": "user",
+ "content": "Explain the importance of low latency LLMs",
+ }
+ ],
+ model="llama3-8b-8192",
+ )
+
+ print(response.choices[0].message.content)
+ agentops.end_session('Success')
+
+asyncio.run(main())
+```
+
+</CodeGroup>
+
+<Card title="Multi Agent Example" icon="bolt" href="https://github.com/AgentOps-AI/agentops/blob/main/examples/multi_agent_groq_example.ipynb">
+ This notebook demonstrates how to use AgentOps with a multi-agent system using Groq.
+</Card>
+
+<script type="module" src="/scripts/github_stars.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>
diff --git a/docs/v1/integrations/langchain.mdx b/docs/v1/integrations/langchain.mdx
index 20813f96..ae24566e 100644
--- a/docs/v1/integrations/langchain.mdx
+++ b/docs/v1/integrations/langchain.mdx
@@ -39,7 +39,6 @@ AgentOps works seamlessly with applications built using LangChain.
Note that you don't need to set up a separate agentops.init() call, as the LangChain callback handler will automatically initialize the AgentOps client for you.
</Tip>
Set up your LangChain agent with the AgentOps callback handler, and AgentOps will automatically record your LangChain sessions.
- <span className="api-key-container">
<CodeGroup>
```python python
handler = LangchainCallbackHandler(api_key=AGENTOPS_API_KEY, tags=['LangChain Example'])
@@ -58,32 +57,29 @@ AgentOps works seamlessly with applications built using LangChain.
handle_parsing_errors=True)
```
</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>
+ <CodeGroup>
+ ```python .env
+ AGENTOPS_API_KEY=<YOUR API KEY>
+ ```
+ </CodeGroup>
+ Read more about environment variables in [Advanced Configuration](/v1/usage/advanced-configuration)
</Step>
<Step title="Run your agent">
- Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your LangChain Agent! 🕵️
- <Tip>
- After your run, AgentOps prints a clickable URL to the 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>
+ Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your LangChain Agent! 🕵️
+ <Tip>
+ After your run, AgentOps prints a clickable URL to the 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/main/docs/images/link-to-session.gif?raw=true" />
+ </Frame>
+ </Step>
</Steps>
## Full Examples
-<CodeGroup className="adjust-api-key">
+<CodeGroup>
```python python
import os
from langchain.chat_models import ChatOpenAI
@@ -106,7 +102,6 @@ AgentOps works seamlessly with applications built using LangChain.
</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>
diff --git a/docs/v1/integrations/litellm.mdx b/docs/v1/integrations/litellm.mdx
index ed851b84..8103b710 100644
--- a/docs/v1/integrations/litellm.mdx
+++ b/docs/v1/integrations/litellm.mdx
@@ -4,42 +4,82 @@ description: "Call the latest models using the OpenAI format including:
Llama, Mistral, Claude, Gemini, Gemma, DALL-E, Whisper"
---
-## LiteLLM
+import EnvTooltip from '/snippets/add-env-tooltip.mdx'
-From [LiteLLM's docs](https://docs.litellm.ai/docs/):
+[LiteLLM](https://www.litellm.ai) allows tracking 100+ LLMs with AgentOps. Checkout the [providers](https://docs.litellm.ai/docs/providers) supported by LiteLLM.
+Visit the [LiteLLM docs](https://docs.litellm.ai/docs/) for more information.
-Call 400+ LLMs using the same input/output Format
-
-- Translate inputs to provider's `completion`, `embedding`, and `image_generation` endpoints
-- Consistent output. Text responses will always be available at `['choices'][0]['message']['content']`.
-- Retry/fallback logic across multiple deployments (e.g. Azure/OpenAI)
-- Track spend & set budgets per project
+## Using AgentOps with LiteLLM
-LiteLLM also supports many [providers](https://docs.litellm.ai/docs/providers).
+<Steps>
+ <Step title="Install the AgentOps SDK">
+ <CodeGroup>
+ ```bash pip
+ pip install agentops
+ ```
+ ```bash poetry
+ poetry add agentops
+ ```
+ </CodeGroup>
+ </Step>
+ <Step title="Install LiteLLM">
+ <Note>
+ AgentOps supports `litellm>=1.3.1`
+ </Note>
+ <CodeGroup>
+ ```bash pip
+ pip install litellm
+ ```
+ ```bash poetry
+ poetry add litellm
+ ```
+ </CodeGroup>
+ </Step>
+ <Step title="Initialize AgentOps and use LiteLLM in your code">
+ <Warning>
+ AgentOps requires a minor adjustment to how you call LiteLLM. This is because of other existing integrations that use the `completion` function.
+ </Warning>
+ <CodeGroup>
+ ```python python
+ import agentops
+ import litellm
-## Using AgentOps with LiteLLM
+ agentops.init(<INSERT YOUR API KEY HERE>)
-### Requires `litellm>=1.3.1`
+ # Some code here...
-AgentOps requires a minor adjustment to how you call LiteLLM.
+ response = litellm.completion(model="gpt-4o", messages=messages)
+
+ # Some code here...
-```python python
-# Do not use LiteLLM like this
-# from litellm import completion
-# ...
-# response = completion(model="claude-3", messages=messages)
+ agentops.end_session('Success')
+ ```
+ </CodeGroup>
+ <EnvTooltip />
+ <CodeGroup>
+ ```python .env
+ AGENTOPS_API_KEY=<YOUR API KEY>
+ ```
+ </CodeGroup>
+ Read more about environment variables in [Advanced Configuration](/v1/usage/advanced-configuration)
+ </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>
-# Use LiteLLM like this
-import litellm
-...
-response = litellm.completion(model="claude-3", messages=messages)
-# or
-response = await litellm.acompletion(model="claude-3", messages=messages)
+## Full Examples
-```
+An example notebook is available [here](https://github.com/AgentOps-AI/agentops/blob/main/examples/litellm_examples/litellm_example.ipynb).
<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>
diff --git a/docs/v1/integrations/mistral.mdx b/docs/v1/integrations/mistral.mdx
new file mode 100644
index 00000000..490f340e
--- /dev/null
+++ b/docs/v1/integrations/mistral.mdx
@@ -0,0 +1,194 @@
+---
+title: Mistral
+description: "AgentOps provides first class support for Mistral AI's models"
+---
+
+import CodeTooltip from '/snippets/add-code-tooltip.mdx'
+import EnvTooltip from '/snippets/add-env-tooltip.mdx'
+
+[Mistral](https://mistral.ai) publishes open-weight AI models that can be used for a variety of tasks. To develop with Mistral, visit their developer docs [here](https://docs.mistral.ai).
+
+## Steps to Integrate Mistral with AgentOps
+
+<Steps>
+ <Step title="Install the AgentOps SDK">
+ <CodeGroup>
+ ```bash pip
+ pip install agentops
+ ```
+ ```bash poetry
+ poetry add agentops
+ ```
+ </CodeGroup>
+ </Step>
+ <Step title="Install the Mistral SDK">
+ <CodeGroup>
+ ```bash pip
+ pip install mistralai
+ ```
+ ```bash poetry
+ poetry add mistralai
+ ```
+ </CodeGroup>
+ </Step>
+ <Step title="Initialize AgentOps and develop with Mistral">
+ <CodeTooltip/>
+ <CodeGroup>
+ ```python python
+ from mistralai import Mistral
+ import agentops
+
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = Mistral(api_key="your_api_key")
+
+ # Your code here...
+
+ agentops.end_session('Success')
+ ```
+ </CodeGroup>
+ <EnvTooltip />
+ <CodeGroup>
+ ```python .env
+ AGENTOPS_API_KEY=<YOUR API KEY>
+ MISTRAL_API_KEY=<YOUR MISTRAL API KEY>
+ ```
+ </CodeGroup>
+ </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/main/docs/images/external/mistral/mistral_session.png?raw=true" />
+ </Frame>
+ </Step>
+</Steps>
+
+## Full Examples
+
+A notebook demonstrating how to use AgentOps with Mistral can be found [here](https://github.com/AgentOps-AI/agentops/blob/main/examples/mistral_examples/mistral_example.ipynb).
+
+<CodeGroup>
+
+```python sync
+from mistralai import Mistral
+import agentops
+
+agentops.init(<INSERT YOUR API KEY HERE>)
+client = Mistral(api_key="your_api_key")
+
+response = client.chat.complete(
+ model="mistral-small-latest",
+ messages=[
+ {
+ "role": "user",
+ "content": "Explain the history of the French Revolution."
+ }
+ ],
+)
+
+print(response.choices[0].message.content)
+agentops.end_session('Success')
+```
+
+```python async
+import asyncio
+from mistralai import Mistral
+import agentops
+
+async def main():
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = Mistral(api_key="your_api_key")
+
+ response = await client.chat.complete_async(
+ model="mistral-small-latest",
+ messages=[
+ {
+ "role": "user",
+ "content": "Write a short summary about the poem La Belle Dame sans Merci.",
+ },
+ ],
+ )
+
+ print(response.choices[0].message.content)
+ agentops.end_session('Success')
+
+asyncio.run(main())
+```
+
+</CodeGroup>
+
+### Streaming Examples
+
+<CodeGroup>
+
+```python sync
+from mistralai import Mistral
+import agentops
+
+agentops.init(<INSERT YOUR API KEY HERE>)
+client = Mistral(api_key="your_api_key")
+
+complete_response = ""
+
+response = client.chat.stream(
+ model="mistral-small-latest",
+ messages=[
+ {
+ "role": "user",
+ "content": "Who was Joan of Arc?"
+ }
+ ],
+)
+
+for chunk in response:
+ if chunk.data.choices[0].finish_reason == "stop":
+ print(complete_response)
+ else:
+ complete_response += chunk.data.choices[0].delta.content
+
+agentops.end_session('Success')
+```
+
+```python async
+import asyncio
+from mistralai import Mistral
+import agentops
+
+async def main():
+ agentops.init(<INSERT YOUR API KEY HERE>)
+ client = Mistral(api_key="your_api_key")
+
+ complete_response = ""
+
+ response = await client.chat.stream_async(
+ model="mistral-small-latest",
+ messages=[
+ {
+ "role": "user",
+ "content": "Write a short summary about the poem La Belle Dame sans Merci.",
+ },
+ ],
+ )
+
+ async for chunk in response:
+ if chunk.data.choices[0].finish_reason == "stop":
+ print(complete_response)
+ else:
+ complete_response += chunk.data.choices[0].delta.content
+
+ agentops.end_session('Success')
+
+asyncio.run(main())
+```
+
+</CodeGroup>
+
+
+<script type="module" src="/scripts/github_stars.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>
diff --git a/docs/v1/integrations/multion.mdx b/docs/v1/integrations/multion.mdx
index 5a3646cb..8c66c567 100644
--- a/docs/v1/integrations/multion.mdx
+++ b/docs/v1/integrations/multion.mdx
@@ -1,18 +1,12 @@
---
title: MultiOn
-description: "AgentOps provides first class support for MultiOn agents"
+description: "AgentOps and MultiOn have collaborated to simplify the monitoring of autonomous browser agents."
---
import CodeTooltip from '/snippets/add-code-tooltip.mdx'
import EnvTooltip from '/snippets/add-env-tooltip.mdx'
-AgentOps and [MultiOn](https://www.multion.ai) have collaborated to simplify the monitoring of autonomous browser agents.
-
-You can view several example notebooks [here](https://github.com/AgentOps-AI/agentops/tree/main/examples/multion):
-* [Sample web browser agent using only MultiOn](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Autonomous_web_browsing.ipynb)
-* [Combining a MultiOn agent with other LLMs calls](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Autonomous_web_browsing.ipynb)
-* [Step-by-step tracking of browse events](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Step_by_step_web_browsing.ipynb)
-* [Collecting data from a web page using the retrieve API](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Webpage_data_retrieval.ipynb)
+[MultiOn](https://www.multion.ai) is a platform for building autonomous agents.
## Adding AgentOps to MultiOn agents
@@ -33,7 +27,6 @@ You can view several example notebooks [here](https://github.com/AgentOps-AI/age
</Step>
<Step title="Create a MultiOn client with an AgentOps key">
<CodeTooltip/>
- <span className="api-key-container">
<CodeGroup>
```python python
import multion
@@ -54,9 +47,7 @@ You can view several example notebooks [here](https://github.com/AgentOps-AI/age
print(browse_response.message)
```
- </CodeGroup>
- </span>
-
+ </CodeGroup>
<EnvTooltip />
</Step>
<Step title="Run your agent">
@@ -71,8 +62,15 @@ You can view several example notebooks [here](https://github.com/AgentOps-AI/age
</Step>
</Steps>
+## Full Examples
+
+You can view several example notebooks [here](https://github.com/AgentOps-AI/agentops/tree/main/examples/multion):
+* [Sample web browser agent using only MultiOn](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Autonomous_web_browsing.ipynb)
+* [Combining a MultiOn agent with other LLMs calls](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Autonomous_web_browsing.ipynb)
+* [Step-by-step tracking of browse events](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Step_by_step_web_browsing.ipynb)
+* [Collecting data from a web page using the retrieve API](https://github.com/AgentOps-AI/agentops/blob/main/examples/multion/Webpage_data_retrieval.ipynb)
+
<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>
diff --git a/docs/v1/integrations/ollama.mdx b/docs/v1/integrations/ollama.mdx
index 04d84932..54fa7f19 100644
--- a/docs/v1/integrations/ollama.mdx
+++ b/docs/v1/integrations/ollama.mdx
@@ -6,13 +6,7 @@ description: "AgentOps provides first class support for Ollama"
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="Ollama" icon={<img src="https://www.github.com/agentops-ai/agentops/blob/main/docs/images/external/ollama/ollama-icon.png?raw=true" alt="Ollama" />} iconType="image" href="https://ollama.com">
- First class support for Ollama
-</Card>
+[Ollama](https://ollama.com) is a lightweight, open-source tool for running and managing LLM models. Track your Ollama model calls with AgentOps.
<Steps>
<Step title="Install the AgentOps SDK">
@@ -56,7 +50,7 @@ This is a living integration. Should you need any added functionality, message u
print(response['message']['content'])
...
# End of program (e.g. main.py)
- agentops.end_session("Success") # Success|Fail|Indeterminate
+ agentops.end_session("Success")
```
</CodeGroup>
<EnvTooltip />
diff --git a/docs/v1/integrations/openai.mdx b/docs/v1/integrations/openai.mdx
index 0ac716e6..8fa2760b 100644
--- a/docs/v1/integrations/openai.mdx
+++ b/docs/v1/integrations/openai.mdx
@@ -6,10 +6,6 @@ description: "AgentOps provides first class support for OpenAI's GPT family of m
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>
@@ -50,7 +46,6 @@ This is a living integration. Should you need any added functionality, message u
</Step>
<Step title="Add 3 lines of code">
<CodeTooltip/>
- <span className="api-key-container">
<CodeGroup>
```python python
import agentops
@@ -60,12 +55,10 @@ This is a living integration. Should you need any added functionality, message u
client = OpenAI()
...
# End of program (e.g. main.py)
- agentops.end_session("Success") # Success|Fail|Indeterminate
+ agentops.end_session("Success")
```
</CodeGroup>
- </span>
<EnvTooltip />
- <span className="api-key-container">
<CodeGroup>
```python .env
AGENTOPS_API_KEY=<YOUR API KEY>
@@ -73,7 +66,6 @@ This is a living integration. Should you need any added functionality, message u
```
</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! 🕵️
@@ -188,7 +180,6 @@ This is a living integration. Should you need any added functionality, message u
</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>
diff --git a/docs/v1/introduction.mdx b/docs/v1/introduction.mdx
index fbc7811e..3c3d2c72 100644
--- a/docs/v1/introduction.mdx
+++ b/docs/v1/introduction.mdx
@@ -44,12 +44,12 @@ You also get helpful debugging info such as any SDK versions you were on if you'
LLM calls are presented as a familiar chat history view, and charts give you a breakdown of the types of events that were called and how long they took.
<Frame type="glass" caption="Session Summary">
- <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/session-summary.gif?raw=true" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/session-summary.gif?raw=true" />
</Frame>
Find any past sessions from your Session Drawer.
<Frame type="glass" caption="Session Drawer">
- <img height="250" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/session-drawer.gif?raw=true" />
+ <img height="250" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/session-drawer.gif?raw=true" />
</Frame>
Most powerful of all is the Session Waterfall. On the left, a time visualization of all your LLM calls, Action events, Tool calls, and Errors.
@@ -57,14 +57,14 @@ On the right, specific details about the event you've selected on the waterfall.
Most of which has been automatically recorded for you.
<Frame type="glass" caption="Session Waterfall">
- <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/session-waterfall.gif?raw=true" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/session-waterfall.gif?raw=true" />
</Frame>
### Session Overview
View a meta-analysis of all of your sessions in a single view.
<Frame type="glass" caption="Session Overview">
- <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/overview.png?raw=true" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/overview.png?raw=true" />
</Frame>
<script type="module" src="/scripts/github_stars.js"></script>
diff --git a/docs/v1/quickstart.mdx b/docs/v1/quickstart.mdx
index e9120b58..de62171d 100644
--- a/docs/v1/quickstart.mdx
+++ b/docs/v1/quickstart.mdx
@@ -18,7 +18,6 @@ import EnvTooltip from '/snippets/add-env-tooltip.mdx'
</Step>
<Step title="Add 2 lines of code">
<CodeTooltip />
- <span className="api-key-container">
Get an AgentOps API key [here](https://app.agentops.ai/settings/projects)
<CodeGroup>
```python python
@@ -26,7 +25,6 @@ import EnvTooltip from '/snippets/add-env-tooltip.mdx'
agentops.init(<INSERT YOUR API KEY HERE>)
```
</CodeGroup>
- </span>
<EnvTooltip />
</Step>
<Step title="Run your agent">
@@ -36,7 +34,7 @@ import EnvTooltip from '/snippets/add-env-tooltip.mdx'
<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" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/link-to-session.gif?raw=true" />
</Frame>
</Step>
</Steps>
@@ -135,7 +133,6 @@ agentops.end_session('Success')
</CardGroup>
<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>
diff --git a/docs/v1/usage/advanced-configuration.mdx b/docs/v1/usage/advanced-configuration.mdx
index bcab8ebc..4b3d9010 100644
--- a/docs/v1/usage/advanced-configuration.mdx
+++ b/docs/v1/usage/advanced-configuration.mdx
@@ -5,13 +5,11 @@ mode: "wide"
In AgentOps fashion, you only need to add one line of "code" to your `.env` file 😊
-<span className="api-key-container">
- <CodeGroup>
- ```python .env
- AGENTOPS_API_KEY=<YOUR API KEY>
- ```
- </CodeGroup>
-</span>
+<CodeGroup>
+ ```python .env
+ AGENTOPS_API_KEY=<YOUR API KEY>
+ ```
+</CodeGroup>
<Tip>
Find your AgentOps API Key in your Settings > [Projects & API Keys](https://app.agentops.ai/settings/projects) page.
@@ -33,7 +31,6 @@ AGENTOPS_ENV_DATA_OPT_OUT=FALSE
```
<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="module" src="/scripts/adjust_api_dynamically.js"></script>
diff --git a/docs/v1/usage/dashboard-info.mdx b/docs/v1/usage/dashboard-info.mdx
index 57001693..b45dbd8b 100644
--- a/docs/v1/usage/dashboard-info.mdx
+++ b/docs/v1/usage/dashboard-info.mdx
@@ -14,12 +14,12 @@ You also get helpful debugging info such as any SDK versions you were on if you'
LLM calls are presented as a familiar chat history view, and charts give you a breakdown of the types of events that were called and how long they took.
<Frame type="glass" caption="Session Summary">
- <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/session-summary.gif?raw=true" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/session-summary.gif?raw=true" />
</Frame>
Find any past sessions from your Session Drawer.
<Frame type="glass" caption="Session Drawer">
- <img height="250" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/session-drawer.gif?raw=true" />
+ <img height="250" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/session-drawer.gif?raw=true" />
</Frame>
Most powerful of all is the Session Waterfall. On the left, a time visualization of all your LLM calls, Action events, Tool calls, and Errors.
@@ -27,18 +27,17 @@ On the right, specific details about the event you've selected on the waterfall.
Most of which has been automatically recorded for you.
<Frame type="glass" caption="Session Waterfall">
- <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/session-waterfall.gif?raw=true" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/session-waterfall.gif?raw=true" />
</Frame>
### Session Overview
View a meta-analysis of all of your sessions in a single view.
<Frame type="glass" caption="Session Overview">
- <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/cf67191f13e0e2a09446a61b7393e1810b3eee95/docs/images/overview.png?raw=true" />
+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/overview.png?raw=true" />
</Frame>
<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/intro.css"></script>
\ No newline at end of file
diff --git a/docs/v1/usage/langchain-callback-handler.mdx b/docs/v1/usage/langchain-callback-handler.mdx
index 8337a287..98e12779 100644
--- a/docs/v1/usage/langchain-callback-handler.mdx
+++ b/docs/v1/usage/langchain-callback-handler.mdx
@@ -68,7 +68,6 @@ If your project uses LangChain for Agents, Events and Tools, it may be easier to
If your project uses models with LangChain that are not yet supported by AgentOps, they can be supported by the Handler.
<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="module" src="/scripts/adjust_api_dynamically.js"></script>
diff --git a/docs/v1/usage/recording-events.mdx b/docs/v1/usage/recording-events.mdx
index a80d4d2d..99e365e2 100644
--- a/docs/v1/usage/recording-events.mdx
+++ b/docs/v1/usage/recording-events.mdx
@@ -52,7 +52,6 @@ record(ActionEvent("event_type1"))
```
<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="module" src="/scripts/adjust_api_dynamically.js"></script>
diff --git a/docs/v1/usage/sdk-reference.mdx b/docs/v1/usage/sdk-reference.mdx
index 876aee69..62b11c9f 100644
--- a/docs/v1/usage/sdk-reference.mdx
+++ b/docs/v1/usage/sdk-reference.mdx
@@ -154,7 +154,6 @@ This callback handler is intended to be used as an option in place of AgentOps a
when using LangChain as your LLM calling library.
<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="module" src="/scripts/adjust_api_dynamically.js"></script>
diff --git a/docs/v1/usage/tracking-agents.mdx b/docs/v1/usage/tracking-agents.mdx
index a261951d..12557201 100644
--- a/docs/v1/usage/tracking-agents.mdx
+++ b/docs/v1/usage/tracking-agents.mdx
@@ -52,6 +52,5 @@ In this example, we create a custom agent class. We initialize an agent object a
<script type="module" src="/scripts/github_stars.js"></script>
<script type="module" src="/scripts/adjust_api_dynamically.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>
\ No newline at end of file
diff --git a/docs/v1/usage/tracking-llm-calls.mdx b/docs/v1/usage/tracking-llm-calls.mdx
index b448fd18..0ab4d03d 100644
--- a/docs/v1/usage/tracking-llm-calls.mdx
+++ b/docs/v1/usage/tracking-llm-calls.mdx
@@ -37,7 +37,6 @@ This function reverts the changes made to your LLM provider's module, removing A
_Special consideration for Cohere: Calling `stop_instrumenting()` has no effect on previously instantiated Cohere clients. You must create a new Cohere client after calling this function._
<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="module" src="/scripts/adjust_api_dynamically.js"></script>
diff --git a/examples/anthropic_examples/anthropicguide.md b/examples/anthropic_examples/README.md
similarity index 90%
rename from examples/anthropic_examples/anthropicguide.md
rename to examples/anthropic_examples/README.md
index ddc6ac58..ffeb9c82 100644
--- a/examples/anthropic_examples/anthropicguide.md
+++ b/examples/anthropic_examples/README.md
@@ -88,13 +88,3 @@ In this example, we look at the tool system through a deeper dive; we will use o
-## Looking for a Barebones, Straight To The Point Journal?
-
-This journal directly shows the bare basics on using Anthropic and AgentOps!
-
-> [!WARNING]
-> This is mainly recommended for those adept at programming or those who already understand how AgentOps and LLM APIs generally work!
-
-[Access the Journal By Clicking Here](./anthropic_example.ipynb)
-
-
diff --git a/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb
index 17bea5de..4f80d321 100644
--- a/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb
+++ b/examples/anthropic_examples/agentops-anthropic-understanding-tools.ipynb
@@ -1,1030 +1,1022 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Anthropic's tool returns are not as simple as getting a few strings! While this system is more complex than those before it, it's also simple enough to be used without problem once you understand how it works! "
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "To get started, we will import Agentops and Anthropic"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "!pip install agentops\n",
- "!pip install anthropic"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Setup our generic default statements"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [],
- "source": [
- "from anthropic import Anthropic, AsyncAnthropic\n",
- "import agentops\n",
- "import os\n",
- "import random # We don't need this for agentops, we use this to generate a message later\n",
- "import time # We don't need this for agentops either, we use this when simulating an API later\n",
- "import re # Regex for formatting\n",
- "from dotenv import load_dotenv"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "And set our API keys."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [],
- "source": [
- "load_dotenv()\n",
- "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\n",
- "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\""
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "\n",
- "Now let's set the client as Anthropic and make an AgentOps session"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=df6426c5-1995-4bec-b90e-680369a0cddb\u001b[0m\u001b[0m\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "<agentops.session.Session at 0x10e6ca710>"
- ]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool-tutorials\"])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [],
- "source": [
- "client = Anthropic(api_key=ANTHROPIC_API_KEY)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now to create a simple dummy tool! We are going to make a tool that will tell us about the demon infestation levels for 3 areas. From there, we will have VEGA, our AI determine the best place for the Doom Slayer to attack."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [],
- "source": [
- "locations = [\n",
- " {\n",
- " \"Name\": \"Super Gore Nest\",\n",
- " \"Description\": \"A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Exultia\",\n",
- " \"Description\": \"An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Cultist Base\",\n",
- " \"Description\": \"A grim fortress hidden within the icy mountains, where a fanatical cult worships demons. Filled with chilling sacrificial chambers, traps, and rituals, the Cultist Base is a hostile stronghold where Doom Slayer must confront the cult leaders aiding Hell's invasion of Earth.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Taras Nabad\",\n",
- " \"Description\": \"A war-ravaged city on the homeworld of the Night Sentinels, showcasing grandiose, ancient architecture in the midst of destruction. Taras Nabad's sprawling structures and historical significance reveal glimpses into the Doom Slayer’s past and the once-thriving Sentinel civilization.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Nekravol\",\n",
- " \"Description\": \"A hellish, industrial fortress where souls are processed into Argent energy. With conveyor belts moving the damned and a skyline dominated by fire and darkness, Nekravol is a nightmarish facility that powers Hell's armies and embodies the horrific machinery of Hell's cruelty.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Urdak\",\n",
- " \"Description\": \"A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"UAC Base\",\n",
- " \"Description\": \"A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions.\",\n",
- " },\n",
- "]\n",
- "\n",
- "combat_casualties = [\"Nonexistent\", \"Low\", \"Medium\", \"High\", \"Extinction\"]\n",
- "\n",
- "missions = [\n",
- " \"Locate and confront a key leader of Hell’s invasion forces.\",\n",
- " \"Clear out demonic infestations to secure a strategic foothold.\",\n",
- " \"Disrupt Hell's control over the area by eliminating critical targets.\",\n",
- " \"Enter a critical demonic stronghold to disrupt enemy operations.\",\n",
- " \"Locate and destroy the central power source to weaken enemy forces.\",\n",
- " \"Collect essential resources before the area becomes unstable.\",\n",
- "]"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now that that's done, we can make a function! We will generate three random missions and pass it off to the AI."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {},
- "outputs": [],
- "source": [
- "def generate_missions():\n",
- " selectedmissions = []\n",
- " loop = 0\n",
- "\n",
- " while loop < 3:\n",
- " location = random.choice(locations)\n",
- " casualties = random.choice(combat_casualties)\n",
- " mission = random.choice(missions)\n",
- " final = (\n",
- " f'LocationName: {location[\"Name\"]}, '\n",
- " f'LocationInfo: {location[\"Description\"]}, '\n",
- " f\"HumanCombatCasualties: {casualties}, \"\n",
- " f\"Mission: {mission}\"\n",
- " )\n",
- "\n",
- " selectedmissions.append(final)\n",
- " loop += 1\n",
- "\n",
- " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n",
- " missions_string = \"\\n\".join(\n",
- " missions\n",
- " ) # Or \", \".join(missions) for a comma-separated string\n",
- " print(missions_string)\n",
- " return missions_string"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Locate and confront a key leader of Hell’s invasion forces.\n",
- "Clear out demonic infestations to secure a strategic foothold.\n",
- "Disrupt Hell's control over the area by eliminating critical targets.\n",
- "Enter a critical demonic stronghold to disrupt enemy operations.\n",
- "Locate and destroy the central power source to weaken enemy forces.\n",
- "Collect essential resources before the area becomes unstable.\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "\"Locate and confront a key leader of Hell’s invasion forces.\\nClear out demonic infestations to secure a strategic foothold.\\nDisrupt Hell's control over the area by eliminating critical targets.\\nEnter a critical demonic stronghold to disrupt enemy operations.\\nLocate and destroy the central power source to weaken enemy forces.\\nCollect essential resources before the area becomes unstable.\""
- ]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "generate_missions()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it (and it's generally good practice)!\n",
- "\n",
- "We are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now we make a message! This time around we will skip making an intial message that has too much context, unlike in the past!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {},
- "outputs": [],
- "source": [
- "# We make our history a separate block to be easier to add to later on! This is essentially our history\n",
- "initial_messages = [\n",
- " {\n",
- " \"role\": \"user\",\n",
- " \"content\": \"You are VEGA, the assistant to the DOOMGUY. Get three missions from the ship's API and tell me which mission is most to least important for quellng the forces of hell. \",\n",
- " }\n",
- "]"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now to construct a request!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01HAJR2iiPBGr9A473tZyewV', input={}, name='generate_missions', type='tool_use')]\n"
- ]
- }
- ],
- "source": [
- "response = client.messages.create(\n",
- " max_tokens=5000,\n",
- " model=\"claude-3-5-sonnet-20240620\",\n",
- " tools=[\n",
- " {\n",
- " \"name\": \"generate_missions\",\n",
- " \"description\": \"Retrieve three missions for the DoomSlayer\",\n",
- " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
- " }\n",
- " ],\n",
- " messages=initial_messages,\n",
- ")\n",
- "\n",
- "print(response.content)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Having trouble understanding this? The first block given is always Ai dialouge! You can use response.content[0].text to get the AI's text! Let's try it below."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\n",
- "\n",
- "Let's begin by retrieving the missions:\n"
- ]
- }
- ],
- "source": [
- "message = response.content[0].text\n",
- "print(message)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "The code below finds the tool used!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01HAJR2iiPBGr9A473tZyewV', input={}, name='generate_missions', type='tool_use')]\n",
- "Locate and confront a key leader of Hell’s invasion forces.\n",
- "Clear out demonic infestations to secure a strategic foothold.\n",
- "Disrupt Hell's control over the area by eliminating critical targets.\n",
- "Enter a critical demonic stronghold to disrupt enemy operations.\n",
- "Locate and destroy the central power source to weaken enemy forces.\n",
- "Collect essential resources before the area becomes unstable.\n"
- ]
- }
- ],
- "source": [
- "gen_mission_result = \"\"\n",
- "\n",
- "# Print response content to see the data\n",
- "print(response.content)\n",
- "\n",
- "# Assuming ToolUseBlock is at index 1\n",
- "tool_use_block = response.content[1]\n",
- "\n",
- "# Get the tool name and input\n",
- "tool_name = tool_use_block.name\n",
- "tool_input = tool_use_block.input\n",
- "\n",
- "# We don't need to look to extract any inputs since we don't use any\n",
- "\n",
- "# Check if the tool name is \"generate_missions\"\n",
- "if tool_name == \"generate_missions\":\n",
- " # Call the function with the tool creator as an argument\n",
- " gen_mission_result = generate_missions()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now we add these as context to the LLM through intial messages!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {},
- "outputs": [],
- "source": [
- "initial_messages.append({\"role\": \"assistant\", \"content\": gen_mission_result})\n",
- "\n",
- "initial_messages.append(\n",
- " {\n",
- " \"role\": \"user\",\n",
- " \"content\": \"Based on these, which location should take priority and why?\",\n",
- " }\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "And now to get a response!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Message(id='msg_016Hd62W2sJNyd762Yp1udLd', content=[TextBlock(text=\"I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly retrieving the missions using the available function. \", type='text'), ToolUseBlock(id='toolu_01TUaMJbZc7VHMVZKaA9RqvL', input={}, name='generate_missions', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=497, output_tokens=83))\n"
- ]
- }
- ],
- "source": [
- "response = client.messages.create(\n",
- " max_tokens=5000,\n",
- " model=\"claude-3-5-sonnet-20240620\",\n",
- " tools=[\n",
- " {\n",
- " \"name\": \"generate_missions\",\n",
- " \"description\": \"Retrieve three missions for the DoomSlayer\",\n",
- " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
- " }\n",
- " ],\n",
- " messages=initial_messages,\n",
- ")\n",
- "\n",
- "print(response)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Isolate again!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly retrieving the missions using the available function. \n"
- ]
- }
- ],
- "source": [
- "message = response.content[0].text\n",
- "print(message)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Hmmm, what if we wanted to include more tools and add inputs? Let's create two new functions to display this!\n",
- "\n",
- "One will show the kind of demon we are facing, whereas another one will take our weapon input to determine what the best weapon chain to use is (You heard that right, we believe in quick weapon switches around these parts)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "metadata": {},
- "outputs": [],
- "source": [
- "demons = [\n",
- " {\n",
- " \"Name\": \"Imp\",\n",
- " \"Description\": \"A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Cacodemon\",\n",
- " \"Description\": \"A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Hell Knight\",\n",
- " \"Description\": \"A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Mancubus\",\n",
- " \"Description\": \"A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\",\n",
- " },\n",
- "]\n",
- "\n",
- "\n",
- "weapons = [\n",
- " {\n",
- " \"Name\": \"Super Shotgun\",\n",
- " \"Description\": \"A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Rocket Launcher\",\n",
- " \"Description\": \"A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Chaingun\",\n",
- " \"Description\": \"A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"BFG 9000\",\n",
- " \"Description\": \"One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\",\n",
- " },\n",
- " {\n",
- " \"Name\": \"Ice Bomb\",\n",
- " \"Description\": \"A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\",\n",
- " },\n",
- "]"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now we can keep the initialmessages from before actually! However let's change the context"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "metadata": {},
- "outputs": [],
- "source": [
- "initial_messages.append(\n",
- " {\n",
- " \"role\": \"user\",\n",
- " \"content\": \"The first priority mission was selected. At the same time, scan for enemies and check inventory to determine the best combat strategy. You should use both tools at once.\",\n",
- " }\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "And we of course make functions"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "metadata": {},
- "outputs": [],
- "source": [
- "def enemyscan(amount):\n",
- " enemiesonscene = []\n",
- " loop = 0\n",
- "\n",
- " while loop < amount + 1:\n",
- " scannedenemy = random.choice(demons)\n",
- "\n",
- " # Append just the name of the demon to the list\n",
- " enemiesonscene.append(scannedenemy[\"Name\"])\n",
- " enemiesonscene.append(scannedenemy[\"Description\"])\n",
- " loop += 1\n",
- "\n",
- " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n",
- " enemies_string = \"\\n\".join(enemiesonscene)\n",
- " print(enemies_string)\n",
- " return enemies_string"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 19,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Imp\n",
- "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
- "Cacodemon\n",
- "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n",
- "Imp\n",
- "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
- "Imp\n",
- "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
- "Cacodemon\n",
- "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n",
- "Hell Knight\n",
- "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "'Imp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nHell Knight\\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.'"
- ]
- },
- "execution_count": 19,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "enemyscan(5)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "And now inventory"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 20,
- "metadata": {},
- "outputs": [],
- "source": [
- "def inventoryscan():\n",
- " weapons_at_hand = []\n",
- " loop = 0\n",
- "\n",
- " while loop < 5:\n",
- " weapon = random.choice(weapons)\n",
- "\n",
- " # Append just the name of the demon to the list\n",
- " weapons_at_hand.append(weapon[\"Name\"])\n",
- " weapons_at_hand.append(weapon[\"Description\"])\n",
- " loop += 1\n",
- "\n",
- " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n",
- " weapons_string = \"\\n\".join(weapons_at_hand)\n",
- " print(weapons_string)\n",
- " return weapons_string"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 21,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "BFG 9000\n",
- "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
- "Chaingun\n",
- "A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\n",
- "BFG 9000\n",
- "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
- "Rocket Launcher\n",
- "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n",
- "Rocket Launcher\n",
- "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "'BFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nChaingun\\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\\nBFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nRocket Launcher\\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\\nRocket Launcher\\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.'"
- ]
- },
- "execution_count": 21,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "inventoryscan()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "With that, let's construct our new tools and run this!!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 22,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Message(id='msg_0119o5gGDi7TRTsNPzNXd2ov', content=[TextBlock(text=\"Certainly! I'll prioritize the missions and use both tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\", type='text'), ToolUseBlock(id='toolu_01MmqMojDYtt5qdWnsXMJoWL', input={'amount': 5}, name='enemyscan_tool', type='tool_use'), ToolUseBlock(id='toolu_01WxN7tUMTFTai1WdiFc94HW', input={}, name='inventoryscan_tool', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=610, output_tokens=110))\n"
- ]
- }
- ],
- "source": [
- "response = client.messages.create(\n",
- " max_tokens=5000,\n",
- " model=\"claude-3-5-sonnet-20240620\",\n",
- " tools=[\n",
- " {\n",
- " \"name\": \"enemyscan_tool\",\n",
- " \"description\": \"Retrieve a list of demons currently present in the area.\",\n",
- " \"input_schema\": {\n",
- " \"type\": \"object\",\n",
- " \"properties\": {\n",
- " \"amount\": {\n",
- " \"type\": \"integer\",\n",
- " \"description\": \"Number of enemies to scan.\",\n",
- " }\n",
- " },\n",
- " \"required\": [\"amount\"],\n",
- " },\n",
- " },\n",
- " {\n",
- " \"name\": \"inventoryscan_tool\",\n",
- " \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n",
- " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
- " },\n",
- " ],\n",
- " messages=initial_messages,\n",
- ")\n",
- "\n",
- "print(response)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Display just the text"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 23,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Certainly! I'll prioritize the missions and use both tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\n"
- ]
- }
- ],
- "source": [
- "message = response.content[0].text\n",
- "print(message)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 24,
- "metadata": {},
- "outputs": [],
- "source": [
- "initial_messages.append({\"role\": \"assistant\", \"content\": f\"{str(response)}\"})"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "And now to get the information and put it all together! PLEASE read the comments!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 25,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Hell Knight\n",
- "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
- "Imp\n",
- "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
- "Hell Knight\n",
- "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
- "Mancubus\n",
- "A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n",
- "Hell Knight\n",
- "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
- "Cacodemon\n",
- "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n",
- "Rocket Launcher\n",
- "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n",
- "BFG 9000\n",
- "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
- "BFG 9000\n",
- "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
- "Super Shotgun\n",
- "A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n",
- "Ice Bomb\n",
- "A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n",
- "Rocket Launcher\n",
- "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n",
- "BFG 9000\n",
- "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
- "BFG 9000\n",
- "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
- "Super Shotgun\n",
- "A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n",
- "Ice Bomb\n",
- "A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n",
- "Hell Knight\n",
- "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
- "Imp\n",
- "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
- "Hell Knight\n",
- "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
- "Mancubus\n",
- "A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n",
- "Hell Knight\n",
- "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
- "Cacodemon\n",
- "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n"
- ]
- }
- ],
- "source": [
- "inv_scan_res = \"\"\n",
- "enemy_scan_res = \"\"\n",
- "\n",
- "\n",
- "response_str = str(response)\n",
- "tool_use_count = response_str.count(\n",
- " \"ToolUseBlock\"\n",
- ") # We know the ToolUseBlock will appear once for each tool request so we check how many time it appears\n",
- "\n",
- "\n",
- "# You can use print(tool_use_count)to validate the ToolBlocks here if you wish\n",
- "\n",
- "loop = 0\n",
- "\n",
- "# We do this instead of a (foreach) because we need to skip the first block! This contains the message from the AI, not the tool! This way allows us to reference the item we want as easily as possible without complex logic needed!\n",
- "\n",
- "while loop < tool_use_count: # We will get the tools now\n",
- " tool_use_block = response.content[\n",
- " loop + 1\n",
- " ] # We start at 1 since 0 holds the AI mesage\n",
- " tool_name = tool_use_block.name\n",
- " tool_input = tool_use_block.input\n",
- "\n",
- " if tool_name == \"inventoryscan_tool\":\n",
- " # Call the inventoryscan function for inventoryscan_tool\n",
- " inv_scan_res = inventoryscan()\n",
- " elif tool_name == \"enemyscan_tool\":\n",
- " # Get the amount for enemyscan_tool\n",
- " amount = tool_input[\"amount\"]\n",
- " # Call the enemyscan function with the amount\n",
- " enemy_scan_res = enemyscan(amount)\n",
- "\n",
- " loop = loop + 1\n",
- "print(inv_scan_res)\n",
- "print(enemy_scan_res)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "And now we are basically done! We can give this to th AI and see what we get"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 26,
- "metadata": {},
- "outputs": [],
- "source": [
- "initial_messages.append(\n",
- " {\n",
- " \"role\": \"assistant\",\n",
- " \"content\": f\"Weapons Inventory Scan Result: {inv_scan_res}\\nEnemy Scans Result: {enemy_scan_res}\",\n",
- " }\n",
- ")\n",
- "\n",
- "\n",
- "initial_messages.append(\n",
- " {\n",
- " \"role\": \"user\",\n",
- " \"content\": \"What is the combat plan for killing these demons? Based on the last message, tell me which demons to kill first, in which order and using which weapons as well as any sweakpoints.\",\n",
- " }\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 27,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Certainly, I'll outline a combat plan for efficiently eliminating these demons based on the enemy scan and our available weaponry. Here's the recommended order of engagement and the most effective weapons to use:\n",
- "\n",
- "1. Cacodemon (Highest Priority):\n",
- " - Weapon: Rocket Launcher with Lock-On Burst mod\n",
- " - Strategy: The Cacodemon's aerial mobility makes it a priority target. Use the Rocket Launcher's Lock-On Burst to ensure hits. Aim for its open mouth, which is its weak point. A well-placed rocket in its mouth can stagger it, allowing for a quick Glory Kill.\n",
- "\n",
- "2. Mancubus:\n",
- " - Weapon: BFG 9000\n",
- " - Strategy: The Mancubus is slow but dangerous due to its high firepower. Use the BFG 9000 to deal massive damage quickly. Aim for its arm cannons to disable its primary attack method. The BFG's area effect can also damage nearby demons.\n",
- "\n",
- "3. Hell Knights (3 present):\n",
- " - Weapon: Super Shotgun with Meat Hook\n",
- " - Strategy: Use the Meat Hook to close distance quickly, then unleash the Super Shotgun's devastating close-range damage. Aim for the head to maximize damage. The Ice Bomb can be used to freeze multiple Hell Knights at once, allowing for easier targeting and potential Glory Kills.\n",
- "\n",
- "4. Imps (Lowest Priority):\n",
- " - Weapon: Super Shotgun or Rocket Launcher (for groups)\n",
- " - Strategy: Imps are fast but relatively weak. Use the Super Shotgun for close encounters or the Rocket Launcher to take out groups. Their agility makes them dangerous if ignored, so eliminate them when they group up or after dealing with bigger threats.\n",
- "\n",
- "General Combat Tips:\n",
- "1. Use the Ice Bomb strategically to freeze multiple enemies, especially when Hell Knights and Imps are grouped together.\n",
- "2. Keep moving to avoid being surrounded. Use the Meat Hook on the Super Shotgun for quick mobility between targets.\n",
- "3. Save the BFG 9000 ammo for the Mancubus or if you get overwhelmed by multiple heavy demons.\n",
- "4. Prioritize Glory Kills when possible to replenish health and armor.\n",
- "5. Use the environment to your advantage, funneling enemies into choke points for more effective use of area-of-effect weapons like the Rocket Launcher.\n",
- "\n",
- "Remember, Doom Slayer, the key is to stay mobile, prioritize threats, and make efficient use of your diverse arsenal. Rip and tear, until it is done!\n"
- ]
- }
- ],
- "source": [
- "response = client.messages.create(\n",
- " max_tokens=5000,\n",
- " model=\"claude-3-5-sonnet-20240620\",\n",
- " tools=[\n",
- " {\n",
- " \"name\": \"enemyscan_tool\",\n",
- " \"description\": \"Retrieve a list of demons currently present in the area.\",\n",
- " \"input_schema\": {\n",
- " \"type\": \"object\",\n",
- " \"properties\": {\n",
- " \"amount\": {\n",
- " \"type\": \"integer\",\n",
- " \"description\": \"Number of enemies to scan.\",\n",
- " }\n",
- " },\n",
- " \"required\": [\"amount\"],\n",
- " },\n",
- " },\n",
- " {\n",
- " \"name\": \"inventoryscan_tool\",\n",
- " \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n",
- " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
- " },\n",
- " ],\n",
- " messages=initial_messages,\n",
- ")\n",
- "\n",
- "message = response.content[0].text\n",
- "print(message)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "End the session"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 28,
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "🖇 AgentOps: Session Stats - \u001b[1mDuration:\u001b[0m 27.6s | \u001b[1mCost:\u001b[0m $0.022353 | \u001b[1mLLMs:\u001b[0m 4 | \u001b[1mTools:\u001b[0m 0 | \u001b[1mActions:\u001b[0m 0 | \u001b[1mErrors:\u001b[0m 0\n",
- "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=df6426c5-1995-4bec-b90e-680369a0cddb\u001b[0m\u001b[0m\n"
- ]
- }
- ],
- "source": [
- "agentops.end_session(\"Success\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kaggle": {
- "accelerator": "none",
- "dataSources": [],
- "dockerImageVersionId": 30787,
- "isGpuEnabled": false,
- "isInternetEnabled": true,
- "language": "python",
- "sourceType": "notebook"
- },
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.5"
- }
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Anthropic's tool returns are not as simple as getting a few strings! While this system is more complex than those before it, it's also simple enough to be used without problem once you understand how it works! "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To get started, we will import Agentops and Anthropic"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "!pip install agentops\n",
+ "!pip install anthropic"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Setup our generic default statements"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from anthropic import Anthropic, AsyncAnthropic\n",
+ "import agentops\n",
+ "import os\n",
+ "import random # We don't need this for agentops, we use this to generate a message later\n",
+ "import time # We don't need this for agentops either, we use this when simulating an API later\n",
+ "import re # Regex for formatting\n",
+ "from dotenv import load_dotenv"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And set our API keys."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "load_dotenv()\n",
+ "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\n",
+ "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "Now let's set the client as Anthropic and make an AgentOps session"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=df6426c5-1995-4bec-b90e-680369a0cddb\u001b[0m\u001b[0m\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "<agentops.session.Session at 0x10e6ca710>"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool-tutorials\"])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "client = Anthropic(api_key=ANTHROPIC_API_KEY)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now to create a simple dummy tool! We are going to make a tool that will tell us about the demon infestation levels for 3 areas. From there, we will have VEGA, our AI determine the best place for the Doom Slayer to attack."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "locations = [\n",
+ " {\n",
+ " \"Name\": \"Super Gore Nest\",\n",
+ " \"Description\": \"A grotesque mass of demonic growth and organic structures infesting the ruins of an urban area on Earth. The Super Gore Nest serves as a massive, pulsating hive for Hell’s forces, complete with rivers of blood, twisted tendrils, and a dark, organic design that shows how deeply Hell has taken root in the city.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Exultia\",\n",
+ " \"Description\": \"An ancient, mystical world that holds the ruins of the Night Sentinels' kingdom, with gothic structures and arcane symbols throughout. This realm is filled with epic landscapes, medieval architecture, and hints of the powerful civilization that once defended against Hell’s forces.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Cultist Base\",\n",
+ " \"Description\": \"A grim fortress hidden within the icy mountains, where a fanatical cult worships demons. Filled with chilling sacrificial chambers, traps, and rituals, the Cultist Base is a hostile stronghold where Doom Slayer must confront the cult leaders aiding Hell's invasion of Earth.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Taras Nabad\",\n",
+ " \"Description\": \"A war-ravaged city on the homeworld of the Night Sentinels, showcasing grandiose, ancient architecture in the midst of destruction. Taras Nabad's sprawling structures and historical significance reveal glimpses into the Doom Slayer’s past and the once-thriving Sentinel civilization.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Nekravol\",\n",
+ " \"Description\": \"A hellish, industrial fortress where souls are processed into Argent energy. With conveyor belts moving the damned and a skyline dominated by fire and darkness, Nekravol is a nightmarish facility that powers Hell's armies and embodies the horrific machinery of Hell's cruelty.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Urdak\",\n",
+ " \"Description\": \"A surreal, high-tech realm that serves as the home of the angelic Maykrs. Urdak’s sleek, pristine architecture and ethereal ambiance sharply contrast with Hell’s brutal landscapes, yet this realm holds its own dark secrets and a critical role in Hell's invasion of Earth.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"UAC Base\",\n",
+ " \"Description\": \"A futuristic military base on Earth controlled by the Union Aerospace Corporation (UAC), filled with high-tech weaponry and security systems. The UAC Base serves as a human foothold in the fight against Hell, though some within its ranks may have darker intentions.\",\n",
+ " },\n",
+ "]\n",
+ "\n",
+ "combat_casualties = [\"Nonexistent\", \"Low\", \"Medium\", \"High\", \"Extinction\"]\n",
+ "\n",
+ "missions = [\n",
+ " \"Locate and confront a key leader of Hell’s invasion forces.\",\n",
+ " \"Clear out demonic infestations to secure a strategic foothold.\",\n",
+ " \"Disrupt Hell's control over the area by eliminating critical targets.\",\n",
+ " \"Enter a critical demonic stronghold to disrupt enemy operations.\",\n",
+ " \"Locate and destroy the central power source to weaken enemy forces.\",\n",
+ " \"Collect essential resources before the area becomes unstable.\",\n",
+ "]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now that that's done, we can make a function! We will generate three random missions and pass it off to the AI."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def generate_missions():\n",
+ " selectedmissions = []\n",
+ " loop = 0\n",
+ "\n",
+ " while loop < 3:\n",
+ " location = random.choice(locations)\n",
+ " casualties = random.choice(combat_casualties)\n",
+ " mission = random.choice(missions)\n",
+ " final = (\n",
+ " f'LocationName: {location[\"Name\"]}, '\n",
+ " f'LocationInfo: {location[\"Description\"]}, '\n",
+ " f\"HumanCombatCasualties: {casualties}, \"\n",
+ " f\"Mission: {mission}\"\n",
+ " )\n",
+ "\n",
+ " selectedmissions.append(final)\n",
+ " loop += 1\n",
+ "\n",
+ " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n",
+ " missions_string = \"\\n\".join(\n",
+ " missions\n",
+ " ) # Or \", \".join(missions) for a comma-separated string\n",
+ " print(missions_string)\n",
+ " return missions_string"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Locate and confront a key leader of Hell’s invasion forces.\n",
+ "Clear out demonic infestations to secure a strategic foothold.\n",
+ "Disrupt Hell's control over the area by eliminating critical targets.\n",
+ "Enter a critical demonic stronghold to disrupt enemy operations.\n",
+ "Locate and destroy the central power source to weaken enemy forces.\n",
+ "Collect essential resources before the area becomes unstable.\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "\"Locate and confront a key leader of Hell’s invasion forces.\\nClear out demonic infestations to secure a strategic foothold.\\nDisrupt Hell's control over the area by eliminating critical targets.\\nEnter a critical demonic stronghold to disrupt enemy operations.\\nLocate and destroy the central power source to weaken enemy forces.\\nCollect essential resources before the area becomes unstable.\""
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "generate_missions()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it (and it's generally good practice)!\n",
+ "\n",
+ "We are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now we make a message! This time around we will skip making an intial message that has too much context, unlike in the past!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# We make our history a separate block to be easier to add to later on! This is essentially our history\n",
+ "initial_messages = [\n",
+ " {\n",
+ " \"role\": \"user\",\n",
+ " \"content\": \"You are VEGA, the assistant to the DOOMGUY. Get three missions from the ship's API and tell me which mission is most to least important for quellng the forces of hell. \",\n",
+ " }\n",
+ "]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now to construct a request!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01HAJR2iiPBGr9A473tZyewV', input={}, name='generate_missions', type='tool_use')]\n"
+ ]
+ }
+ ],
+ "source": [
+ "response = client.messages.create(\n",
+ " max_tokens=5000,\n",
+ " model=\"claude-3-5-sonnet-20240620\",\n",
+ " tools=[\n",
+ " {\n",
+ " \"name\": \"generate_missions\",\n",
+ " \"description\": \"Retrieve three missions for the DoomSlayer\",\n",
+ " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
+ " }\n",
+ " ],\n",
+ " messages=initial_messages,\n",
+ ")\n",
+ "\n",
+ "print(response.content)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Having trouble understanding this? The first block given is always Ai dialouge! You can use response.content[0].text to get the AI's text! Let's try it below."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\n",
+ "\n",
+ "Let's begin by retrieving the missions:\n"
+ ]
+ }
+ ],
+ "source": [
+ "message = response.content[0].text\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The code below finds the tool used!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[TextBlock(text=\"Certainly! As VEGA, I'll retrieve three missions for the DoomSlayer from the ship's API using the available function. Then, I'll analyze and prioritize them based on their importance for quelling the forces of Hell.\\n\\nLet's begin by retrieving the missions:\", type='text'), ToolUseBlock(id='toolu_01HAJR2iiPBGr9A473tZyewV', input={}, name='generate_missions', type='tool_use')]\n",
+ "Locate and confront a key leader of Hell’s invasion forces.\n",
+ "Clear out demonic infestations to secure a strategic foothold.\n",
+ "Disrupt Hell's control over the area by eliminating critical targets.\n",
+ "Enter a critical demonic stronghold to disrupt enemy operations.\n",
+ "Locate and destroy the central power source to weaken enemy forces.\n",
+ "Collect essential resources before the area becomes unstable.\n"
+ ]
+ }
+ ],
+ "source": [
+ "gen_mission_result = \"\"\n",
+ "\n",
+ "# Print response content to see the data\n",
+ "print(response.content)\n",
+ "\n",
+ "# Assuming ToolUseBlock is at index 1\n",
+ "tool_use_block = response.content[1]\n",
+ "\n",
+ "# Get the tool name and input\n",
+ "tool_name = tool_use_block.name\n",
+ "tool_input = tool_use_block.input\n",
+ "\n",
+ "# We don't need to look to extract any inputs since we don't use any\n",
+ "\n",
+ "# Check if the tool name is \"generate_missions\"\n",
+ "if tool_name == \"generate_missions\":\n",
+ " # Call the function with the tool creator as an argument\n",
+ " gen_mission_result = generate_missions()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now we add these as context to the LLM through intial messages!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "initial_messages.append({\"role\": \"assistant\", \"content\": gen_mission_result})\n",
+ "\n",
+ "initial_messages.append(\n",
+ " {\n",
+ " \"role\": \"user\",\n",
+ " \"content\": \"Based on these, which location should take priority and why?\",\n",
+ " }\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And now to get a response!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Message(id='msg_016Hd62W2sJNyd762Yp1udLd', content=[TextBlock(text=\"I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly retrieving the missions using the available function. \", type='text'), ToolUseBlock(id='toolu_01TUaMJbZc7VHMVZKaA9RqvL', input={}, name='generate_missions', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=497, output_tokens=83))\n"
+ ]
+ }
+ ],
+ "source": [
+ "response = client.messages.create(\n",
+ " max_tokens=5000,\n",
+ " model=\"claude-3-5-sonnet-20240620\",\n",
+ " tools=[\n",
+ " {\n",
+ " \"name\": \"generate_missions\",\n",
+ " \"description\": \"Retrieve three missions for the DoomSlayer\",\n",
+ " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
+ " }\n",
+ " ],\n",
+ " messages=initial_messages,\n",
+ ")\n",
+ "\n",
+ "print(response)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Isolate again!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "I apologize for the confusion in my previous response. I made a mistake by providing mission details without actually retrieving them from the ship's API. Let me correct that by properly retrieving the missions using the available function. \n"
+ ]
+ }
+ ],
+ "source": [
+ "message = response.content[0].text\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Hmmm, what if we wanted to include more tools and add inputs? Let's create two new functions to display this!\n",
+ "\n",
+ "One will show the kind of demon we are facing, whereas another one will take our weapon input to determine what the best weapon chain to use is (You heard that right, we believe in quick weapon switches around these parts)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "demons = [\n",
+ " {\n",
+ " \"Name\": \"Imp\",\n",
+ " \"Description\": \"A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Cacodemon\",\n",
+ " \"Description\": \"A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Hell Knight\",\n",
+ " \"Description\": \"A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Mancubus\",\n",
+ " \"Description\": \"A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\",\n",
+ " },\n",
+ "]\n",
+ "\n",
+ "\n",
+ "weapons = [\n",
+ " {\n",
+ " \"Name\": \"Super Shotgun\",\n",
+ " \"Description\": \"A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Rocket Launcher\",\n",
+ " \"Description\": \"A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Chaingun\",\n",
+ " \"Description\": \"A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"BFG 9000\",\n",
+ " \"Description\": \"One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\",\n",
+ " },\n",
+ " {\n",
+ " \"Name\": \"Ice Bomb\",\n",
+ " \"Description\": \"A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\",\n",
+ " },\n",
+ "]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now we can keep the initialmessages from before actually! However let's change the context"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "initial_messages.append(\n",
+ " {\n",
+ " \"role\": \"user\",\n",
+ " \"content\": \"The first priority mission was selected. At the same time, scan for enemies and check inventory to determine the best combat strategy. You should use both tools at once.\",\n",
+ " }\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And we of course make functions"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def enemyscan(amount):\n",
+ " enemiesonscene = []\n",
+ " loop = 0\n",
+ "\n",
+ " while loop < amount + 1:\n",
+ " scannedenemy = random.choice(demons)\n",
+ "\n",
+ " # Append just the name of the demon to the list\n",
+ " enemiesonscene.append(scannedenemy[\"Name\"])\n",
+ " enemiesonscene.append(scannedenemy[\"Description\"])\n",
+ " loop += 1\n",
+ "\n",
+ " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n",
+ " enemies_string = \"\\n\".join(enemiesonscene)\n",
+ " print(enemies_string)\n",
+ " return enemies_string"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Imp\n",
+ "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
+ "Cacodemon\n",
+ "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n",
+ "Imp\n",
+ "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
+ "Imp\n",
+ "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
+ "Cacodemon\n",
+ "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n",
+ "Hell Knight\n",
+ "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "'Imp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nImp\\nA fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\\nCacodemon\\nA floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\\nHell Knight\\nA towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.'"
+ ]
+ },
+ "execution_count": 19,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "enemyscan(5)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And now inventory"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def inventoryscan():\n",
+ " weapons_at_hand = []\n",
+ " loop = 0\n",
+ "\n",
+ " while loop < 5:\n",
+ " weapon = random.choice(weapons)\n",
+ "\n",
+ " # Append just the name of the demon to the list\n",
+ " weapons_at_hand.append(weapon[\"Name\"])\n",
+ " weapons_at_hand.append(weapon[\"Description\"])\n",
+ " loop += 1\n",
+ "\n",
+ " # Combine all mission strings into a single string with a separator (e.g., newline or comma)\n",
+ " weapons_string = \"\\n\".join(weapons_at_hand)\n",
+ " print(weapons_string)\n",
+ " return weapons_string"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "BFG 9000\n",
+ "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
+ "Chaingun\n",
+ "A rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\n",
+ "BFG 9000\n",
+ "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
+ "Rocket Launcher\n",
+ "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n",
+ "Rocket Launcher\n",
+ "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n"
+ ]
},
- "nbformat": 4,
- "nbformat_minor": 4
- }
-
\ No newline at end of file
+ {
+ "data": {
+ "text/plain": [
+ "'BFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nChaingun\\nA rapid-fire weapon that can unleash a torrent of bullets at a high rate of speed. The Chaingun is perfect for mowing down enemies and can be equipped with the Heat Blast mod, allowing for explosive energy rounds that can clear multiple enemies at once.\\nBFG 9000\\nOne of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\\nRocket Launcher\\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\\nRocket Launcher\\nA high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.'"
+ ]
+ },
+ "execution_count": 21,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "inventoryscan()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "With that, let's construct our new tools and run this!!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Message(id='msg_0119o5gGDi7TRTsNPzNXd2ov', content=[TextBlock(text=\"Certainly! I'll prioritize the missions and use both tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\", type='text'), ToolUseBlock(id='toolu_01MmqMojDYtt5qdWnsXMJoWL', input={'amount': 5}, name='enemyscan_tool', type='tool_use'), ToolUseBlock(id='toolu_01WxN7tUMTFTai1WdiFc94HW', input={}, name='inventoryscan_tool', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=610, output_tokens=110))\n"
+ ]
+ }
+ ],
+ "source": [
+ "response = client.messages.create(\n",
+ " max_tokens=5000,\n",
+ " model=\"claude-3-5-sonnet-20240620\",\n",
+ " tools=[\n",
+ " {\n",
+ " \"name\": \"enemyscan_tool\",\n",
+ " \"description\": \"Retrieve a list of demons currently present in the area.\",\n",
+ " \"input_schema\": {\n",
+ " \"type\": \"object\",\n",
+ " \"properties\": {\n",
+ " \"amount\": {\n",
+ " \"type\": \"integer\",\n",
+ " \"description\": \"Number of enemies to scan.\",\n",
+ " }\n",
+ " },\n",
+ " \"required\": [\"amount\"],\n",
+ " },\n",
+ " },\n",
+ " {\n",
+ " \"name\": \"inventoryscan_tool\",\n",
+ " \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n",
+ " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
+ " },\n",
+ " ],\n",
+ " messages=initial_messages,\n",
+ ")\n",
+ "\n",
+ "print(response)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Display just the text"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Certainly! I'll prioritize the missions and use both tools to scan for enemies and check the inventory simultaneously. Let's proceed with the tool calls first.\n"
+ ]
+ }
+ ],
+ "source": [
+ "message = response.content[0].text\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "initial_messages.append({\"role\": \"assistant\", \"content\": f\"{str(response)}\"})"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And now to get the information and put it all together! PLEASE read the comments!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hell Knight\n",
+ "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
+ "Imp\n",
+ "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
+ "Hell Knight\n",
+ "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
+ "Mancubus\n",
+ "A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n",
+ "Hell Knight\n",
+ "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
+ "Cacodemon\n",
+ "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n",
+ "Rocket Launcher\n",
+ "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n",
+ "BFG 9000\n",
+ "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
+ "BFG 9000\n",
+ "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
+ "Super Shotgun\n",
+ "A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n",
+ "Ice Bomb\n",
+ "A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n",
+ "Rocket Launcher\n",
+ "A high-powered weapon that fires explosive rockets capable of dealing massive area damage. The Rocket Launcher is invaluable for taking down groups of enemies or dealing significant damage to larger demons, especially when upgraded with the Lock-On Burst mod.\n",
+ "BFG 9000\n",
+ "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
+ "BFG 9000\n",
+ "One of the most iconic weapons in the *Doom* franchise, the BFG 9000 fires a massive energy beam that obliterates anything in its path. With its massive damage potential, the BFG 9000 is a game-changer, especially in dealing with large groups of enemies or the toughest foes.\n",
+ "Super Shotgun\n",
+ "A powerful, double-barreled shotgun that delivers devastating close-range damage. Known for its sheer stopping power, the Super Shotgun can tear through enemies with ease, especially when equipped with the Meat Hook attachment, allowing for rapid mobility and devastating hits.\n",
+ "Ice Bomb\n",
+ "A special grenade that freezes enemies in a wide area, giving the Doom Slayer a chance to deal with multiple foes at once. The Ice Bomb is effective for crowd control, allowing for easy Glory Kills or creating distance from overwhelming enemies.\n",
+ "Hell Knight\n",
+ "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
+ "Imp\n",
+ "A fast, agile demon that hurls fireballs and uses its claws to tear apart its prey. Imps are commonly found in Hell’s army, notorious for their quickness and ability to climb walls, making them dangerous adversaries in any environment.\n",
+ "Hell Knight\n",
+ "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
+ "Mancubus\n",
+ "A grotesque, overweight demon that releases powerful fireballs from its massive arm cannons. Mancubus demons are slow-moving but dangerous due to their firepower and the ability to overwhelm enemies with their fiery onslaughts.\n",
+ "Hell Knight\n",
+ "A towering, brutish demon with immense strength and durability. The Hell Knight is capable of charging at the Doom Slayer and delivering devastating melee attacks. Its tough hide makes it resistant to most forms of damage.\n",
+ "Cacodemon\n",
+ "A floating, spherical demon with a large mouth full of teeth and an ability to launch explosive projectiles. Cacodemons are often encountered in open areas, where their aerial agility and relentless attacks pose a constant threat.\n"
+ ]
+ }
+ ],
+ "source": [
+ "inv_scan_res = \"\"\n",
+ "enemy_scan_res = \"\"\n",
+ "\n",
+ "\n",
+ "response_str = str(response)\n",
+ "tool_use_count = response_str.count(\n",
+ " \"ToolUseBlock\"\n",
+ ") # We know the ToolUseBlock will appear once for each tool request so we check how many time it appears\n",
+ "\n",
+ "\n",
+ "# You can use print(tool_use_count)to validate the ToolBlocks here if you wish\n",
+ "\n",
+ "loop = 0\n",
+ "\n",
+ "# We do this instead of a (foreach) because we need to skip the first block! This contains the message from the AI, not the tool! This way allows us to reference the item we want as easily as possible without complex logic needed!\n",
+ "\n",
+ "while loop < tool_use_count: # We will get the tools now\n",
+ " tool_use_block = response.content[\n",
+ " loop + 1\n",
+ " ] # We start at 1 since 0 holds the AI mesage\n",
+ " tool_name = tool_use_block.name\n",
+ " tool_input = tool_use_block.input\n",
+ "\n",
+ " if tool_name == \"inventoryscan_tool\":\n",
+ " # Call the inventoryscan function for inventoryscan_tool\n",
+ " inv_scan_res = inventoryscan()\n",
+ " elif tool_name == \"enemyscan_tool\":\n",
+ " # Get the amount for enemyscan_tool\n",
+ " amount = tool_input[\"amount\"]\n",
+ " # Call the enemyscan function with the amount\n",
+ " enemy_scan_res = enemyscan(amount)\n",
+ "\n",
+ " loop = loop + 1\n",
+ "print(inv_scan_res)\n",
+ "print(enemy_scan_res)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And now we are basically done! We can give this to th AI and see what we get"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "initial_messages.append(\n",
+ " {\n",
+ " \"role\": \"assistant\",\n",
+ " \"content\": f\"Weapons Inventory Scan Result: {inv_scan_res}\\nEnemy Scans Result: {enemy_scan_res}\",\n",
+ " }\n",
+ ")\n",
+ "\n",
+ "\n",
+ "initial_messages.append(\n",
+ " {\n",
+ " \"role\": \"user\",\n",
+ " \"content\": \"What is the combat plan for killing these demons? Based on the last message, tell me which demons to kill first, in which order and using which weapons as well as any sweakpoints.\",\n",
+ " }\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Certainly, I'll outline a combat plan for efficiently eliminating these demons based on the enemy scan and our available weaponry. Here's the recommended order of engagement and the most effective weapons to use:\n",
+ "\n",
+ "1. Cacodemon (Highest Priority):\n",
+ " - Weapon: Rocket Launcher with Lock-On Burst mod\n",
+ " - Strategy: The Cacodemon's aerial mobility makes it a priority target. Use the Rocket Launcher's Lock-On Burst to ensure hits. Aim for its open mouth, which is its weak point. A well-placed rocket in its mouth can stagger it, allowing for a quick Glory Kill.\n",
+ "\n",
+ "2. Mancubus:\n",
+ " - Weapon: BFG 9000\n",
+ " - Strategy: The Mancubus is slow but dangerous due to its high firepower. Use the BFG 9000 to deal massive damage quickly. Aim for its arm cannons to disable its primary attack method. The BFG's area effect can also damage nearby demons.\n",
+ "\n",
+ "3. Hell Knights (3 present):\n",
+ " - Weapon: Super Shotgun with Meat Hook\n",
+ " - Strategy: Use the Meat Hook to close distance quickly, then unleash the Super Shotgun's devastating close-range damage. Aim for the head to maximize damage. The Ice Bomb can be used to freeze multiple Hell Knights at once, allowing for easier targeting and potential Glory Kills.\n",
+ "\n",
+ "4. Imps (Lowest Priority):\n",
+ " - Weapon: Super Shotgun or Rocket Launcher (for groups)\n",
+ " - Strategy: Imps are fast but relatively weak. Use the Super Shotgun for close encounters or the Rocket Launcher to take out groups. Their agility makes them dangerous if ignored, so eliminate them when they group up or after dealing with bigger threats.\n",
+ "\n",
+ "General Combat Tips:\n",
+ "1. Use the Ice Bomb strategically to freeze multiple enemies, especially when Hell Knights and Imps are grouped together.\n",
+ "2. Keep moving to avoid being surrounded. Use the Meat Hook on the Super Shotgun for quick mobility between targets.\n",
+ "3. Save the BFG 9000 ammo for the Mancubus or if you get overwhelmed by multiple heavy demons.\n",
+ "4. Prioritize Glory Kills when possible to replenish health and armor.\n",
+ "5. Use the environment to your advantage, funneling enemies into choke points for more effective use of area-of-effect weapons like the Rocket Launcher.\n",
+ "\n",
+ "Remember, Doom Slayer, the key is to stay mobile, prioritize threats, and make efficient use of your diverse arsenal. Rip and tear, until it is done!\n"
+ ]
+ }
+ ],
+ "source": [
+ "response = client.messages.create(\n",
+ " max_tokens=5000,\n",
+ " model=\"claude-3-5-sonnet-20240620\",\n",
+ " tools=[\n",
+ " {\n",
+ " \"name\": \"enemyscan_tool\",\n",
+ " \"description\": \"Retrieve a list of demons currently present in the area.\",\n",
+ " \"input_schema\": {\n",
+ " \"type\": \"object\",\n",
+ " \"properties\": {\n",
+ " \"amount\": {\n",
+ " \"type\": \"integer\",\n",
+ " \"description\": \"Number of enemies to scan.\",\n",
+ " }\n",
+ " },\n",
+ " \"required\": [\"amount\"],\n",
+ " },\n",
+ " },\n",
+ " {\n",
+ " \"name\": \"inventoryscan_tool\",\n",
+ " \"description\": \"Retrieve a list of weapons the Doom Slayer has at hand.\",\n",
+ " \"input_schema\": {\"type\": \"object\", \"properties\": {}, \"required\": []},\n",
+ " },\n",
+ " ],\n",
+ " messages=initial_messages,\n",
+ ")\n",
+ "\n",
+ "message = response.content[0].text\n",
+ "print(message)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "End the session"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "🖇 AgentOps: Session Stats - \u001b[1mDuration:\u001b[0m 27.6s | \u001b[1mCost:\u001b[0m $0.022353 | \u001b[1mLLMs:\u001b[0m 4 | \u001b[1mTools:\u001b[0m 0 | \u001b[1mActions:\u001b[0m 0 | \u001b[1mErrors:\u001b[0m 0\n",
+ "🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=df6426c5-1995-4bec-b90e-680369a0cddb\u001b[0m\u001b[0m\n"
+ ]
+ }
+ ],
+ "source": [
+ "agentops.end_session(\"Success\")"
+ ]
+ }
+ ],
+ "metadata": {
+ "kaggle": {
+ "accelerator": "none",
+ "dataSources": [],
+ "dockerImageVersionId": 30787,
+ "isGpuEnabled": false,
+ "isInternetEnabled": true,
+ "language": "python",
+ "sourceType": "notebook"
+ },
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.5"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
diff --git a/examples/anthropic_examples/anthropic-example-sync.ipynb b/examples/anthropic_examples/anthropic-example-sync.ipynb
index 603af99d..0c80ee53 100644
--- a/examples/anthropic_examples/anthropic-example-sync.ipynb
+++ b/examples/anthropic_examples/anthropic-example-sync.ipynb
@@ -1,178 +1,189 @@
{
- "metadata": {
- "kernelspec": {
- "language": "python",
- "display_name": "Python 3",
- "name": "python3"
- },
- "language_info": {
- "name": "python",
- "version": "3.10.14",
- "mimetype": "text/x-python",
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "pygments_lexer": "ipython3",
- "nbconvert_exporter": "python",
- "file_extension": ".py"
- },
- "kaggle": {
- "accelerator": "none",
- "dataSources": [],
- "dockerImageVersionId": 30786,
- "isInternetEnabled": true,
- "language": "python",
- "sourceType": "notebook",
- "isGpuEnabled": false
- }
- },
- "nbformat_minor": 4,
- "nbformat": 4,
"cells": [
{
"cell_type": "markdown",
- "source": "We are going to create a program called \"Nier Storyteller\". In short, it uses a message system similar to Nier Automata's to generate a one sentence summary before creating a short story.\n\nExample:\n\n{A foolish doll} {died in a world} {of ended dreams.} turns into \"In a forgotten land where sunlight barely touched the ground, a little doll wandered through the remains of shattered dreams. Its porcelain face, cracked and wea...\"",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "We are going to create a program called \"Nier Storyteller\". In short, it uses a message system similar to Nier Automata's to generate a one sentence summary before creating a short story.\n",
+ "\n",
+ "Example:\n",
+ "\n",
+ "{A foolish doll} {died in a world} {of ended dreams.} turns into \"In a forgotten land where sunlight barely touched the ground, a little doll wandered through the remains of shattered dreams. Its porcelain face, cracked and wea...\""
+ ]
},
{
"cell_type": "markdown",
- "source": "First, we start by importing Agentops and Anthropic",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "First, we start by importing Agentops and Anthropic"
+ ]
},
{
"cell_type": "code",
- "source": "!pip install agentops\n!pip install anthropic",
+ "execution_count": null,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T19:19:24.428366Z",
"iopub.execute_input": "2024-11-09T19:19:24.428838Z",
+ "iopub.status.busy": "2024-11-09T19:19:24.428366Z",
"iopub.status.idle": "2024-11-09T19:19:58.542271Z",
- "shell.execute_reply.started": "2024-11-09T19:19:24.428796Z",
- "shell.execute_reply": "2024-11-09T19:19:58.540331Z"
+ "shell.execute_reply": "2024-11-09T19:19:58.540331Z",
+ "shell.execute_reply.started": "2024-11-09T19:19:24.428796Z"
},
"trusted": true
},
- "execution_count": 3,
- "outputs": [
- {
- "name": "stdout",
- "text": "Collecting agentops\n Downloading agentops-0.3.16-py3-none-any.whl.metadata (24 kB)\nRequirement already satisfied: requests<3.0.0,>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.32.3)\nCollecting psutil>=5.9.8 (from agentops)\n Downloading psutil-6.1.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (22 kB)\nCollecting packaging==23.2 (from agentops)\n Downloading packaging-23.2-py3-none-any.whl.metadata (3.2 kB)\nRequirement already satisfied: termcolor>=2.3.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.4.0)\nRequirement already satisfied: PyYAML<7.0,>=5.3 in /opt/conda/lib/python3.10/site-packages (from agentops) (6.0.2)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.7)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (2024.8.30)\nDownloading agentops-0.3.16-py3-none-any.whl (55 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.4/55.4 kB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading packaging-23.2-py3-none-any.whl (53 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.0/53.0 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading psutil-6.1.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (287 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m287.3/287.3 kB\u001b[0m \u001b[31m14.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hInstalling collected packages: psutil, packaging, agentops\n Attempting uninstall: psutil\n Found existing installation: psutil 5.9.3\n Uninstalling psutil-5.9.3:\n Successfully uninstalled psutil-5.9.3\n Attempting uninstall: packaging\n Found existing installation: packaging 21.3\n Uninstalling packaging-21.3:\n Successfully uninstalled packaging-21.3\n\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\nbeatrix-jupyterlab 2024.66.154055 requires jupyterlab~=3.6.0, but you have jupyterlab 4.2.5 which is incompatible.\ngoogle-cloud-bigquery 2.34.4 requires packaging<22.0dev,>=14.3, but you have packaging 23.2 which is incompatible.\njupyterlab 4.2.5 requires jupyter-lsp>=2.0.0, but you have jupyter-lsp 1.5.1 which is incompatible.\njupyterlab-lsp 5.1.0 requires jupyter-lsp>=2.0.0, but you have jupyter-lsp 1.5.1 which is incompatible.\nlibpysal 4.9.2 requires shapely>=2.0.1, but you have shapely 1.8.5.post1 which is incompatible.\nthinc 8.3.2 requires numpy<2.1.0,>=2.0.0; python_version >= \"3.9\", but you have numpy 1.26.4 which is incompatible.\nydata-profiling 4.10.0 requires scipy<1.14,>=1.4.1, but you have scipy 1.14.1 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0mSuccessfully installed agentops-0.3.16 packaging-23.2 psutil-5.9.8\nCollecting anthropic\n Downloading anthropic-0.39.0-py3-none-any.whl.metadata (22 kB)\nRequirement already satisfied: anyio<5,>=3.5.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.4.0)\nRequirement already satisfied: distro<2,>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.9.0)\nRequirement already satisfied: httpx<1,>=0.23.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.27.0)\nCollecting jiter<1,>=0.4.0 (from anthropic)\n Downloading jiter-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.2 kB)\nRequirement already satisfied: pydantic<3,>=1.9.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (2.9.2)\nRequirement already satisfied: sniffio in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.3.1)\nRequirement already satisfied: typing-extensions<5,>=4.7 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.12.2)\nRequirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (3.7)\nRequirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (1.2.0)\nRequirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (2024.8.30)\nRequirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (1.0.5)\nRequirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic) (0.14.0)\nRequirement already satisfied: annotated-types>=0.6.0 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (0.7.0)\nRequirement already satisfied: pydantic-core==2.23.4 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (2.23.4)\nDownloading anthropic-0.39.0-py3-none-any.whl (198 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m198.4/198.4 kB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading jiter-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (327 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m327.5/327.5 kB\u001b[0m \u001b[31m14.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hInstalling collected packages: jiter, anthropic\nSuccessfully installed anthropic-0.39.0 jiter-0.7.0\n",
- "output_type": "stream"
- }
+ "outputs": [],
+ "source": [
+ "!pip install agentops\n",
+ "!pip install anthropic"
]
},
{
"cell_type": "markdown",
- "source": "Setup our generic default statements",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Setup our generic default statements"
+ ]
},
{
"cell_type": "code",
- "source": [
- "from anthropic import Anthropic, AsyncAnthropic\n",
- "import agentops\n",
- "import os\n",
- "import random # We don't need this for agentops, we use this to generate a message later\n",
- "from dotenv import load_dotenv"
- ],
+ "execution_count": 4,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T19:20:59.990855Z",
"iopub.execute_input": "2024-11-09T19:20:59.991361Z",
+ "iopub.status.busy": "2024-11-09T19:20:59.990855Z",
"iopub.status.idle": "2024-11-09T19:21:00.999929Z",
- "shell.execute_reply.started": "2024-11-09T19:20:59.991315Z",
- "shell.execute_reply": "2024-11-09T19:21:00.998751Z"
+ "shell.execute_reply": "2024-11-09T19:21:00.998751Z",
+ "shell.execute_reply.started": "2024-11-09T19:20:59.991315Z"
},
"trusted": true
},
- "execution_count": 4,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "from anthropic import Anthropic, AsyncAnthropic\n",
+ "import agentops\n",
+ "import os\n",
+ "import random # We don't need this for agentops, we use this to generate a message later\n",
+ "from dotenv import load_dotenv"
+ ]
},
{
"cell_type": "markdown",
- "source": "And set our API keys.",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "And set our API keys."
+ ]
},
{
"cell_type": "code",
- "source": "load_dotenv()\nANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC KEY HERE\"\nAGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS KEY HERE\"",
+ "execution_count": 6,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T19:21:23.838379Z",
"iopub.execute_input": "2024-11-09T19:21:23.838837Z",
+ "iopub.status.busy": "2024-11-09T19:21:23.838379Z",
"iopub.status.idle": "2024-11-09T19:21:23.845690Z",
- "shell.execute_reply.started": "2024-11-09T19:21:23.838785Z",
- "shell.execute_reply": "2024-11-09T19:21:23.844372Z"
+ "shell.execute_reply": "2024-11-09T19:21:23.844372Z",
+ "shell.execute_reply.started": "2024-11-09T19:21:23.838785Z"
},
"trusted": true
},
- "execution_count": 6,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "load_dotenv()\n",
+ "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC KEY HERE\"\n",
+ "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS KEY HERE\""
+ ]
},
{
"cell_type": "markdown",
- "source": "Now let's set the client as Anthropic and an AgentOps session!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Now let's set the client as Anthropic and an AgentOps session!"
+ ]
},
{
"cell_type": "code",
- "source": "client = Anthropic(api_key=ANTHROPIC_API_KEY)",
+ "execution_count": 7,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T19:21:25.807585Z",
"iopub.execute_input": "2024-11-09T19:21:25.808135Z",
+ "iopub.status.busy": "2024-11-09T19:21:25.807585Z",
"iopub.status.idle": "2024-11-09T19:21:25.828306Z",
- "shell.execute_reply.started": "2024-11-09T19:21:25.808078Z",
- "shell.execute_reply": "2024-11-09T19:21:25.826994Z"
+ "shell.execute_reply": "2024-11-09T19:21:25.826994Z",
+ "shell.execute_reply.started": "2024-11-09T19:21:25.808078Z"
},
"trusted": true
},
- "execution_count": 7,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "client = Anthropic(api_key=ANTHROPIC_API_KEY)"
+ ]
},
{
"cell_type": "code",
- "source": "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example\"])",
+ "execution_count": null,
"metadata": {
"trusted": true
},
- "execution_count": null,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example\"])"
+ ]
},
{
"cell_type": "raw",
- "source": "Remember that story we made earlier? As of writing, claude-3-5-sonnet-20240620 (the version we will be using) has a 150k word, 680k character length. We also get an 8192 context length. This is great because we can actually set an example for the script! \n\nLet's assume we have user (the person speaking), assistant (the AI itself) for now and computer (the way the LLM gets references from).",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Remember that story we made earlier? As of writing, claude-3-5-sonnet-20240620 (the version we will be using) has a 150k word, 680k character length. We also get an 8192 context length. This is great because we can actually set an example for the script! \n",
+ "\n",
+ "Let's assume we have user (the person speaking), assistant (the AI itself) for now and computer (the way the LLM gets references from)."
+ ]
},
{
"cell_type": "markdown",
- "source": "Let's set a default story as a script!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Let's set a default story as a script!"
+ ]
},
{
"cell_type": "code",
- "source": "defaultstory = \"In a forgotten land where sunlight barely touched the ground, a little doll wandered through the remains of shattered dreams. Its porcelain face, cracked and weathered, reflected the emptiness that hung in the air like a lingering fog. The doll's painted eyes, now chipped and dull, stared into the distance, searching for something—anything—that still held life. It had once belonged to a child who dreamt of endless adventures, of castles in the clouds and whispered secrets under starry skies. But those dreams had long since crumbled to dust, leaving behind nothing but a hollow world where even hope dared not tread. The doll, a relic of a life that had faded, trudged through the darkness, its tiny feet stumbling over broken wishes and forgotten stories. Each step took more effort than the last, as if the world itself pulled at the doll's limbs, weary and bitter. It reached a place where the ground fell away into an abyss of despair, the edge crumbling under its weight. The doll paused, teetering on the brink. It reached out, as though to catch a fading dream, but there was nothing left to hold onto. With a faint crack, its brittle body gave way, and the doll tumbled silently into the void. And so, in a world where dreams had died, the foolish little doll met its end. There were no tears, no mourning. Only the soft, empty echo of its fall, fading into the darkness, as the land of ended dreams swallowed the last trace of what once was.\"",
+ "execution_count": 10,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T19:21:34.091200Z",
"iopub.execute_input": "2024-11-09T19:21:34.091673Z",
+ "iopub.status.busy": "2024-11-09T19:21:34.091200Z",
"iopub.status.idle": "2024-11-09T19:21:34.098273Z",
- "shell.execute_reply.started": "2024-11-09T19:21:34.091630Z",
- "shell.execute_reply": "2024-11-09T19:21:34.096957Z"
+ "shell.execute_reply": "2024-11-09T19:21:34.096957Z",
+ "shell.execute_reply.started": "2024-11-09T19:21:34.091630Z"
},
"trusted": true
},
- "execution_count": 10,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "defaultstory = \"In a forgotten land where sunlight barely touched the ground, a little doll wandered through the remains of shattered dreams. Its porcelain face, cracked and weathered, reflected the emptiness that hung in the air like a lingering fog. The doll's painted eyes, now chipped and dull, stared into the distance, searching for something—anything—that still held life. It had once belonged to a child who dreamt of endless adventures, of castles in the clouds and whispered secrets under starry skies. But those dreams had long since crumbled to dust, leaving behind nothing but a hollow world where even hope dared not tread. The doll, a relic of a life that had faded, trudged through the darkness, its tiny feet stumbling over broken wishes and forgotten stories. Each step took more effort than the last, as if the world itself pulled at the doll's limbs, weary and bitter. It reached a place where the ground fell away into an abyss of despair, the edge crumbling under its weight. The doll paused, teetering on the brink. It reached out, as though to catch a fading dream, but there was nothing left to hold onto. With a faint crack, its brittle body gave way, and the doll tumbled silently into the void. And so, in a world where dreams had died, the foolish little doll met its end. There were no tears, no mourning. Only the soft, empty echo of its fall, fading into the darkness, as the land of ended dreams swallowed the last trace of what once was.\""
+ ]
},
{
"cell_type": "markdown",
- "source": "We are almost done! Let's generate a one sentence story summary by taking 3 random sentence fragments and connecting them!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "We are almost done! Let's generate a one sentence story summary by taking 3 random sentence fragments and connecting them!"
+ ]
},
{
"cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T19:21:35.472609Z",
+ "iopub.status.busy": "2024-11-09T19:21:35.472107Z",
+ "iopub.status.idle": "2024-11-09T19:21:35.481452Z",
+ "shell.execute_reply": "2024-11-09T19:21:35.480022Z",
+ "shell.execute_reply.started": "2024-11-09T19:21:35.472556Z"
+ },
+ "trusted": true
+ },
+ "outputs": [],
"source": [
"# Define the lists\n",
"first = [\n",
@@ -223,27 +234,46 @@
"generatedsentence = (\n",
" f\"{random.choice(first)} {random.choice(second)} {random.choice(third)}.\"\n",
")"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T19:21:35.472107Z",
- "iopub.execute_input": "2024-11-09T19:21:35.472609Z",
- "iopub.status.idle": "2024-11-09T19:21:35.481452Z",
- "shell.execute_reply.started": "2024-11-09T19:21:35.472556Z",
- "shell.execute_reply": "2024-11-09T19:21:35.480022Z"
- },
- "trusted": true
- },
- "execution_count": 11,
- "outputs": []
+ ]
},
{
"cell_type": "markdown",
- "source": "And now to construct a stream/message! We set an example for the assistant now!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "And now to construct a stream/message! We set an example for the assistant now!"
+ ]
},
{
"cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T19:21:38.031580Z",
+ "iopub.status.busy": "2024-11-09T19:21:38.031097Z",
+ "iopub.status.idle": "2024-11-09T19:21:47.760983Z",
+ "shell.execute_reply": "2024-11-09T19:21:47.759589Z",
+ "shell.execute_reply.started": "2024-11-09T19:21:38.031536Z"
+ },
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A weaponless soldier grimaced in anger inside an empty ship.\n",
+ "\n",
+ "\n",
+ "The cavernous hull of the abandoned starship echoed with the frustrated growls of Sergeant Maria Vega as she paced its empty corridors. Her hands, calloused from years of combat, clenched and unclenched at her sides, a habit born of the unsettling absence of her trusty plasma rifle. Just hours ago, she had been part of an elite squad tasked with investigating a distress signal from this very vessel, but a series of unfortunate events had left her separated from her team and stripped of her weapons.\n",
+ "\n",
+ "The ship, once a bustling hub of interstellar commerce, now drifted lifelessly through the void, its systems offline and its crew mysteriously vanished. As Maria moved through the ghostly interior, her anger at her predicament slowly gave way to a creeping sense of dread. Without her weapons, she felt naked and vulnerable, acutely aware of every shadow and unexplained noise.\n",
+ "\n",
+ "Rounding a corner, she froze as a metallic clang echoed from a nearby chamber. Her soldier's instincts kicked in, and she pressed herself against the wall, straining to hear any further sounds. As the silence stretched on, Maria realized that surviving this mission—and uncovering the truth behind the ship's fate—would require more than just firepower. It would take all of her training, wit, and courage to face whatever lurked in the depths of this forsaken vessel.\n",
+ "\n",
+ "With a deep breath, she steeled herself and moved towards the source of the noise. Weaponless she may be, but a soldier is never truly defenseless. As she approached the chamber, Maria vowed to solve the mystery of the empty ship and find her way back to her team, no matter what horrors awaited her in the darkness ahead.\n"
+ ]
+ }
+ ],
"source": [
"stream = client.messages.create(\n",
" max_tokens=2400,\n",
@@ -274,39 +304,55 @@
" elif event.type == \"message_stop\":\n",
" print(generatedsentence)\n",
" print(response)"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T19:21:38.031097Z",
- "iopub.execute_input": "2024-11-09T19:21:38.031580Z",
- "iopub.status.idle": "2024-11-09T19:21:47.760983Z",
- "shell.execute_reply.started": "2024-11-09T19:21:38.031536Z",
- "shell.execute_reply": "2024-11-09T19:21:47.759589Z"
- },
- "trusted": true
- },
- "execution_count": 12,
- "outputs": [
- {
- "name": "stdout",
- "text": "A weaponless soldier grimaced in anger inside an empty ship.\n\n\nThe cavernous hull of the abandoned starship echoed with the frustrated growls of Sergeant Maria Vega as she paced its empty corridors. Her hands, calloused from years of combat, clenched and unclenched at her sides, a habit born of the unsettling absence of her trusty plasma rifle. Just hours ago, she had been part of an elite squad tasked with investigating a distress signal from this very vessel, but a series of unfortunate events had left her separated from her team and stripped of her weapons.\n\nThe ship, once a bustling hub of interstellar commerce, now drifted lifelessly through the void, its systems offline and its crew mysteriously vanished. As Maria moved through the ghostly interior, her anger at her predicament slowly gave way to a creeping sense of dread. Without her weapons, she felt naked and vulnerable, acutely aware of every shadow and unexplained noise.\n\nRounding a corner, she froze as a metallic clang echoed from a nearby chamber. Her soldier's instincts kicked in, and she pressed herself against the wall, straining to hear any further sounds. As the silence stretched on, Maria realized that surviving this mission—and uncovering the truth behind the ship's fate—would require more than just firepower. It would take all of her training, wit, and courage to face whatever lurked in the depths of this forsaken vessel.\n\nWith a deep breath, she steeled herself and moved towards the source of the noise. Weaponless she may be, but a soldier is never truly defenseless. As she approached the chamber, Maria vowed to solve the mystery of the empty ship and find her way back to her team, no matter what horrors awaited her in the darkness ahead.\n",
- "output_type": "stream"
- }
]
},
{
"cell_type": "markdown",
- "source": "Finally, we put the session to sleep! Go to your AgentOps dashboard and you should see this session reflected!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Finally, we put the session to sleep! Go to your AgentOps dashboard and you should see this session reflected!"
+ ]
},
{
"cell_type": "code",
- "source": "agentops.end_session(\"Success\")",
+ "execution_count": null,
"metadata": {
"trusted": true
},
- "execution_count": null,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "agentops.end_session(\"Success\")"
+ ]
}
- ]
-}
\ No newline at end of file
+ ],
+ "metadata": {
+ "kaggle": {
+ "accelerator": "none",
+ "dataSources": [],
+ "dockerImageVersionId": 30786,
+ "isGpuEnabled": false,
+ "isInternetEnabled": true,
+ "language": "python",
+ "sourceType": "notebook"
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.14"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
diff --git a/examples/anthropic_examples/anthropic_example.ipynb b/examples/anthropic_examples/anthropic_example.ipynb
deleted file mode 100644
index 1c2cce8a..00000000
--- a/examples/anthropic_examples/anthropic_example.ipynb
+++ /dev/null
@@ -1,235 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Anthropic Example"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "First let's install the required packages"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "%pip install -U anthropic\n",
- "%pip install -U agentops"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Then import them"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from anthropic import Anthropic, AsyncAnthropic\n",
- "import agentops\n",
- "import os\n",
- "from dotenv import load_dotenv"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Next, we'll grab our API keys. You can use dotenv like below or however else you like to load environment variables"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "load_dotenv()\n",
- "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"<your_anthropic_key>\"\n",
- "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"<your_agentops_key>\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example\"])"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Sync Example\n",
- "We will demonstrate a basic sync call to Anthropic using the Claude 3.5 Sonnet model."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "client = Anthropic()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "stream = client.messages.create(\n",
- " max_tokens=1024,\n",
- " model=\"claude-3-5-sonnet-20240620\",\n",
- " messages=[\n",
- " {\n",
- " \"role\": \"user\",\n",
- " \"content\": \"How much wood could a wood chuck chuck if a wood chuck could chuck wood?\",\n",
- " }\n",
- " ],\n",
- " stream=True,\n",
- ")\n",
- "\n",
- "response = \"\"\n",
- "for event in stream:\n",
- " if event.type == \"content_block_delta\":\n",
- " response += event.delta.text\n",
- " elif event.type == \"message_stop\":\n",
- " print(response)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Async Example\n",
- "The async example is very similar to the sync example, but it uses the AsyncAnthropic client from the anthropic library."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "aclient = AsyncAnthropic()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "async def main() -> None:\n",
- " message = await aclient.messages.create(\n",
- " max_tokens=1024,\n",
- " messages=[\n",
- " {\n",
- " \"role\": \"user\",\n",
- " \"content\": \"Explain everything you know about the Leibniz Equation.\",\n",
- " }\n",
- " ],\n",
- " model=\"claude-3-5-sonnet-20240620\",\n",
- " )\n",
- " print(message.content[0].text)\n",
- "\n",
- "\n",
- "await main()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Tool Calling Example\n",
- "Anthropic models support tool calling, which allows the model to call external APIs."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "stream = client.messages.create(\n",
- " max_tokens=1024,\n",
- " model=\"claude-3-5-sonnet-20240620\",\n",
- " tools=[\n",
- " {\n",
- " \"name\": \"web_search\",\n",
- " \"description\": \"Search the web for information\",\n",
- " \"input_schema\": {\n",
- " \"type\": \"object\",\n",
- " \"properties\": {\n",
- " \"query\": {\"type\": \"string\", \"description\": \"The search query\"}\n",
- " },\n",
- " \"required\": [\"query\"],\n",
- " },\n",
- " }\n",
- " ],\n",
- " messages=[\n",
- " {\n",
- " \"role\": \"user\",\n",
- " \"content\": \"Tell me everything you can about AgentOps\",\n",
- " }\n",
- " ],\n",
- " stream=True,\n",
- ")\n",
- "\n",
- "response = \"\"\n",
- "for event in stream:\n",
- " if event.type == \"content_block_delta\":\n",
- " if event.delta.type == \"text\":\n",
- " response += event.delta.text\n",
- " elif event.type == \"message_stop\":\n",
- " print(response)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "agentops.end_session(\"Success\")"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "ops",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.12.3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
diff --git a/examples/anthropic_examples/antrophic-example-tool.ipynb b/examples/anthropic_examples/antrophic-example-tool.ipynb
index c061fd56..f47ea75d 100644
--- a/examples/anthropic_examples/antrophic-example-tool.ipynb
+++ b/examples/anthropic_examples/antrophic-example-tool.ipynb
@@ -1,74 +1,61 @@
{
- "metadata": {
- "kernelspec": {
- "language": "python",
- "display_name": "Python 3",
- "name": "python3"
- },
- "language_info": {
- "name": "python",
- "version": "3.10.14",
- "mimetype": "text/x-python",
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "pygments_lexer": "ipython3",
- "nbconvert_exporter": "python",
- "file_extension": ".py"
- },
- "kaggle": {
- "accelerator": "gpu",
- "dataSources": [],
- "dockerImageVersionId": 30786,
- "isInternetEnabled": true,
- "language": "python",
- "sourceType": "notebook",
- "isGpuEnabled": true
- }
- },
- "nbformat_minor": 4,
- "nbformat": 4,
"cells": [
{
"cell_type": "markdown",
- "source": "Anthropic supports tools, allowing you to easily connect with different external APIs and the like!\n\nFor this example, we are going to make a tool called \"Cyberware\" which will be our tool; we will create a dummy API that gives specs for cyberware from a specific company before the LLM says if the cyberware is good for a build. To do so, we will use both the tool system and an async function!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Anthropic supports tools, allowing you to easily connect with different external APIs and the like!\n",
+ "\n",
+ "For this example, we are going to make a tool called \"Cyberware\" which will be our tool; we will create a dummy API that gives specs for cyberware from a specific company before the LLM says if the cyberware is good for a build. To do so, we will use both the tool system and an async function!"
+ ]
},
{
"cell_type": "markdown",
- "source": "First, we start by importing Agentops and Anthropic",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "First, we start by importing Agentops and Anthropic"
+ ]
},
{
"cell_type": "code",
- "source": "!pip install agentops\n!pip install anthropic",
+ "execution_count": null,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T19:58:34.878657Z",
"iopub.execute_input": "2024-11-09T19:58:34.879322Z",
+ "iopub.status.busy": "2024-11-09T19:58:34.878657Z",
"iopub.status.idle": "2024-11-09T19:59:00.718845Z",
- "shell.execute_reply.started": "2024-11-09T19:58:34.879282Z",
- "shell.execute_reply": "2024-11-09T19:59:00.717724Z"
+ "shell.execute_reply": "2024-11-09T19:59:00.717724Z",
+ "shell.execute_reply.started": "2024-11-09T19:58:34.879282Z"
},
"trusted": true
},
- "execution_count": 3,
- "outputs": [
- {
- "name": "stdout",
- "text": "Collecting agentops\n Downloading agentops-0.3.16-py3-none-any.whl.metadata (24 kB)\nRequirement already satisfied: requests<3.0.0,>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.32.3)\nCollecting psutil>=5.9.8 (from agentops)\n Downloading psutil-6.1.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (22 kB)\nCollecting packaging==23.2 (from agentops)\n Downloading packaging-23.2-py3-none-any.whl.metadata (3.2 kB)\nRequirement already satisfied: termcolor>=2.3.0 in /opt/conda/lib/python3.10/site-packages (from agentops) (2.4.0)\nRequirement already satisfied: PyYAML<7.0,>=5.3 in /opt/conda/lib/python3.10/site-packages (from agentops) (6.0.2)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (3.7)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.0.0->agentops) (2024.8.30)\nDownloading agentops-0.3.16-py3-none-any.whl (55 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.4/55.4 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading packaging-23.2-py3-none-any.whl (53 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.0/53.0 kB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading psutil-6.1.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (287 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m287.3/287.3 kB\u001b[0m \u001b[31m21.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hInstalling collected packages: psutil, packaging, agentops\n Attempting uninstall: psutil\n Found existing installation: psutil 5.9.3\n Uninstalling psutil-5.9.3:\n Successfully uninstalled psutil-5.9.3\n Attempting uninstall: packaging\n Found existing installation: packaging 21.3\n Uninstalling packaging-21.3:\n Successfully uninstalled packaging-21.3\n\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\ncudf 24.8.3 requires cubinlinker, which is not installed.\ncudf 24.8.3 requires cupy-cuda11x>=12.0.0, which is not installed.\ncudf 24.8.3 requires ptxcompiler, which is not installed.\ncuml 24.8.0 requires cupy-cuda11x>=12.0.0, which is not installed.\ndask-cudf 24.8.3 requires cupy-cuda11x>=12.0.0, which is not installed.\nbeatrix-jupyterlab 2024.66.154055 requires jupyterlab~=3.6.0, but you have jupyterlab 4.2.5 which is incompatible.\ncudf 24.8.3 requires cuda-python<12.0a0,>=11.7.1, but you have cuda-python 12.6.0 which is incompatible.\ndistributed 2024.7.1 requires dask==2024.7.1, but you have dask 2024.9.1 which is incompatible.\ngoogle-cloud-bigquery 2.34.4 requires packaging<22.0dev,>=14.3, but you have packaging 23.2 which is incompatible.\njupyterlab 4.2.5 requires jupyter-lsp>=2.0.0, but you have jupyter-lsp 1.5.1 which is incompatible.\njupyterlab-lsp 5.1.0 requires jupyter-lsp>=2.0.0, but you have jupyter-lsp 1.5.1 which is incompatible.\nlibpysal 4.9.2 requires shapely>=2.0.1, but you have shapely 1.8.5.post1 which is incompatible.\nrapids-dask-dependency 24.8.0a0 requires dask==2024.7.1, but you have dask 2024.9.1 which is incompatible.\nydata-profiling 4.10.0 requires scipy<1.14,>=1.4.1, but you have scipy 1.14.1 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0mSuccessfully installed agentops-0.3.16 packaging-23.2 psutil-5.9.8\nCollecting anthropic\n Downloading anthropic-0.39.0-py3-none-any.whl.metadata (22 kB)\nRequirement already satisfied: anyio<5,>=3.5.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.4.0)\nRequirement already satisfied: distro<2,>=1.7.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.9.0)\nRequirement already satisfied: httpx<1,>=0.23.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (0.27.0)\nCollecting jiter<1,>=0.4.0 (from anthropic)\n Downloading jiter-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.2 kB)\nRequirement already satisfied: pydantic<3,>=1.9.0 in /opt/conda/lib/python3.10/site-packages (from anthropic) (2.9.2)\nRequirement already satisfied: sniffio in /opt/conda/lib/python3.10/site-packages (from anthropic) (1.3.1)\nRequirement already satisfied: typing-extensions<5,>=4.7 in /opt/conda/lib/python3.10/site-packages (from anthropic) (4.12.2)\nRequirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (3.7)\nRequirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5,>=3.5.0->anthropic) (1.2.0)\nRequirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (2024.8.30)\nRequirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx<1,>=0.23.0->anthropic) (1.0.5)\nRequirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic) (0.14.0)\nRequirement already satisfied: annotated-types>=0.6.0 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (0.7.0)\nRequirement already satisfied: pydantic-core==2.23.4 in /opt/conda/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->anthropic) (2.23.4)\nDownloading anthropic-0.39.0-py3-none-any.whl (198 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m198.4/198.4 kB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading jiter-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (327 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m327.5/327.5 kB\u001b[0m \u001b[31m19.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hInstalling collected packages: jiter, anthropic\nSuccessfully installed anthropic-0.39.0 jiter-0.7.0\n",
- "output_type": "stream"
- }
+ "outputs": [],
+ "source": [
+ "!pip install agentops\n",
+ "!pip install anthropic"
]
},
{
"cell_type": "markdown",
- "source": "Setup our generic default statements",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Setup our generic default statements"
+ ]
},
{
"cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T19:59:59.532140Z",
+ "iopub.status.busy": "2024-11-09T19:59:59.531722Z",
+ "iopub.status.idle": "2024-11-09T20:00:00.316206Z",
+ "shell.execute_reply": "2024-11-09T20:00:00.315436Z",
+ "shell.execute_reply.started": "2024-11-09T19:59:59.532101Z"
+ },
+ "trusted": true
+ },
+ "outputs": [],
"source": [
"from anthropic import Anthropic, AsyncAnthropic\n",
"import agentops\n",
@@ -77,76 +64,91 @@
"import time # We don't need this for agentops either, we use this when simulating an API later\n",
"import re # Regex for formatting\n",
"from dotenv import load_dotenv"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T19:59:59.531722Z",
- "iopub.execute_input": "2024-11-09T19:59:59.532140Z",
- "iopub.status.idle": "2024-11-09T20:00:00.316206Z",
- "shell.execute_reply.started": "2024-11-09T19:59:59.532101Z",
- "shell.execute_reply": "2024-11-09T20:00:00.315436Z"
- },
- "trusted": true
- },
- "execution_count": 4,
- "outputs": []
+ ]
},
{
"cell_type": "markdown",
- "source": "And set our API keys.",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "And set our API keys."
+ ]
},
{
"cell_type": "code",
- "source": "load_dotenv()\nANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\nAGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\"",
+ "execution_count": 5,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:00:02.860124Z",
"iopub.execute_input": "2024-11-09T20:00:02.860678Z",
+ "iopub.status.busy": "2024-11-09T20:00:02.860124Z",
"iopub.status.idle": "2024-11-09T20:00:02.866414Z",
- "shell.execute_reply.started": "2024-11-09T20:00:02.860635Z",
- "shell.execute_reply": "2024-11-09T20:00:02.865290Z"
+ "shell.execute_reply": "2024-11-09T20:00:02.865290Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:02.860635Z"
},
"trusted": true
},
- "execution_count": 5,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "load_dotenv()\n",
+ "ANTHROPIC_API_KEY = os.getenv(\"ANTHROPIC_API_KEY\") or \"ANTHROPIC API KEY\"\n",
+ "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\") or \"AGENTOPS API KEY\""
+ ]
},
{
"cell_type": "markdown",
- "source": "\nNow let's set the client as Anthropic and start an AgentOps session",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "\n",
+ "Now let's set the client as Anthropic and start an AgentOps session"
+ ]
},
{
"cell_type": "code",
- "source": "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool\"])",
- "metadata": {},
"execution_count": null,
- "outputs": []
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "agentops.init(AGENTOPS_API_KEY, default_tags=[\"anthropic-example-tool\"])"
+ ]
},
{
"cell_type": "code",
- "source": "client = Anthropic(api_key=ANTHROPIC_API_KEY)",
+ "execution_count": 6,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:00:05.338079Z",
"iopub.execute_input": "2024-11-09T20:00:05.338711Z",
+ "iopub.status.busy": "2024-11-09T20:00:05.338079Z",
"iopub.status.idle": "2024-11-09T20:00:05.354458Z",
- "shell.execute_reply.started": "2024-11-09T20:00:05.338647Z",
- "shell.execute_reply": "2024-11-09T20:00:05.353577Z"
+ "shell.execute_reply": "2024-11-09T20:00:05.353577Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:05.338647Z"
},
"trusted": true
},
- "execution_count": 6,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "client = Anthropic(api_key=ANTHROPIC_API_KEY)"
+ ]
},
{
"cell_type": "markdown",
- "source": "Let's create a dummy tool now! First off, let's create a list of companies for the system to choose from",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Let's create a dummy tool now! First off, let's create a list of companies for the system to choose from"
+ ]
},
{
"cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T20:00:08.563085Z",
+ "iopub.status.busy": "2024-11-09T20:00:08.562702Z",
+ "iopub.status.idle": "2024-11-09T20:00:08.569085Z",
+ "shell.execute_reply": "2024-11-09T20:00:08.568239Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:08.563049Z"
+ },
+ "trusted": true
+ },
+ "outputs": [],
"source": [
"Corpo = [\n",
" \"Kiroshi\",\n",
@@ -157,27 +159,32 @@
" \"Zetatech\",\n",
" \"Dynalar\",\n",
"]"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T20:00:08.562702Z",
- "iopub.execute_input": "2024-11-09T20:00:08.563085Z",
- "iopub.status.idle": "2024-11-09T20:00:08.569085Z",
- "shell.execute_reply.started": "2024-11-09T20:00:08.563049Z",
- "shell.execute_reply": "2024-11-09T20:00:08.568239Z"
- },
- "trusted": true
- },
- "execution_count": 9,
- "outputs": []
+ ]
},
{
"cell_type": "markdown",
- "source": "And now we create a DB! This could be anything from an .xml/.json to Postgres or MySQL! For our intent of a test, we will just include a dictionary.",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "And now we create a DB! This could be anything from an .xml/.json to Postgres or MySQL! For our intent of a test, we will just include a dictionary."
+ ]
},
{
"cell_type": "code",
+ "execution_count": 55,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T20:32:14.377597Z",
+ "iopub.status.busy": "2024-11-09T20:32:14.377202Z",
+ "iopub.status.idle": "2024-11-09T20:32:14.402830Z",
+ "shell.execute_reply": "2024-11-09T20:32:14.401893Z",
+ "shell.execute_reply.started": "2024-11-09T20:32:14.377561Z"
+ },
+ "jupyter": {
+ "source_hidden": true
+ },
+ "trusted": true
+ },
+ "outputs": [],
"source": [
"cyberware_list = [\n",
" {\n",
@@ -365,30 +372,32 @@
" \"stats\": {\"targeting_accuracy\": \"+20%\", \"analyze_speed\": \"+25%\"},\n",
" },\n",
"]"
- ],
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And finally we make build types! We will keep to 6 based off the Edgerunners anime! (Try guessing which archetype is who)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:32:14.377202Z",
- "iopub.execute_input": "2024-11-09T20:32:14.377597Z",
- "iopub.status.idle": "2024-11-09T20:32:14.402830Z",
- "shell.execute_reply.started": "2024-11-09T20:32:14.377561Z",
- "shell.execute_reply": "2024-11-09T20:32:14.401893Z"
+ "iopub.execute_input": "2024-11-09T20:00:14.285035Z",
+ "iopub.status.busy": "2024-11-09T20:00:14.284254Z",
+ "iopub.status.idle": "2024-11-09T20:00:14.291284Z",
+ "shell.execute_reply": "2024-11-09T20:00:14.290236Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:14.284994Z"
},
"jupyter": {
"source_hidden": true
},
"trusted": true
},
- "execution_count": 55,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "source": "And finally we make build types! We will keep to 6 based off the Edgerunners anime! (Try guessing which archetype is who)",
- "metadata": {}
- },
- {
- "cell_type": "code",
+ "outputs": [],
"source": [
"edgerunners_builds = [\n",
" {\n",
@@ -416,30 +425,32 @@
" \"description\": \"A build focused on enhancing team performance. Utilizing a mix of hacking and buffing skills, this strategist provides advantages in combat, ensuring that allies remain strong and focused during engagements.\",\n",
" },\n",
"]"
- ],
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now that that's done, we can make a function! We will take the input from the user; for this test, we can assume we will always get a proper corpo name. We have a two second wait to simulate an online API request"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:00:14.284254Z",
- "iopub.execute_input": "2024-11-09T20:00:14.285035Z",
- "iopub.status.idle": "2024-11-09T20:00:14.291284Z",
- "shell.execute_reply.started": "2024-11-09T20:00:14.284994Z",
- "shell.execute_reply": "2024-11-09T20:00:14.290236Z"
+ "iopub.execute_input": "2024-11-09T20:00:23.150097Z",
+ "iopub.status.busy": "2024-11-09T20:00:23.149239Z",
+ "iopub.status.idle": "2024-11-09T20:00:23.157206Z",
+ "shell.execute_reply": "2024-11-09T20:00:23.156013Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:23.150045Z"
},
"jupyter": {
"source_hidden": true
},
"trusted": true
},
- "execution_count": 11,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "source": "Now that that's done, we can make a function! We will take the input from the user; for this test, we can assume we will always get a proper corpo name. We have a two second wait to simulate an online API request",
- "metadata": {}
- },
- {
- "cell_type": "code",
+ "outputs": [],
"source": [
"def get_cyberware_by_creator(creator_name):\n",
" # Filter the items by creator name (case-insensitive)\n",
@@ -463,60 +474,67 @@
" final = f'Name: {returned_item[\"name\"]}, Creator: {returned_item[\"creator\"]}, Bio: {returned_item[\"bio\"]}, Stats: {returned_item[\"stats\"]}'\n",
"\n",
" return final"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T20:00:23.149239Z",
- "iopub.execute_input": "2024-11-09T20:00:23.150097Z",
- "iopub.status.idle": "2024-11-09T20:00:23.157206Z",
- "shell.execute_reply.started": "2024-11-09T20:00:23.150045Z",
- "shell.execute_reply": "2024-11-09T20:00:23.156013Z"
- },
- "jupyter": {
- "source_hidden": true
- },
- "trusted": true
- },
- "execution_count": 13,
- "outputs": []
+ ]
},
{
"cell_type": "code",
- "source": "get_cyberware_by_creator(\"Militech\")",
+ "execution_count": 14,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:00:29.288885Z",
"iopub.execute_input": "2024-11-09T20:00:29.289810Z",
+ "iopub.status.busy": "2024-11-09T20:00:29.288885Z",
"iopub.status.idle": "2024-11-09T20:00:31.298240Z",
- "shell.execute_reply.started": "2024-11-09T20:00:29.289769Z",
- "shell.execute_reply": "2024-11-09T20:00:31.297326Z"
+ "shell.execute_reply": "2024-11-09T20:00:31.297326Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:29.289769Z"
},
"trusted": true
},
- "execution_count": 14,
"outputs": [
{
- "execution_count": 14,
- "output_type": "execute_result",
"data": {
- "text/plain": "\"Name: Projectile Launch System, Creator: Militech, Bio: An arm-mounted cannon that allows the user to launch various types of projectiles, including grenades and explosive rounds., Stats: {'ammo_types': ['Explosive', 'Incendiary', 'EMP'], 'blast_radius': '3 meters'}\""
+ "text/plain": [
+ "\"Name: Projectile Launch System, Creator: Militech, Bio: An arm-mounted cannon that allows the user to launch various types of projectiles, including grenades and explosive rounds., Stats: {'ammo_types': ['Explosive', 'Incendiary', 'EMP'], 'blast_radius': '3 meters'}\""
+ ]
},
- "metadata": {}
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
}
+ ],
+ "source": [
+ "get_cyberware_by_creator(\"Militech\")"
]
},
{
"cell_type": "markdown",
- "source": "Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it!\n\nWe are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Now to the real core of this; making our message stream! We create this as a function we can call later! I create examples since the LLM's context size can handle it!\n",
+ "\n",
+ "We are also going to take several steps here; we must create an example of the tool being used as context. Next, we must add the generated lines to the messages list once done being generated. Finally, we will parse the text for the format we want and request another line"
+ ]
},
{
"cell_type": "markdown",
- "source": "Now we make a message!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Now we make a message!"
+ ]
},
{
"cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T20:00:34.415759Z",
+ "iopub.status.busy": "2024-11-09T20:00:34.415063Z",
+ "iopub.status.idle": "2024-11-09T20:00:34.426528Z",
+ "shell.execute_reply": "2024-11-09T20:00:34.425555Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:34.415719Z"
+ },
+ "trusted": true
+ },
+ "outputs": [],
"source": [
"# We make our history a separate block to be easier to add to and get a random build to begin\n",
"\n",
@@ -594,27 +612,37 @@
" \"content\": f\"Based on the user's build type and requested corporation, get a random item from the corporation and tell if it will be a good idea to use; {random_build['name']} - {random_build['description']}, Requested Coroporation is {random.choice(Corpo)}\",\n",
" },\n",
"]"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T20:00:34.415063Z",
- "iopub.execute_input": "2024-11-09T20:00:34.415759Z",
- "iopub.status.idle": "2024-11-09T20:00:34.426528Z",
- "shell.execute_reply.started": "2024-11-09T20:00:34.415719Z",
- "shell.execute_reply": "2024-11-09T20:00:34.425555Z"
- },
- "trusted": true
- },
- "execution_count": 15,
- "outputs": []
+ ]
},
{
"cell_type": "markdown",
- "source": "For now, this is where we will talk to the LLM! Stream on seems to have a few problems so we get the output as one chunk! ",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "For now, this is where we will talk to the LLM! Stream on seems to have a few problems so we get the output as one chunk! "
+ ]
},
{
"cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T20:00:38.500868Z",
+ "iopub.status.busy": "2024-11-09T20:00:38.500148Z",
+ "iopub.status.idle": "2024-11-09T20:00:41.670002Z",
+ "shell.execute_reply": "2024-11-09T20:00:41.669032Z",
+ "shell.execute_reply.started": "2024-11-09T20:00:38.500827Z"
+ },
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Message(id='msg_01Afykywq3GD2EoHaGGxujRy', content=[TextBlock(text=\"Certainly! Let's see what Zetatech has to offer for The Stealth Hacker build. I'll retrieve a random item from Zetatech and evaluate its suitability for your build.\", type='text'), ToolUseBlock(id='toolu_011JwtgPzy3a88NR1s9BmgNL', input={'creator': 'Zetatech'}, name='get_cyberware_by_creator', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=1206, output_tokens=109))\n"
+ ]
+ }
+ ],
"source": [
"response = client.messages.create(\n",
" max_tokens=5000,\n",
@@ -639,33 +667,37 @@
")\n",
"\n",
"print(response)"
- ],
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now to get the tool used! We know it will be used and can pretty much ignore the AI's text, still let's show it anyways! We are going to see if the tool name is called get_cyberware_by_creator (And we know it's going to %99 be there)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:00:38.500148Z",
- "iopub.execute_input": "2024-11-09T20:00:38.500868Z",
- "iopub.status.idle": "2024-11-09T20:00:41.670002Z",
- "shell.execute_reply.started": "2024-11-09T20:00:38.500827Z",
- "shell.execute_reply": "2024-11-09T20:00:41.669032Z"
+ "iopub.execute_input": "2024-11-09T20:23:38.711991Z",
+ "iopub.status.busy": "2024-11-09T20:23:38.711588Z",
+ "iopub.status.idle": "2024-11-09T20:23:40.718852Z",
+ "shell.execute_reply": "2024-11-09T20:23:40.718027Z",
+ "shell.execute_reply.started": "2024-11-09T20:23:38.711953Z"
},
"trusted": true
},
- "execution_count": 16,
"outputs": [
{
"name": "stdout",
- "text": "Message(id='msg_01Afykywq3GD2EoHaGGxujRy', content=[TextBlock(text=\"Certainly! Let's see what Zetatech has to offer for The Stealth Hacker build. I'll retrieve a random item from Zetatech and evaluate its suitability for your build.\", type='text'), ToolUseBlock(id='toolu_011JwtgPzy3a88NR1s9BmgNL', input={'creator': 'Zetatech'}, name='get_cyberware_by_creator', type='tool_use')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=1206, output_tokens=109))\n",
- "output_type": "stream"
+ "output_type": "stream",
+ "text": [
+ "[TextBlock(text=\"Certainly! Let's see what Zetatech has to offer for The Stealth Hacker build. I'll retrieve a random item from Zetatech and evaluate its suitability for your build.\", type='text'), ToolUseBlock(id='toolu_011JwtgPzy3a88NR1s9BmgNL', input={'creator': 'Zetatech'}, name='get_cyberware_by_creator', type='tool_use')]\n"
+ ]
}
- ]
- },
- {
- "cell_type": "markdown",
- "source": "Now to get the tool used! We know it will be used and can pretty much ignore the AI's text, still let's show it anyways! We are going to see if the tool name is called get_cyberware_by_creator (And we know it's going to %99 be there)",
- "metadata": {}
- },
- {
- "cell_type": "code",
+ ],
"source": [
"SearchResult = \"\"\n",
"\n",
@@ -686,58 +718,64 @@
"if tool_name == \"get_cyberware_by_creator\":\n",
" # Call the function with the tool creator as an argument\n",
" SearchResult = get_cyberware_by_creator(tool_creator)"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T20:23:38.711588Z",
- "iopub.execute_input": "2024-11-09T20:23:38.711991Z",
- "iopub.status.idle": "2024-11-09T20:23:40.718852Z",
- "shell.execute_reply.started": "2024-11-09T20:23:38.711953Z",
- "shell.execute_reply": "2024-11-09T20:23:40.718027Z"
- },
- "trusted": true
- },
- "execution_count": 47,
- "outputs": [
- {
- "name": "stdout",
- "text": "[TextBlock(text=\"Certainly! Let's see what Zetatech has to offer for The Stealth Hacker build. I'll retrieve a random item from Zetatech and evaluate its suitability for your build.\", type='text'), ToolUseBlock(id='toolu_011JwtgPzy3a88NR1s9BmgNL', input={'creator': 'Zetatech'}, name='get_cyberware_by_creator', type='tool_use')]\n",
- "output_type": "stream"
- }
]
},
{
"cell_type": "markdown",
- "source": "Now, we will add an item to the history and create our next request!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Now, we will add an item to the history and create our next request!"
+ ]
},
{
"cell_type": "code",
- "source": [
- "initialmessages.append({\"role\": \"assistant\", \"content\": SearchResult})\n",
- "\n",
- "initialmessages.append({\"role\": \"user\", \"content\": \"Is this a good match?\"})"
- ],
+ "execution_count": 49,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:24:59.776900Z",
"iopub.execute_input": "2024-11-09T20:24:59.777625Z",
+ "iopub.status.busy": "2024-11-09T20:24:59.776900Z",
"iopub.status.idle": "2024-11-09T20:24:59.782123Z",
- "shell.execute_reply.started": "2024-11-09T20:24:59.777585Z",
- "shell.execute_reply": "2024-11-09T20:24:59.781171Z"
+ "shell.execute_reply": "2024-11-09T20:24:59.781171Z",
+ "shell.execute_reply.started": "2024-11-09T20:24:59.777585Z"
},
"trusted": true
},
- "execution_count": 49,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "initialmessages.append({\"role\": \"assistant\", \"content\": SearchResult})\n",
+ "\n",
+ "initialmessages.append({\"role\": \"user\", \"content\": \"Is this a good match?\"})"
+ ]
},
{
"cell_type": "markdown",
- "source": "Now let's see if this is good!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Now let's see if this is good!"
+ ]
},
{
"cell_type": "code",
+ "execution_count": 50,
+ "metadata": {
+ "execution": {
+ "iopub.execute_input": "2024-11-09T20:25:02.863142Z",
+ "iopub.status.busy": "2024-11-09T20:25:02.862732Z",
+ "iopub.status.idle": "2024-11-09T20:25:12.630165Z",
+ "shell.execute_reply": "2024-11-09T20:25:12.629235Z",
+ "shell.execute_reply.started": "2024-11-09T20:25:02.863103Z"
+ },
+ "trusted": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Message(id='msg_01YWrpDbF475reehYXHNv7nE', content=[TextBlock(text='Yes, the Neofiber cyberware from Zetatech is an excellent match for The Stealth Hacker build you described. Let\\'s break down why:\\n\\n1. Alignment with build focus: The Stealth Hacker is described as a \"stealthy and agile build focused on evasion.\" The Neofiber directly enhances both stealth and agility aspects of this build.\\n\\n2. Evasion increase: The +10% evasion increase is particularly valuable for a character that aims to avoid detection and enemy attacks. This will make it easier to sneak past enemy lines and escape if spotted.\\n\\n3. Movement speed bonus: The +5% movement speed bonus complements the build\\'s agility focus. Faster movement allows for quicker repositioning, easier escapes, and more efficient navigation through complex environments during covert operations.\\n\\n4. Synergy with hacking: While this cyberware doesn\\'t directly enhance hacking abilities, the improved evasion and speed will help the character get into optimal positions for hacking operations and quickly retreat if necessary.\\n\\n5. Non-interference with stealth: Unlike some combat-focused cyberware that might be noisy or visually obvious, this muscle fiber enhancement is subtle and won\\'t compromise the character\\'s ability to remain undetected.\\n\\n6. Correct corporation: The item is from Zetatech, which matches the requested corporation.\\n\\nOverall, the Neofiber cyberware enhances the core aspects of The Stealth Hacker build - stealth, agility, and evasion. It will allow the character to move more quickly and avoid detection more effectively, which is crucial for an infiltrator focused on covert operations. This cyberware provides a solid foundation for the build, leaving room for additional hacking-specific augmentations to round out the character\\'s capabilities.', type='text')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=1385, output_tokens=408))\n"
+ ]
+ }
+ ],
"source": [
"response = client.messages.create(\n",
" max_tokens=5000,\n",
@@ -762,66 +800,103 @@
")\n",
"\n",
"print(response)"
- ],
- "metadata": {
- "execution": {
- "iopub.status.busy": "2024-11-09T20:25:02.862732Z",
- "iopub.execute_input": "2024-11-09T20:25:02.863142Z",
- "iopub.status.idle": "2024-11-09T20:25:12.630165Z",
- "shell.execute_reply.started": "2024-11-09T20:25:02.863103Z",
- "shell.execute_reply": "2024-11-09T20:25:12.629235Z"
- },
- "trusted": true
- },
- "execution_count": 50,
- "outputs": [
- {
- "name": "stdout",
- "text": "Message(id='msg_01YWrpDbF475reehYXHNv7nE', content=[TextBlock(text='Yes, the Neofiber cyberware from Zetatech is an excellent match for The Stealth Hacker build you described. Let\\'s break down why:\\n\\n1. Alignment with build focus: The Stealth Hacker is described as a \"stealthy and agile build focused on evasion.\" The Neofiber directly enhances both stealth and agility aspects of this build.\\n\\n2. Evasion increase: The +10% evasion increase is particularly valuable for a character that aims to avoid detection and enemy attacks. This will make it easier to sneak past enemy lines and escape if spotted.\\n\\n3. Movement speed bonus: The +5% movement speed bonus complements the build\\'s agility focus. Faster movement allows for quicker repositioning, easier escapes, and more efficient navigation through complex environments during covert operations.\\n\\n4. Synergy with hacking: While this cyberware doesn\\'t directly enhance hacking abilities, the improved evasion and speed will help the character get into optimal positions for hacking operations and quickly retreat if necessary.\\n\\n5. Non-interference with stealth: Unlike some combat-focused cyberware that might be noisy or visually obvious, this muscle fiber enhancement is subtle and won\\'t compromise the character\\'s ability to remain undetected.\\n\\n6. Correct corporation: The item is from Zetatech, which matches the requested corporation.\\n\\nOverall, the Neofiber cyberware enhances the core aspects of The Stealth Hacker build - stealth, agility, and evasion. It will allow the character to move more quickly and avoid detection more effectively, which is crucial for an infiltrator focused on covert operations. This cyberware provides a solid foundation for the build, leaving room for additional hacking-specific augmentations to round out the character\\'s capabilities.', type='text')], model='claude-3-5-sonnet-20240620', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=1385, output_tokens=408))\n",
- "output_type": "stream"
- }
]
},
{
"cell_type": "markdown",
- "source": "Now to display the output!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Now to display the output!"
+ ]
},
{
"cell_type": "code",
- "source": "message = response.content[0].text\nprint(message)",
+ "execution_count": 54,
"metadata": {
"execution": {
- "iopub.status.busy": "2024-11-09T20:30:57.591539Z",
"iopub.execute_input": "2024-11-09T20:30:57.591951Z",
+ "iopub.status.busy": "2024-11-09T20:30:57.591539Z",
"iopub.status.idle": "2024-11-09T20:30:57.597218Z",
- "shell.execute_reply.started": "2024-11-09T20:30:57.591906Z",
- "shell.execute_reply": "2024-11-09T20:30:57.596320Z"
+ "shell.execute_reply": "2024-11-09T20:30:57.596320Z",
+ "shell.execute_reply.started": "2024-11-09T20:30:57.591906Z"
},
"trusted": true
},
- "execution_count": 54,
"outputs": [
{
"name": "stdout",
- "text": "Yes, the Neofiber cyberware from Zetatech is an excellent match for The Stealth Hacker build you described. Let's break down why:\n\n1. Alignment with build focus: The Stealth Hacker is described as a \"stealthy and agile build focused on evasion.\" The Neofiber directly enhances both stealth and agility aspects of this build.\n\n2. Evasion increase: The +10% evasion increase is particularly valuable for a character that aims to avoid detection and enemy attacks. This will make it easier to sneak past enemy lines and escape if spotted.\n\n3. Movement speed bonus: The +5% movement speed bonus complements the build's agility focus. Faster movement allows for quicker repositioning, easier escapes, and more efficient navigation through complex environments during covert operations.\n\n4. Synergy with hacking: While this cyberware doesn't directly enhance hacking abilities, the improved evasion and speed will help the character get into optimal positions for hacking operations and quickly retreat if necessary.\n\n5. Non-interference with stealth: Unlike some combat-focused cyberware that might be noisy or visually obvious, this muscle fiber enhancement is subtle and won't compromise the character's ability to remain undetected.\n\n6. Correct corporation: The item is from Zetatech, which matches the requested corporation.\n\nOverall, the Neofiber cyberware enhances the core aspects of The Stealth Hacker build - stealth, agility, and evasion. It will allow the character to move more quickly and avoid detection more effectively, which is crucial for an infiltrator focused on covert operations. This cyberware provides a solid foundation for the build, leaving room for additional hacking-specific augmentations to round out the character's capabilities.\n",
- "output_type": "stream"
+ "output_type": "stream",
+ "text": [
+ "Yes, the Neofiber cyberware from Zetatech is an excellent match for The Stealth Hacker build you described. Let's break down why:\n",
+ "\n",
+ "1. Alignment with build focus: The Stealth Hacker is described as a \"stealthy and agile build focused on evasion.\" The Neofiber directly enhances both stealth and agility aspects of this build.\n",
+ "\n",
+ "2. Evasion increase: The +10% evasion increase is particularly valuable for a character that aims to avoid detection and enemy attacks. This will make it easier to sneak past enemy lines and escape if spotted.\n",
+ "\n",
+ "3. Movement speed bonus: The +5% movement speed bonus complements the build's agility focus. Faster movement allows for quicker repositioning, easier escapes, and more efficient navigation through complex environments during covert operations.\n",
+ "\n",
+ "4. Synergy with hacking: While this cyberware doesn't directly enhance hacking abilities, the improved evasion and speed will help the character get into optimal positions for hacking operations and quickly retreat if necessary.\n",
+ "\n",
+ "5. Non-interference with stealth: Unlike some combat-focused cyberware that might be noisy or visually obvious, this muscle fiber enhancement is subtle and won't compromise the character's ability to remain undetected.\n",
+ "\n",
+ "6. Correct corporation: The item is from Zetatech, which matches the requested corporation.\n",
+ "\n",
+ "Overall, the Neofiber cyberware enhances the core aspects of The Stealth Hacker build - stealth, agility, and evasion. It will allow the character to move more quickly and avoid detection more effectively, which is crucial for an infiltrator focused on covert operations. This cyberware provides a solid foundation for the build, leaving room for additional hacking-specific augmentations to round out the character's capabilities.\n"
+ ]
}
+ ],
+ "source": [
+ "message = response.content[0].text\n",
+ "print(message)"
]
},
{
"cell_type": "markdown",
- "source": "Run this to end the session!",
- "metadata": {}
+ "metadata": {},
+ "source": [
+ "Run this to end the session!"
+ ]
},
{
"cell_type": "code",
- "source": "agentops.end_session(\"Success\")",
+ "execution_count": null,
"metadata": {
"trusted": true
},
- "execution_count": null,
- "outputs": []
+ "outputs": [],
+ "source": [
+ "agentops.end_session(\"Success\")"
+ ]
+ }
+ ],
+ "metadata": {
+ "kaggle": {
+ "accelerator": "gpu",
+ "dataSources": [],
+ "dockerImageVersionId": 30786,
+ "isGpuEnabled": true,
+ "isInternetEnabled": true,
+ "language": "python",
+ "sourceType": "notebook"
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.10.14"
}
- ]
-}
\ No newline at end of file
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
diff --git a/examples/multi_session_llm.ipynb b/examples/multi_session_llm.ipynb
index 87c980bb..e12d7bde 100644
--- a/examples/multi_session_llm.ipynb
+++ b/examples/multi_session_llm.ipynb
@@ -292,14 +292,6 @@
"source": [
"If you look in the AgentOps dashboard for these sessions, you will see two unique sessions, both with one LLM Event each, one with an Action Event as well."
]
- },
- {
- "cell_type": "markdown",
- "id": "dbc7483434f8c147",
- "metadata": {
- "collapsed": false
- },
- "source": []
}
],
"metadata": {
diff --git a/examples/openai_examples/openai_example_async.ipynb b/examples/openai_examples/openai_example_async.ipynb
index 2576ea70..79ab76d2 100644
--- a/examples/openai_examples/openai_example_async.ipynb
+++ b/examples/openai_examples/openai_example_async.ipynb
@@ -107,7 +107,8 @@
"user_prompt = [\n",
" {\n",
" \"type\": \"text\",\n",
- " \"text\": \"Write a mystery thriller story based on your understanding of the provided image.\"},\n",
+ " \"text\": \"Write a mystery thriller story based on your understanding of the provided image.\"\n",
+ " },\n",
" {\n",
" \"type\": \"image_url\",\n",
" \"image_url\": {\"url\": f\"https://www.cosy.sbg.ac.at/~pmeerw/Watermarking/lena_color.gif\"},\n",