From 1f925feebb4b437432e49e6b876ccfdb80a19ed9 Mon Sep 17 00:00:00 2001 From: Soo Date: Thu, 4 Jul 2024 11:25:36 -0700 Subject: [PATCH 1/6] Rounds up to nearest 100, makes script elegante suck it mint growth plan, I did it my damn self --- docs/v1/integrations/autogen.mdx | 17 +---------------- docs/v1/integrations/cohere.mdx | 17 +---------------- docs/v1/integrations/crewai.mdx | 17 +---------------- docs/v1/integrations/langchain.mdx | 8 ++++---- docs/v1/integrations/litellm.mdx | 19 +++---------------- docs/v1/stars.js | 14 ++++++++++++++ 6 files changed, 24 insertions(+), 68 deletions(-) create mode 100644 docs/v1/stars.js diff --git a/docs/v1/integrations/autogen.mdx b/docs/v1/integrations/autogen.mdx index 0b7fe745..cae332f7 100644 --- a/docs/v1/integrations/autogen.mdx +++ b/docs/v1/integrations/autogen.mdx @@ -80,19 +80,4 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/integrations/cohere.mdx b/docs/v1/integrations/cohere.mdx index 0d417431..ea733b62 100644 --- a/docs/v1/integrations/cohere.mdx +++ b/docs/v1/integrations/cohere.mdx @@ -115,19 +115,4 @@ This is a living integration. Should you need any added functionality message us ``` - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/integrations/crewai.mdx b/docs/v1/integrations/crewai.mdx index af6faef2..bc11526f 100644 --- a/docs/v1/integrations/crewai.mdx +++ b/docs/v1/integrations/crewai.mdx @@ -106,19 +106,4 @@ agentops.init(skip_auto_end_session=True) - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/integrations/langchain.mdx b/docs/v1/integrations/langchain.mdx index 6fef2008..dcaa216a 100644 --- a/docs/v1/integrations/langchain.mdx +++ b/docs/v1/integrations/langchain.mdx @@ -19,9 +19,7 @@ AgentOps works seamlessly with applications built using Langchain. poetry add agentops[langchain] ``` - - [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊) - + [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊) Import the following Langchain and AgentOps dependencies @@ -107,4 +105,6 @@ AgentOps works seamlessly with applications built using Langchain. callbacks=[handler], # You must pass in a callback handler to record your agent handle_parsing_errors=True) ``` - \ No newline at end of file + + + \ No newline at end of file diff --git a/docs/v1/integrations/litellm.mdx b/docs/v1/integrations/litellm.mdx index 57e3b968..21574b7a 100644 --- a/docs/v1/integrations/litellm.mdx +++ b/docs/v1/integrations/litellm.mdx @@ -17,6 +17,8 @@ Call 100+ LLMs using the same Input/Output Format LiteLLM also supports many [providers](https://docs.litellm.ai/docs/providers) +[Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊) + ## Using AgentOps with LiteLLM ### Requires litellm>=1.3.1 @@ -38,19 +40,4 @@ response = await litellm.acompletion(model="claude-3", messages=messages) ``` - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/stars.js b/docs/v1/stars.js new file mode 100644 index 00000000..021248f3 --- /dev/null +++ b/docs/v1/stars.js @@ -0,0 +1,14 @@ +window.addEventListener('load', function() { + fetch("https://api.github.com/repos/AgentOps-AI/agentops") + .then((response) => response.json()) + .then((data) => { + const stars = Math.ceil(data.stargazers_count / 100) * 100 + 100; + const dataContainer = document.getElementById("stars-text"); + dataContainer.innerHTML = `${stars.toLocaleString()}th`; + + }) + .catch((error) => { + console.error("Error:", error); + document.getElementById("stars-text").textContent = 'Error loading data.'; + }); +}) \ No newline at end of file From 1ec0fab98ffe6a37996fb9604040054764198f43 Mon Sep 17 00:00:00 2001 From: Soo Date: Thu, 4 Jul 2024 11:38:32 -0700 Subject: [PATCH 2/6] mild file struct change to accommodate more scripts --- docs/v1/integrations/autogen.mdx | 3 ++- docs/v1/integrations/cohere.mdx | 3 ++- docs/v1/integrations/crewai.mdx | 3 ++- docs/v1/integrations/langchain.mdx | 3 ++- docs/v1/integrations/litellm.mdx | 3 ++- docs/v1/scripts/display_api_dynamically.js | 0 docs/v1/{ => scripts}/stars.js | 0 7 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 docs/v1/scripts/display_api_dynamically.js rename docs/v1/{ => scripts}/stars.js (100%) diff --git a/docs/v1/integrations/autogen.mdx b/docs/v1/integrations/autogen.mdx index cae332f7..e15b5d85 100644 --- a/docs/v1/integrations/autogen.mdx +++ b/docs/v1/integrations/autogen.mdx @@ -80,4 +80,5 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/integrations/cohere.mdx b/docs/v1/integrations/cohere.mdx index ea733b62..058d847f 100644 --- a/docs/v1/integrations/cohere.mdx +++ b/docs/v1/integrations/cohere.mdx @@ -115,4 +115,5 @@ This is a living integration. Should you need any added functionality message us ``` - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/integrations/crewai.mdx b/docs/v1/integrations/crewai.mdx index bc11526f..1d8130af 100644 --- a/docs/v1/integrations/crewai.mdx +++ b/docs/v1/integrations/crewai.mdx @@ -106,4 +106,5 @@ agentops.init(skip_auto_end_session=True) - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/integrations/langchain.mdx b/docs/v1/integrations/langchain.mdx index dcaa216a..411344ba 100644 --- a/docs/v1/integrations/langchain.mdx +++ b/docs/v1/integrations/langchain.mdx @@ -107,4 +107,5 @@ AgentOps works seamlessly with applications built using Langchain. ``` - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/integrations/litellm.mdx b/docs/v1/integrations/litellm.mdx index 21574b7a..ac8ded4b 100644 --- a/docs/v1/integrations/litellm.mdx +++ b/docs/v1/integrations/litellm.mdx @@ -40,4 +40,5 @@ response = await litellm.acompletion(model="claude-3", messages=messages) ``` - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/scripts/display_api_dynamically.js b/docs/v1/scripts/display_api_dynamically.js new file mode 100644 index 00000000..e69de29b diff --git a/docs/v1/stars.js b/docs/v1/scripts/stars.js similarity index 100% rename from docs/v1/stars.js rename to docs/v1/scripts/stars.js From 32f388df628fe818fe46ec02a819312d24a54cbb Mon Sep 17 00:00:00 2001 From: Soo Date: Thu, 4 Jul 2024 13:31:57 -0700 Subject: [PATCH 3/6] handling dynamic adjustments on all pages --- docs/v1/concepts/core-concepts.mdx | 3 ++ docs/v1/concepts/decorators.mdx | 3 ++ docs/v1/concepts/events.mdx | 3 ++ docs/v1/concepts/host-env.mdx | 5 +++- docs/v1/concepts/sessions.mdx | 5 +++- docs/v1/concepts/tags.mdx | 5 +++- docs/v1/examples.mdx | 3 ++ docs/v1/integrations/autogen.mdx | 4 +-- docs/v1/integrations/cohere.mdx | 2 +- docs/v1/integrations/crewai.mdx | 2 +- docs/v1/integrations/langchain.mdx | 4 +-- docs/v1/integrations/litellm.mdx | 2 +- docs/v1/introduction.mdx | 18 ++---------- docs/v1/quickstart.mdx | 18 ++---------- ...namically.js => adjust_api_dynamically.js} | 0 docs/v1/scripts/stars.js | 28 ++++++++++++++----- docs/v1/usage/environment-variables.mdx | 5 +++- docs/v1/usage/langchain-callback-handler.mdx | 5 +++- docs/v1/usage/recording-events.mdx | 3 ++ docs/v1/usage/sdk-reference.mdx | 5 +++- docs/v1/usage/tracking-agents.mdx | 3 ++ docs/v1/usage/tracking-llm-calls.mdx | 3 ++ 22 files changed, 77 insertions(+), 52 deletions(-) rename docs/v1/scripts/{display_api_dynamically.js => adjust_api_dynamically.js} (100%) diff --git a/docs/v1/concepts/core-concepts.mdx b/docs/v1/concepts/core-concepts.mdx index 31d4bb6c..5272a05c 100644 --- a/docs/v1/concepts/core-concepts.mdx +++ b/docs/v1/concepts/core-concepts.mdx @@ -91,3 +91,6 @@ Optionally, agents may also have: ### Threads *Details coming soon.* + + + \ No newline at end of file diff --git a/docs/v1/concepts/decorators.mdx b/docs/v1/concepts/decorators.mdx index ad475993..8722dcd1 100644 --- a/docs/v1/concepts/decorators.mdx +++ b/docs/v1/concepts/decorators.mdx @@ -21,3 +21,6 @@ Sometimes your agent system will use functions that are important to track as [` Adding this decorator above any function will allow every instance of that function call to be tracked and displayed in your [Session](v1/concepts/sessions) Drill-Down on the dashboard. + + + \ No newline at end of file diff --git a/docs/v1/concepts/events.mdx b/docs/v1/concepts/events.mdx index 38d51b79..0400f4f5 100644 --- a/docs/v1/concepts/events.mdx +++ b/docs/v1/concepts/events.mdx @@ -105,3 +105,6 @@ def scrape_website(url: str): record(tool_event) ``` + + + \ No newline at end of file diff --git a/docs/v1/concepts/host-env.mdx b/docs/v1/concepts/host-env.mdx index 6be89111..0fe749f9 100644 --- a/docs/v1/concepts/host-env.mdx +++ b/docs/v1/concepts/host-env.mdx @@ -29,4 +29,7 @@ AgentOps users can opt out of certain environment data collection by setting the AGENTOPS_ENV_DATA_OPT_OUT=True ``` -For more questions on privacy and data usage, please [send us an email](mailto:alex@agentops.ai) \ No newline at end of file +For more questions on privacy and data usage, please [send us an email](mailto:alex@agentops.ai) + + + \ No newline at end of file diff --git a/docs/v1/concepts/sessions.mdx b/docs/v1/concepts/sessions.mdx index 6f53eac8..c0db77d3 100644 --- a/docs/v1/concepts/sessions.mdx +++ b/docs/v1/concepts/sessions.mdx @@ -69,4 +69,7 @@ _More info for the curious_ Under the hood, `agentops.init()` sets up a `Client` object with various configuration options like your API key, worker thread options for when to send out batches of events, etc. Whenever you start a new session, these configuration options will automatically be applied. You can also apply different configuration options when you start a new session by passing in a -[Configuration](/v1/usage/sdk-reference/#configuration) object. \ No newline at end of file +[Configuration](/v1/usage/sdk-reference/#configuration) object. + + + \ No newline at end of file diff --git a/docs/v1/concepts/tags.mdx b/docs/v1/concepts/tags.mdx index e3f405a8..751f7ec4 100644 --- a/docs/v1/concepts/tags.mdx +++ b/docs/v1/concepts/tags.mdx @@ -50,4 +50,7 @@ agentops.add_tags(['appended tag']) ## Session Drill-down 1. Click the session selector button 2. In the session selector, click "Tags" -3. Choose what tags to search by \ No newline at end of file +3. Choose what tags to search by + + + \ No newline at end of file diff --git a/docs/v1/examples.mdx b/docs/v1/examples.mdx index 63d9d79f..fa61e84a 100644 --- a/docs/v1/examples.mdx +++ b/docs/v1/examples.mdx @@ -41,3 +41,6 @@ mode: "wide" ![thumbnail](https://cdn.loom.com/sessions/thumbnails/679d65cc06f148299e8dffc459d053ab-with-play.gif) + + + \ No newline at end of file diff --git a/docs/v1/integrations/autogen.mdx b/docs/v1/integrations/autogen.mdx index e15b5d85..6d6f2eec 100644 --- a/docs/v1/integrations/autogen.mdx +++ b/docs/v1/integrations/autogen.mdx @@ -19,7 +19,7 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do poetry add agentops ``` - Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊) + [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊) @@ -81,4 +81,4 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/integrations/cohere.mdx b/docs/v1/integrations/cohere.mdx index 058d847f..87210186 100644 --- a/docs/v1/integrations/cohere.mdx +++ b/docs/v1/integrations/cohere.mdx @@ -116,4 +116,4 @@ This is a living integration. Should you need any added functionality message us - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/integrations/crewai.mdx b/docs/v1/integrations/crewai.mdx index 1d8130af..ae7797b1 100644 --- a/docs/v1/integrations/crewai.mdx +++ b/docs/v1/integrations/crewai.mdx @@ -107,4 +107,4 @@ agentops.init(skip_auto_end_session=True) - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/integrations/langchain.mdx b/docs/v1/integrations/langchain.mdx index 411344ba..b0b5ff1c 100644 --- a/docs/v1/integrations/langchain.mdx +++ b/docs/v1/integrations/langchain.mdx @@ -85,7 +85,7 @@ AgentOps works seamlessly with applications built using Langchain. ## Full Examples - + ```python python import os from langchain.chat_models import ChatOpenAI @@ -108,4 +108,4 @@ AgentOps works seamlessly with applications built using Langchain. - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/integrations/litellm.mdx b/docs/v1/integrations/litellm.mdx index ac8ded4b..b0efde27 100644 --- a/docs/v1/integrations/litellm.mdx +++ b/docs/v1/integrations/litellm.mdx @@ -41,4 +41,4 @@ response = await litellm.acompletion(model="claude-3", messages=messages) ``` - \ No newline at end of file + \ No newline at end of file diff --git a/docs/v1/introduction.mdx b/docs/v1/introduction.mdx index f687757f..2a901521 100644 --- a/docs/v1/introduction.mdx +++ b/docs/v1/introduction.mdx @@ -67,19 +67,5 @@ View a meta-analysis of all of your sessions in a single view. - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/quickstart.mdx b/docs/v1/quickstart.mdx index 5e7c70b6..11c5a236 100644 --- a/docs/v1/quickstart.mdx +++ b/docs/v1/quickstart.mdx @@ -154,19 +154,5 @@ agentops.end_session('Success') - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/scripts/display_api_dynamically.js b/docs/v1/scripts/adjust_api_dynamically.js similarity index 100% rename from docs/v1/scripts/display_api_dynamically.js rename to docs/v1/scripts/adjust_api_dynamically.js diff --git a/docs/v1/scripts/stars.js b/docs/v1/scripts/stars.js index 021248f3..6b8e6b5c 100644 --- a/docs/v1/scripts/stars.js +++ b/docs/v1/scripts/stars.js @@ -1,14 +1,28 @@ -window.addEventListener('load', function() { +function updateStars() { fetch("https://api.github.com/repos/AgentOps-AI/agentops") .then((response) => response.json()) .then((data) => { const stars = Math.ceil(data.stargazers_count / 100) * 100 + 100; - const dataContainer = document.getElementById("stars-text"); - dataContainer.innerHTML = `${stars.toLocaleString()}th`; - + setTimeout(() => { + const dataContainer = document.getElementById("stars-text"); + dataContainer.innerHTML = `${stars.toLocaleString()}th`; + }, 50); }) .catch((error) => { - console.error("Error:", error); - document.getElementById("stars-text").textContent = 'Error loading data.'; + // console.error("Github Stars pull error:", error); + }); +} + +function addNewEventListeners() { + setTimeout(() => { + document.querySelectorAll('li, a').forEach(element => { + element.addEventListener('click', updateStars); }); -}) \ No newline at end of file + }, 50); +} + +window.addEventListener('load', function() { + updateStars(); + const observer = new MutationObserver(addNewEventListeners); + observer.observe(document.body, { childList: true, subtree: true }); +}); \ No newline at end of file diff --git a/docs/v1/usage/environment-variables.mdx b/docs/v1/usage/environment-variables.mdx index 1b1e82c7..5b724a0d 100644 --- a/docs/v1/usage/environment-variables.mdx +++ b/docs/v1/usage/environment-variables.mdx @@ -24,4 +24,7 @@ AGENTOPS_API_ENDPOINT=https://api.agentops.ai AGENTOPS_LOGGING_LEVEL=INFO # Whether to opt out of recording environment data. . Defaults to FALSE AGENTOPS_ENV_DATA_OPT_OUT=FALSE -``` \ No newline at end of file +``` + + + \ 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 eeedcf60..2e719d06 100644 --- a/docs/v1/usage/langchain-callback-handler.mdx +++ b/docs/v1/usage/langchain-callback-handler.mdx @@ -65,4 +65,7 @@ response = chain.invoke({"animal": "bears"}) If your project uses Langchain for Agents, Events and Tools, it may be easier to use the callback Handler for observability. -If your project uses models with Langchain that are not yet supported by AgentOps, they can be supported by the Handler. \ No newline at end of file +If your project uses models with Langchain that are not yet supported by AgentOps, they can be supported by the Handler. + + + \ No newline at end of file diff --git a/docs/v1/usage/recording-events.mdx b/docs/v1/usage/recording-events.mdx index 3a363964..abbdf8af 100644 --- a/docs/v1/usage/recording-events.mdx +++ b/docs/v1/usage/recording-events.mdx @@ -33,3 +33,6 @@ Record any child of the [Event type](/v1/concepts/events) or ErrorEvent. from agentops import record, ActionEvent record(ActionEvent("event_type1")) ``` + + + \ No newline at end of file diff --git a/docs/v1/usage/sdk-reference.mdx b/docs/v1/usage/sdk-reference.mdx index a5982870..6b1e9008 100644 --- a/docs/v1/usage/sdk-reference.mdx +++ b/docs/v1/usage/sdk-reference.mdx @@ -151,4 +151,7 @@ Stores the configuration settings for AgentOps clients. [Reference](/v1/usage/langchain-callback-handler) This callback handler is intended to be used as an option in place of AgentOps auto-instrumenting. This is only useful -when using Langchain as your LLM calling library. \ No newline at end of file +when using Langchain as your LLM calling library. + + + \ No newline at end of file diff --git a/docs/v1/usage/tracking-agents.mdx b/docs/v1/usage/tracking-agents.mdx index 88b0b84a..47485cd3 100644 --- a/docs/v1/usage/tracking-agents.mdx +++ b/docs/v1/usage/tracking-agents.mdx @@ -22,3 +22,6 @@ class MyAgent: `trackagent.name` is optional.

If omitted, agent name defaults to the name of the class (e.g. MyAgent).

If an event does not originate from a tracked agent, agent name defaults to "Default Agent". + + + \ 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 b2e30b05..740a0030 100644 --- a/docs/v1/usage/tracking-llm-calls.mdx +++ b/docs/v1/usage/tracking-llm-calls.mdx @@ -26,3 +26,6 @@ To get started, just follow the quick start guide. Get started with AgentOps in under 5 minutes + + + \ No newline at end of file From efea4442e4bb303b3ad4564f81f0c43fd361a511 Mon Sep 17 00:00:00 2001 From: Soo Date: Thu, 4 Jul 2024 15:27:13 -0700 Subject: [PATCH 4/6] API Key dynamic (pending endpoint) Fixes #272 --- docs/v1/integrations/autogen.mdx | 34 +++++---- docs/v1/integrations/cohere.mdx | 90 ++++++++++++----------- docs/v1/integrations/crewai.mdx | 34 +++++---- docs/v1/integrations/langchain.mdx | 38 +++++----- docs/v1/introduction.mdx | 14 ++-- docs/v1/quickstart.mdx | 32 ++++---- docs/v1/scripts/adjust_api_dynamically.js | 64 ++++++++++++++++ docs/v1/scripts/stars.js | 18 +++-- docs/v1/usage/environment-variables.mdx | 8 +- 9 files changed, 213 insertions(+), 119 deletions(-) diff --git a/docs/v1/integrations/autogen.mdx b/docs/v1/integrations/autogen.mdx index 6d6f2eec..cd14ab5f 100644 --- a/docs/v1/integrations/autogen.mdx +++ b/docs/v1/integrations/autogen.mdx @@ -34,18 +34,20 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do 1. Before setting up anything in Autogen, call `agentops.init()` 2. At the end of your agent run, call `agentops.end_session("Success")` - - ```python python - import agentops +
+ + ```python python + import agentops - # Beginning of program (i.e. main.py, __init__.py) - # IMPORTANT: Must be before using any autogen setup - agentops.init() - ... - # End of program (e.g. main.py) - agentops.end_session("Success") # Success|Fail|Indeterminate - ``` - + # Beginning of program (i.e. main.py, __init__.py) + # IMPORTANT: Must be before using any autogen setup + agentops.init() + ... + # End of program (e.g. main.py) + agentops.end_session("Success") # Success|Fail|Indeterminate + ``` + +
Instantiating the AgentOps client will automatically instrument Autogen, meaning you will be able to see all of your sessions on the AgentOps Dashboard along with the full LLM chat histories, cost, token counts, etc. @@ -63,10 +65,12 @@ Autogen has comprehensive [documentation](https://microsoft.github.io/autogen/do API keys are tied to individual projects.

A Default Project has been created for you, so just click Copy API Key - Set this API Key in your [environment variables](/v1/usage/environment-variables) - ```python .env - AGENTOPS_API_KEY= - ``` +
+ Set this API Key in your [environment variables](/v1/usage/environment-variables) + ```python .env + AGENTOPS_API_KEY= + ``` +
Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Autogen Agent! 🕵️ diff --git a/docs/v1/integrations/cohere.mdx b/docs/v1/integrations/cohere.mdx index 87210186..891032a7 100644 --- a/docs/v1/integrations/cohere.mdx +++ b/docs/v1/integrations/cohere.mdx @@ -25,19 +25,21 @@ This is a living integration. Should you need any added functionality message us [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub while you're at it (you may be our 2,000th 😊) - - ```python python - import agentops - - # Beginning of program (i.e. main.py, __init__.py) - # IMPORTANT: Must be before calling `co = cohere.Client()` - agentops.init() - co = cohere.Client() - ... - # End of program (e.g. main.py) - agentops.end_session("Success") # Success|Fail|Indeterminate - ``` - +
+ + ```python python + import agentops + + # Beginning of program (i.e. main.py, __init__.py) + # IMPORTANT: Must be before calling `co = cohere.Client()` + agentops.init() + co = cohere.Client() + ... + # End of program (e.g. main.py) + agentops.end_session("Success") # Success|Fail|Indeterminate + ``` + +
Requires cohere>=5.4.0 @@ -59,9 +61,11 @@ This is a living integration. Should you need any added functionality message us A Default Project has been created for you, so just click Copy API Key Set this API Key in your [environment variables](/v1/usage/environment-variables) - ```python .env - AGENTOPS_API_KEY= - ``` +
+ ```python .env + AGENTOPS_API_KEY= + ``` +
Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Agents! 🕵️ @@ -77,43 +81,45 @@ This is a living integration. Should you need any added functionality message us ## Full Examples - - ```python chat() - import cohere - import agentops +
+ + ```python chat() + import cohere + import agentops - agentops.init() + agentops.init() - co = cohere.Client() + co = cohere.Client() - chat = co.chat( - message="Is it pronounced ceaux-hear or co-hehray?" - ) + chat = co.chat( + message="Is it pronounced ceaux-hear or co-hehray?" + ) - print(chat) + print(chat) - agentops.end_session('Success') - ``` + agentops.end_session('Success') + ``` - ```python chat_stream() - import cohere - import agentops + ```python chat_stream() + import cohere + import agentops - agentops.init() + agentops.init() - co = cohere.Client() + co = cohere.Client() - stream = co.chat_stream( - message="Write me a haiku about the synergies between Cohere and AgentOps" - ) + stream = co.chat_stream( + message="Write me a haiku about the synergies between Cohere and AgentOps" + ) - for event in stream: - if event.event_type == "text-generation": - print(event.text, end='') + for event in stream: + if event.event_type == "text-generation": + print(event.text, end='') - agentops.end_session('Success') - ``` - + agentops.end_session('Success') + ``` + +
\ No newline at end of file diff --git a/docs/v1/integrations/crewai.mdx b/docs/v1/integrations/crewai.mdx index ae7797b1..c8acdb2e 100644 --- a/docs/v1/integrations/crewai.mdx +++ b/docs/v1/integrations/crewai.mdx @@ -44,18 +44,20 @@ Crew has comprehensive [documentation](https://docs.crewai.com) available as wel 1. Before calling the `Crew()` constructor in your code, call `agentops.init()` 2. At the end of your Crew run, call `agentops.end_session("Success")` - - ```python python - import agentops +
+ + ```python python + import agentops - # Beginning of program (i.e. main.py, __init__.py) - # IMPORTANT: Must be before calling the `Crew()` constructor - agentops.init() - ... - # End of program (e.g. main.py) - agentops.end_session("Success") # Success|Fail|Indeterminate - ``` - + # Beginning of program (i.e. main.py, __init__.py) + # IMPORTANT: Must be before calling the `Crew()` constructor + agentops.init() + ... + # End of program (e.g. main.py) + agentops.end_session("Success") # Success|Fail|Indeterminate + ``` + +
Instantiating the AgentOps client will automatically instrument Crew, meaning you will be able to see all of your sessions on the AgentOps Dashboard along with the full LLM chat histories, cost, token counts, etc. @@ -73,10 +75,12 @@ Crew has comprehensive [documentation](https://docs.crewai.com) available as wel API keys are tied to individual projects.

A Default Project has been created for you, so just click Copy API Key - Set this API Key in your [environment variables](/v1/usage/environment-variables) - ```python .env - AGENTOPS_API_KEY= - ``` +
+ Set this API Key in your [environment variables](/v1/usage/environment-variables) + ```python .env + AGENTOPS_API_KEY= + ``` +
Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Crew! 🕵️ diff --git a/docs/v1/integrations/langchain.mdx b/docs/v1/integrations/langchain.mdx index b0b5ff1c..bfb8d69d 100644 --- a/docs/v1/integrations/langchain.mdx +++ b/docs/v1/integrations/langchain.mdx @@ -37,22 +37,24 @@ AgentOps works seamlessly with applications built using Langchain. Set up your Langchain agent with the AgentOps callback handler and AgentOps will automatically record your Langchain sessions. - - ```python python - handler = LangchainCallbackHandler(api_key=AGENTOPS_API_KEY, tags=['Langchain Example']) +
+ + ```python python + handler = LangchainCallbackHandler(api_key=AGENTOPS_API_KEY, tags=['Langchain Example']) - llm = ChatOpenAI(openai_api_key=OPENAI_API_KEY, - callbacks=[handler], - model='gpt-3.5-turbo') + llm = ChatOpenAI(openai_api_key=OPENAI_API_KEY, + callbacks=[handler], + model='gpt-3.5-turbo') - agent = initialize_agent(tools, - llm, - agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, - verbose=True, - callbacks=[handler], # You must pass in a callback handler to record your agent - handle_parsing_errors=True) - ``` - + agent = initialize_agent(tools, + llm, + agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, + verbose=True, + callbacks=[handler], # You must pass in a callback handler to record your agent + handle_parsing_errors=True) + ``` + +
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. @@ -67,9 +69,11 @@ AgentOps works seamlessly with applications built using Langchain. A Default Project has been created for you, so just click Copy API Key Set this API Key in your [environment variables](/v1/usage/environment-variables) - ```python .env - AGENTOPS_API_KEY= - ``` +
+ ```python .env + AGENTOPS_API_KEY= + ``` +
Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Langchain Agent! 🕵️ diff --git a/docs/v1/introduction.mdx b/docs/v1/introduction.mdx index 2a901521..7a88f9ac 100644 --- a/docs/v1/introduction.mdx +++ b/docs/v1/introduction.mdx @@ -22,12 +22,14 @@ mode: "wide" And we do it all in just two lines of code... - - ```python python - import agentops - agentops.init() - ``` - +
+ + ```python python + import agentops + agentops.init() + ``` + +
... that logs everything back to your AgentOps Dashboard. ## The AgentOps Dashboard diff --git a/docs/v1/quickstart.mdx b/docs/v1/quickstart.mdx index 11c5a236..e033a852 100644 --- a/docs/v1/quickstart.mdx +++ b/docs/v1/quickstart.mdx @@ -16,16 +16,18 @@ import SupportedModels from '/snippets/supported-models.mdx'
- - ```python python - import agentops - - # Beginning of program (i.e. main.py, __init__.py) - # IMPORTANT: Must be before any OpenAI, Cohere, Crew, etc constructors are called - # e.g. before client = OpenAI(...) - agentops.init() - ``` - +
+ + ```python python + import agentops + + # Beginning of program (i.e. main.py, __init__.py) + # IMPORTANT: Must be before any OpenAI, Cohere, Crew, etc constructors are called + # e.g. before client = OpenAI(...) + agentops.init() + ``` + +
Just these two lines and you have magically tracked LLM calls! After the `openai`, `cohere`, or `litellm` packages have been imported, importing + instantiating the AgentOps client @@ -45,9 +47,11 @@ import SupportedModels from '/snippets/supported-models.mdx' A Default Project has been created for you, so just click Copy API Key Set this API Key in your [environment variables](/v1/usage/environment-variables) - ```python .env - AGENTOPS_API_KEY= - ``` +
+ ```python .env + AGENTOPS_API_KEY= + ``` +
Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your Agent! 🕵️ @@ -106,6 +110,7 @@ import SupportedModels from '/snippets/supported-models.mdx' Here is the complete code from the sections above +
```python python import openai import agentops @@ -126,6 +131,7 @@ class sample_agent(...): # End of program agentops.end_session('Success') ``` +
response.json()) + .then((data) => { + const apiKey = data.apiKey; + patternFindAndAdjust(apiKey); + if (!data.hasKey) { + // no API key, new rate-limited one is generated by endpoint? + // option to display a notice that the API key is rate-limited here? + + } + }) + .catch((error) => { + // console.error("API Key pull error:", error); + // just for testing, comment out later + const apiKey = "BOOGLYWOOGLY"; + patternFindAndAdjust(apiKey); + }); +} + +function patternFindAndAdjust(apiKey) { + const elementsWithPatterns = Array.from(document.getElementsByClassName("adjust-api-key")); + + const apiKeyPattern = /AGENTOPS_API_KEY/g; + const tokenOperatorPattern1 = /<<\/span>YOUR API KEY><\/span>/g; + const tokenOperatorPattern2 = /<<\/span>INSERT YOUR API KEY HERE><\/span>/g; + + // Process the collected elements + elementsWithPatterns.forEach(element => { + console.log(element.textContent) + const containsApiKeyPattern = element.textContent.includes("AGENTOPS_API_KEY"); + const containsTokenOperatorPattern1 = element.textContent.includes(""); + const containsTokenOperatorPattern2 = element.textContent.includes(""); + + if (containsTokenOperatorPattern1 || containsTokenOperatorPattern2) { + element.innerHTML = element.innerHTML.replace(tokenOperatorPattern1, apiKey).replace(tokenOperatorPattern2, apiKey); + } else if (containsApiKeyPattern) { + element.innerHTML = element.innerHTML.replace(apiKeyPattern, apiKey); + } + element.className = "adjusted-api-key"; + }); +} + +// Note that functions cannot be named the same thing across script files if copy-pasting this to add new scripts +function addAPIEventListeners() { // would change to button + console.log("new listeners added") + document.querySelectorAll('li, a').forEach(element => { + // this can instead add a button before the "adjust-api-key" span that when clicked adjusts the API key + element.addEventListener('click', () => { + setTimeout(adjustAPIKey, 50); + }); + }); +} + +window.addEventListener('load', function() { + // addAPIEventListeners(); + // const apiObserver = new MutationObserver(addAPIEventListeners); + // apiObserver.observe(document.body, { childList: true, subtree: true }); + // adjustAPIKey(); // this can be removed if turned into a button that calls this +}); \ No newline at end of file diff --git a/docs/v1/scripts/stars.js b/docs/v1/scripts/stars.js index 6b8e6b5c..f5c4d59b 100644 --- a/docs/v1/scripts/stars.js +++ b/docs/v1/scripts/stars.js @@ -3,26 +3,28 @@ function updateStars() { .then((response) => response.json()) .then((data) => { const stars = Math.ceil(data.stargazers_count / 100) * 100 + 100; - setTimeout(() => { - const dataContainer = document.getElementById("stars-text"); - dataContainer.innerHTML = `${stars.toLocaleString()}th`; - }, 50); + const dataContainer = document.getElementById("stars-text"); + dataContainer.innerHTML = `${stars.toLocaleString()}th`; }) .catch((error) => { // console.error("Github Stars pull error:", error); }); } -function addNewEventListeners() { + +// Note that functions cannot be named the same thing across script files if copy-pasting this to add new scripts +function addStarsEventListeners() { setTimeout(() => { document.querySelectorAll('li, a').forEach(element => { - element.addEventListener('click', updateStars); + element.addEventListener('click', () => { + setTimeout(updateStars, 50); + }); }); }, 50); } window.addEventListener('load', function() { updateStars(); - const observer = new MutationObserver(addNewEventListeners); - observer.observe(document.body, { childList: true, subtree: true }); + const starsObserver = new MutationObserver(addStarsEventListeners); + starsObserver.observe(document.body, { childList: true, subtree: true }); }); \ No newline at end of file diff --git a/docs/v1/usage/environment-variables.mdx b/docs/v1/usage/environment-variables.mdx index 5b724a0d..ca5b37c1 100644 --- a/docs/v1/usage/environment-variables.mdx +++ b/docs/v1/usage/environment-variables.mdx @@ -5,9 +5,11 @@ mode: "wide" In AgentOps fashion, you only need to add one line of "code" to your `.env` file 😊 -```python .env -AGENTOPS_API_KEY= -``` +
+ ```python .env + AGENTOPS_API_KEY= + ``` +
Find your AgentOps API Key in your Settings > [Projects & API Keys](https://app.agentops.ai/settings/projects) page. From 6dff177c6d16fd0f1e788a0c0a13afaebf825bf4 Mon Sep 17 00:00:00 2001 From: Soo Date: Fri, 5 Jul 2024 13:47:36 -0700 Subject: [PATCH 5/6] Button to get API Key Test --- docs/snippets/api-key-button.mdx | 3 +++ docs/snippets/api-key-warning.mdx | 3 +++ docs/snippets/dynamic-dashboard.mdx | 0 docs/v1/introduction.mdx | 24 +++++++++++++++------ docs/v1/scripts/adjust_api_dynamically.js | 4 ++++ docs/v1/styles/button.css | 26 +++++++++++++++++++++++ 6 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 docs/snippets/api-key-button.mdx create mode 100644 docs/snippets/api-key-warning.mdx create mode 100644 docs/snippets/dynamic-dashboard.mdx create mode 100644 docs/v1/styles/button.css diff --git a/docs/snippets/api-key-button.mdx b/docs/snippets/api-key-button.mdx new file mode 100644 index 00000000..2d6f540c --- /dev/null +++ b/docs/snippets/api-key-button.mdx @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/docs/snippets/api-key-warning.mdx b/docs/snippets/api-key-warning.mdx new file mode 100644 index 00000000..831e343f --- /dev/null +++ b/docs/snippets/api-key-warning.mdx @@ -0,0 +1,3 @@ + + Psst, anyone else around? Careful when revealing your API key! + \ No newline at end of file diff --git a/docs/snippets/dynamic-dashboard.mdx b/docs/snippets/dynamic-dashboard.mdx new file mode 100644 index 00000000..e69de29b diff --git a/docs/v1/introduction.mdx b/docs/v1/introduction.mdx index 7a88f9ac..1eea267c 100644 --- a/docs/v1/introduction.mdx +++ b/docs/v1/introduction.mdx @@ -4,9 +4,13 @@ description: "Build your next agent with evals, observability, and replays" mode: "wide" --- +import DynamicDashboard from '/snippets/dynamic-dashboard.mdx' +import APIKeyWarning from '/snippets/api-key-warning.mdx' +import APIKeyButton from '/snippets/api-key-button.mdx' + [Give us a star](https://github.com/AgentOps-AI/agentops) on GitHub if you find AgentOps helpful (you may be our 2,000th 😊) -# AgentOps solves what Terminal can't +# AgentOps solves what Terminal can't... @@ -21,7 +25,10 @@ mode: "wide" -And we do it all in just two lines of code... +# in 2 lines of code... + + +
```python python @@ -30,15 +37,19 @@ And we do it all in just two lines of code... ```
-... that logs everything back to your AgentOps Dashboard. -## The AgentOps Dashboard + + + +# ... that logs it all in your Dashboard. + +{/* ## The AgentOps Dashboard With just two lines of code, you can free yourself from the chains of the terminal and instead visualize your agents' behavior in your AgentOps Dashboard. After setting up AgentOps, each execution of your program is recorded as a session and the above data is automatically recorded for you. -The examples below were captured with two lines of code. +The examples below were captured with two lines of code. */} ### Session Drilldown Here you will find a list of all of your previously recorded sessions and useful data about each such as total execution time. @@ -70,4 +81,5 @@ View a meta-analysis of all of your sessions in a single view. - \ No newline at end of file + + \ No newline at end of file diff --git a/docs/v1/scripts/adjust_api_dynamically.js b/docs/v1/scripts/adjust_api_dynamically.js index 1b46a80a..d5598380 100644 --- a/docs/v1/scripts/adjust_api_dynamically.js +++ b/docs/v1/scripts/adjust_api_dynamically.js @@ -57,6 +57,10 @@ function addAPIEventListeners() { // would change to button } window.addEventListener('load', function() { + const actionButtons = document.querySelectorAll('.action-button'); + actionButtons.forEach(button => { + button.addEventListener('click', adjustAPIKey); + }); // addAPIEventListeners(); // const apiObserver = new MutationObserver(addAPIEventListeners); // apiObserver.observe(document.body, { childList: true, subtree: true }); diff --git a/docs/v1/styles/button.css b/docs/v1/styles/button.css new file mode 100644 index 00000000..db8093bb --- /dev/null +++ b/docs/v1/styles/button.css @@ -0,0 +1,26 @@ +/* header { + color: blue; +} */ + +button.action-button { + background-color: #0b430d; /* Darker green background */ + border: none; /* Remove borders */ + color: #E0E0E0; /* Light gray text */ + padding: 0em 0.8em; /* Some padding */ + text-align: center; /* Centered text */ + text-decoration: none; /* Remove underline */ + display: inline-block; /* Get the element to line up correctly */ + font-size: 1em; /* Increase font size */ + margin: 0.8em 2em; /* Add some margin */ + cursor: pointer; /* Add a pointer cursor on hover */ + border-radius: 0.4em; /* Rounded corners */ + transition: background-color 0.3s ease; /* Animate background color changes */ + font-weight: bold; /* Make text bold */ + display: block; /* Make the button a block element */ + margin-left: auto; /* Center the button horizontally */ + margin-right: auto; /* Center the button horizontally */ +} + +button.action-button:hover { + background-color: #28832e; /* Even darker green on hover */ +} From 5249f3c1cb590ae03854df69de16f0de9740e145 Mon Sep 17 00:00:00 2001 From: Soo Date: Mon, 8 Jul 2024 16:19:22 -0700 Subject: [PATCH 6/6] getting copy button working [minor] --- docs/v1/introduction.mdx | 4 ++-- docs/v1/scripts/adjust_api_dynamically.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/v1/introduction.mdx b/docs/v1/introduction.mdx index 1eea267c..5c779bf9 100644 --- a/docs/v1/introduction.mdx +++ b/docs/v1/introduction.mdx @@ -29,14 +29,14 @@ import APIKeyButton from '/snippets/api-key-button.mdx' -
+ ```python python import agentops agentops.init() ``` -
+
diff --git a/docs/v1/scripts/adjust_api_dynamically.js b/docs/v1/scripts/adjust_api_dynamically.js index d5598380..1a394ace 100644 --- a/docs/v1/scripts/adjust_api_dynamically.js +++ b/docs/v1/scripts/adjust_api_dynamically.js @@ -1,3 +1,6 @@ +// NOTE: The copy button is copying the old non-displayed API key, need to add a click listener and set +// the new textContent to be copied + function adjustAPIKey() { // uncomment if you'd like to see this without delay, purely for testing // const apiKey = "BOOGLYWOOGLY"; @@ -23,14 +26,18 @@ function adjustAPIKey() { } function patternFindAndAdjust(apiKey) { - const elementsWithPatterns = Array.from(document.getElementsByClassName("adjust-api-key")); + const targetClasses = document.querySelectorAll(".adjust-api-key"); + const codeElements = []; + targetClasses.forEach(element => { + codeElements.push(element.querySelector('code')); + }); const apiKeyPattern = /AGENTOPS_API_KEY/g; const tokenOperatorPattern1 = /<<\/span>YOUR API KEY><\/span>/g; const tokenOperatorPattern2 = /<<\/span>INSERT YOUR API KEY HERE><\/span>/g; // Process the collected elements - elementsWithPatterns.forEach(element => { + codeElements.forEach(element => { console.log(element.textContent) const containsApiKeyPattern = element.textContent.includes("AGENTOPS_API_KEY"); const containsTokenOperatorPattern1 = element.textContent.includes("");