Coder Social home page Coder Social logo

agentops-ai / agentops Goto Github PK

View Code? Open in Web Editor NEW
1.1K 20.0 89.0 100.2 MB

Python SDK for agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks like CrewAI, Langchain, and Autogen

Home Page: https://agentops.ai

License: MIT License

Python 99.49% Jupyter Notebook 0.51%
agent agentops ai evals evaluation-metrics llm anthropic autogen cost-estimation crewai groq langchain mistral ollama openai

agentops's Introduction

AI agents suck. Weโ€™re fixing that.

Python Version

๐Ÿฆ Twitter ย ย โ€ขย ย  ๐Ÿ“ข Discord ย ย โ€ขย ย  ๐Ÿ–‡๏ธ AgentOps ย ย โ€ขย ย  ๐Ÿ“™ Documentation

AgentOps ๐Ÿ–‡๏ธ

License: MIT PyPI - Version AgentOps Twitter Discord community channel git commit activity

AgentOps helps developers build, evaluate, and monitor AI agents. Tools to build agents from prototype to production.

๐Ÿ“Š Replay Analytics and Debugging Step-by-step agent execution graphs
๐Ÿ’ธ LLM Cost Management Track spend with LLM foundation model providers
๐Ÿงช Agent Benchmarking Test your agents against 1,000+ evals
๐Ÿ” Compliance and Security Detect common prompt injection and data exfiltration exploits
๐Ÿค Framework Integrations Native Integrations with CrewAI, AutoGen, & LangChain

Quick Start โŒจ๏ธ

pip install agentops

Session replays in 3 lines of code

Initialize the AgentOps client and automatically get analytics on every LLM call.

import agentops

# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)

...
# (optional: record specific functions)
@agentops.record_function('sample function being record')
def sample_function(...):
    ...

# End of program
agentops.end_session('Success')
# Woohoo You're done ๐ŸŽ‰

All your sessions are available on the AgentOps dashboard. Refer to our API documentation for detailed instructions.

Agent Dashboard Agent Dashboard
Session Analytics Session Analytics
Session Replays Session Replays

Integrations ๐Ÿฆพ

CrewAI ๐Ÿ›ถ

Build Crew agents with observability with only 2 lines of code. Simply set an AGENTOPS_API_KEY in your environment, and your crews will get automatic monitoring on the AgentOps dashboard.

AgentOps is integrated with CrewAI on a pre-release fork. Install crew with

pip install git+https://github.com/AgentOps-AI/crewAI.git@main

AutoGen ๐Ÿค–

With only two lines of code, add full observability and monitoring to Autogen agents. Set an AGENTOPS_API_KEY in your environment and call agentops.init()

Langchain ๐Ÿฆœ๐Ÿ”—

AgentOps works seamlessly with applications built using Langchain. To use the handler, install Langchain as an optional dependency:

Installation
pip install agentops[langchain]

To use the handler, import and set

import os
from langchain.chat_models import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from agentops.langchain_callback_handler import LangchainCallbackHandler

AGENTOPS_API_KEY = os.environ['AGENTOPS_API_KEY']
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')

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)

Check out the Langchain Examples Notebook for more details including Async handlers.

Cohere โŒจ๏ธ

First class support for Cohere(>=5.4.0). This is a living integration, should you need any added functionality please message us on Discord!

Installation
pip install cohere
import cohere
import agentops

# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)
co = cohere.Client()

chat = co.chat(
    message="Is it pronounced ceaux-hear or co-hehray?"
)

print(chat)

agentops.end_session('Success')
import cohere
import agentops

# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)

co = cohere.Client()

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='')

agentops.end_session('Success')

LiteLLM

AgentOps provides support for LiteLLM(>=1.3.1), allowing you to call 100+ LLMs using the same Input/Output Format.

Installation
pip install litellm
# Do not use LiteLLM like this
# from litellm import completion
# ...
# response = completion(model="claude-3", messages=messages)

# Use LiteLLM like this
import litellm
...
response = litellm.completion(model="claude-3", messages=messages)
# or
response = await litellm.acompletion(model="claude-3", messages=messages)

LlamaIndex ๐Ÿฆ™

(Coming Soon)

Time travel debugging ๐Ÿ”ฎ

(coming soon!)

Agent Arena ๐ŸฅŠ

(coming soon!)

Evaluations Roadmap ๐Ÿงญ

Platform Dashboard Evals
โœ… Python SDK โœ… Multi-session and Cross-session metrics โœ… Custom eval metrics
๐Ÿšง Evaluation builder API โœ… Custom event tag trackingย  ๐Ÿ”œ Agent scorecards
โœ… Javascript/Typescript SDK โœ… Session replays ๐Ÿ”œ Evaluation playground + leaderboard

Debugging Roadmap ๐Ÿงญ

Performance testing Environments LLM Testing Reasoning and execution testing
โœ… Event latency analysis ๐Ÿ”œ Non-stationary environment testing ๐Ÿ”œ LLM non-deterministic function detection ๐Ÿšง Infinite loops and recursive thought detection
โœ… Agent workflow execution pricing ๐Ÿ”œ Multi-modal environments ๐Ÿšง Token limit overflow flags ๐Ÿ”œ Faulty reasoning detection
๐Ÿšง Success validators (external) ๐Ÿ”œ Execution containers ๐Ÿ”œ Context limit overflow flags ๐Ÿ”œ Generative code validators
๐Ÿ”œ Agent controllers/skill tests โœ… Honeypot and prompt injection detection (PromptArmor) ๐Ÿ”œ API bill tracking ๐Ÿ”œ Error breakpoint analysis
๐Ÿ”œ Information context constraint testing ๐Ÿ”œ Anti-agent roadblocks (i.e. Captchas) ๐Ÿ”œ CI/CD integration checks
๐Ÿ”œ Regression testing ๐Ÿ”œ Multi-agent framework visualization

Why AgentOps? ๐Ÿค”

Without the right tools, AI agents are slow, expensive, and unreliable. Our mission is to bring your agent from prototype to production. Here's why AgentOps stands out:

  • Comprehensive Observability: Track your AI agents' performance, user interactions, and API usage.
  • Real-Time Monitoring: Get instant insights with session replays, metrics, and live monitoring tools.
  • Cost Control: Monitor and manage your spend on LLM and API calls.
  • Failure Detection: Quickly identify and respond to agent failures and multi-agent interaction issues.
  • Tool Usage Statistics: Understand how your agents utilize external tools with detailed analytics.
  • Session-Wide Metrics: Gain a holistic view of your agents' sessions with comprehensive statistics.

AgentOps is designed to make agent observability, testing, and monitoring easy.

Star History

Check out our growth in the community:

Logo

agentops's People

Contributors

abhinavmir avatar albertkimjunior avatar areibman avatar atomsilverman avatar bboynton97 avatar eltociear avatar howieg avatar mbarnathan avatar siyangqiu avatar sprajosh avatar stateofkate avatar the-praxs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agentops's Issues

Emit events on exit

Currently we don't see the last termination event. We should emit that. So for example, ctrl+C should show that termination event

pypi auto publish

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Auto publish to pypi

Create a workflow

Add DSPY instrumentor

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Using either OpenInference or OpenLLMetry, add an instrumented for DSPY. This is the first of several test features we'll use to determine which is the best instrumentation library.

Hanging thread after exit

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
Our current atexit code is not working. Tried this with smol-scheduler and it was bad.

๐Ÿ”„ Reproduction Steps
Create a simple script with a single function. (print hello world) and decorate it with the agent ops event recorder

๐Ÿ™ Expected Behavior
Program should exit properly.

Add Mypy and Coverage.py

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Currently, our test coverage is not being tracked. Also, we want to abide by Mypy typing

๐Ÿค” Is your feature request related to a problem?
We don't have adequate coverage reporting.

๐ŸŽ‰ Describe the solution you'd like
Add mypy and coverage.py to our tox file.

Add org id to sessions

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Several users are requesting the ability to collect analytics on sessions within their org. That is, individual maintainers of OSS projects want to be able to log and manage sessions created by their users. We currently don't have a simple way of aggregating user data to this degree.

๐ŸŽ‰ Describe the solution you'd like
Suggestion:

  1. Add an optional org_key to the AO client. Sessions created with an org key will be accessible to organization managers
  2. Sessions with an org key but no api key will still be saved.
  3. Sessions with an org key and an api key will be saved, and users will be able to track their personal historical traces, but not that of other users in the org

Furthermore, sessions without an API key will now show a temporary URL that hosts session's run. This is anonymous but technically accessible to anyone with the URL.

๐Ÿ“š Have you considered any alternatives?
We've considering issuing API keys to users based on org dashboards, but this is too cumbersome. For users we track during, say, hackathons, we want to minimize the time it takes for them to sign up to track their replays

Update events prompts to be sent as ChatML

๐Ÿš€ Feature Request

Currently, we do not consistently send prompts to the server as either ChatML format or string. We should enforce this standard on SDK for both langchain and OpenAI

Replace LLM action recorders with autologger

๐Ÿš€ Feature Request

Weights and biases has a cool pattern where you can just override and patch OpenAI calls. We can use this to emit events instead of having to build special wrappers for llm calls.

Since we are now tracking events asynchronously, we can pull this off pretty easily.

meta_client.py-meta_client:48 - WARNING: ๐Ÿ–‡ AgentOps: Error: [WinError 21] The device is not ready: 'G:\\' ---> In Windows

๐Ÿ› Bug Report

(venv) PS E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew> python main.py
2024-04-30 10:04:06,923 - 3368 - meta_client.py-meta_client:48 - WARNING: ๐Ÿ–‡ AgentOps: Error: [WinError 21] The device is not ready: 'G:\'
2024-04-30 10:04:07,007 - 3368 - meta_client.py-meta_client:48 - WARNING: ๐Ÿ–‡ AgentOps: Error: [WinError 21] The device is not ready: 'G:\'
2024-04-30 10:04:07,039 - 3368 - client.py-client:242 - WARNING: ๐Ÿ–‡ AgentOps: Cannot end session - no current session
Traceback (most recent call last):
File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\meta_client.py", line 46, in wrapper
return method(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\client.py", line 217, in start_session
self._session = Session(inherited_session_id or uuid4(), tags or self.tags, host_env=get_host_env())
^^^^^^^^^^^^^^
File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\host_env.py", line 63, in get_host_env
"Disk": get_disk_details(),
^^^^^^^^^^^^^^^^^^
File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\host_env.py", line 46, in get_disk_details
usage = psutil.disk_usage(partition.mountpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\psutil_init
.py", line 2049, in disk_usage
return _psplatform.disk_usage(path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\psutil_pswindows.py", line 291, in disk_usage
total, free = cext.disk_usage(path)
^^^^^^^^^^^^^^^^^^^^^
PermissionError: [WinError 21] The device is not ready: 'G:\'

๐Ÿ”Ž Describe the Bug The application crashes with a PermissionError when trying to access the 'G:' drive, which is not ready or inaccessible.

๐Ÿ”„ Reproduction Steps

Run the main.py script.
The application attempts to retrieve disk usage details using the psutil library.
The psutil library tries to access the 'G:' drive, which is not ready.
A PermissionError is raised, causing the application to crash.
๐Ÿ™ Expected Behavior The application should handle the situation gracefully when the 'G:' drive is not ready, without raising an error.

๐Ÿ“ธ Screenshots
image

๐Ÿ” Additional Context The error occurs in the get_disk_details() function in host_env.py, which is called by the start_session() function in client.py. The get_disk_details() function uses the psutil.disk_partitions() function to retrieve a list of all mounted partitions, and then calls the psutil.disk_usage() function for each partition to retrieve usage details. If the 'G:' drive is not ready, the psutil.disk_usage() function raises a PermissionError, causing the application to crash.

Async events get logged as instances

๐Ÿ› Bug Report

When we log async events with record_action, they don't properly terminate. This is because the decorator doesn't properly await.

image

๐Ÿ”„ Reproduction Steps
Record an async event

๐Ÿ™ Expected Behavior
The event should terminate at the end of the async

Add org key to handler

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Currently the Langchain handler doesn't take orgkey as an arg. It should.

Update events handler to read 3rd party library calls

๐Ÿš€ Feature Request

Some libraries use 3rd party agent frameworks. We don't want to replace them but instead patch

๐Ÿ’ก Got a brilliant idea?
Briefly describe your feature suggestion. We're all about improving agent observablity and performance.

๐Ÿค” Is your feature request related to a problem?
If your feature request is related to a problem you're facing, describe it here. The more we understand your struggle, the better we can address it.

๐ŸŽ‰ Describe the solution you'd like
What's your solution? Be as detailed as possible.

๐Ÿ“š Have you considered any alternatives?
Share any alternative solutions or features you've considered.

๐Ÿ–ผ๏ธ Can you provide a visual mock-up or sketch?
If possible, provide a visual mock-up or sketch of your feature request. Visual aids can help us better understand your vision.

๐Ÿ” Additional context
Any extra information or context to help us understand better? Share it here.

Cohere support

๐Ÿš€ Feature Request

Add instrumentation for Cohere models

Data collection toggling

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Some users are requesting environment metadata doesn't get collected. We'd like a way to toggle this

๐Ÿค” Is your feature request related to a problem?
Discord user requested

๐ŸŽ‰ Describe the solution you'd like
Either:
a) In SDK have toggle on init
b) In dashboard have toggle on key create

๐Ÿ“š Have you considered any alternatives?
Status quo collects everything

Load tags from env or offer documentation recommendations for how to add different groupings

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Currently, the highest level grouping of sessions is by session ID. That is, you can't group sessions together other than tags. The problem with tags is that they need to be individually specified for each session instantiation.

As an alternative, I suggest one of the two options:

  1. Update the documentation to automatically add tags based on a present environmental variable on-load. For example AGENTOPS_TAG_GROUP=Chrome navigation test in the .env would automatically add a tag to the tags group.
  2. Add another optional argument to the session installation called group. For example:
        api_key (str): API Key for AgentOps services.
        tags (Dict[str, str], optional): Tags for the sessions that can be used for grouping or sorting later (e.g. {"llm": "GPT-4"}).
        group (str, optional): An ID used to group sessions of the same type together. (e.g. Chrome navigation test).
        config (Configuration, optional): A Configuration object for AgentOps services. If not provided, a default Configuration object will be used.

๐Ÿค” Is your feature request related to a problem?
Currently, we only group sessions by tags in dashboards. It may make sense to have better session grouping logic.

๐ŸŽ‰ Describe the solution you'd like
Add a way to read env to tags, or add a new optional arg to the agentops instantiation (see above)

๐Ÿ“š Have you considered any alternatives?
Grouping by tags alone.

Alternatively, update the documentation to show some recommended practices for using agentops.

Save recording and screenshots for web-browser demos

๐Ÿš€ Feature Request

Several agents navigate the web take screenshots and videos. We'd like to be able to save and store these screenshots in the AgentOps dashboard.

In particular, we should make it easy to handle the format MultiON provides: https://github.com/MULTI-ON/api

๐Ÿ’ก Got a brilliant idea?
This feature has two necessary capabilities:

  1. Add a "screenshot" param to the Event class.
  2. Add a "recording" param to the Session that allows you to add a video to the session before the session ends. This can either be through an update method or directly updated the class attribute

๐ŸŽ‰ Describe the solution you'd like
Please refer to MultiON's API for how they save screenshot and recording data. This is all generally speaking provided by Playwright.

LLM cost tracking

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Currently, we don't have a reliable way of tracking costs. We can either:
a) Plug into a 3rd party API such as Helicone
Pros:

  • All hard complexity abstracted from users. Simply just replace the proxy server + Bearer auth
    Cons:
  • Need to learn API integration
  • Users now have a dependency on 3rd party service pricing.

b) Roll out or own version of cost tracking proxy
Pros:

  • All hard complexity abstracted from users. Simply just replace the proxy server + Bearer auth
  • Tons of OSS services out there do this already, just fork their code. Easy enough?
    Cons:
  • Need to write this out ourselves
  • Need to host ourselves

c) Update the tracker methods to include params for LLMs
Pros:

  • Easy to just roll into existing function wrappers
  • Session ID remains tied with API calls, keeps session costs in line
  • No need to proxy calls
  • Possible extensibility with custom LLMs down the line (i.e. pass in a tokenizer + cost dictionary and get your estimate)
    Cons:
  • Added complexity for tagging

๐Ÿค” Is your feature request related to a problem?
Lots of users are asking to know cost per run. This is really valuable to track.

๐ŸŽ‰ Describe the solution you'd like
Dead simple implementation SDK side

๐Ÿ“š Have you considered any alternatives?
See above. Maybe 3rd party API integration via cost-tracking services (i.e. Helicone) and keep the cost management game out of our hair

Index out of range error

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug

Seeing this error frequently. Appears to be happening a lot with CrewAI streaming.

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/agentops/llm_tracker.py", line 127, in handle_stream_chunk
    token = choices[0].delta.content
            ~~~~~~~^^^
IndexError: list index out of range

๐Ÿ”„ Reproduction Steps
Run a non-standard model with CrewAI

๐Ÿ™ Expected Behavior

  • No error or crash.
  • Error events get more details about what went wrong

Tracebacks for failed events

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Failed events don't provide enough context as to why the agent failed. All we know is that the events fail (marked in red/orange), but we don't see the proximate cause.

๐ŸŽ‰ Describe the solution you'd like
Add a codeblock in the replay of the failed event's complete traceback that led to the error. This should help provide developers a way to understand where in the code the developers should make a fix.

๐Ÿ“š Have you considered any alternatives?
This is akin to Sentry.io. Probably should just adopt whatever patterns they use.

Update events to have init + end timestamps

๐Ÿš€ Feature Request

We are overhauling the agentops client to use init and end timestamps now. This accommodates for asynchronous evens as well as autologging of LLM calls.

Incorrect timezone representation in get_ISO_time

Title: Incorrect Timezone Representation in get_ISO_time Function

There is potential issue in the get_ISO_time function in the agentops/helpers.py file. The function is currently defined as follows:

def get_ISO_time():
    return datetime.fromtimestamp(time.time()).isoformat(timespec='milliseconds') + 'Z'

The function is intended to return the current time in ISO 8601 format, with the 'Z' at the end indicating that the time is in Coordinated Universal Time (UTC). However, the function is currently using datetime.fromtimestamp(time.time()), which returns the local time, not UTC.

This could lead to confusion or incorrect data interpretation, as the 'Z' at the end of the timestamp implies that the time is in UTC, when it is actually in local time.

To correct this, we should use datetime.utcfromtimestamp(time.time()) instead, which will return the current time in UTC. Here's the corrected function:

    return datetime.utcfromtimestamp(time.time()).isoformat(timespec='milliseconds') + 'Z'

This will ensure that the timestamp returned by get_ISO_time is indeed in UTC, as indicated by the 'Z' at the end.

Unended sessions leaving hanging programs

๐Ÿ› Bug Report

Unless Client.end_session is run, the program will hang.

๐Ÿ”Ž Describe the Bug
Give a clear and concise description of the bug.

๐Ÿ”„ Reproduction Steps

  1. Run pytest tests/test_teardown.py. Notice how the program hangs

๐Ÿ™ Expected Behavior
Program should not hang.

๐Ÿ“ธ Screenshots
If applicable, add screenshots to help explain the problem.

(env) (base) โžœ  agentops git:(33-decorators-are-unsafe) โœ— pytest tests/test_teardown.py -s
============================================== test session starts ==============================================
platform darwin -- Python 3.11.3, pytest-7.4.0, pluggy-1.3.0
rootdir: /Users/reibs/Projects/agentops-ai/agentops
plugins: anyio-4.0.0, asyncio-0.21.1, mock-3.11.1, requests-mock-1.11.0, httpx-0.24.0
asyncio: mode=Mode.STRICT
collected 1 item

tests/test_teardown.py .

=============================================== 1 passed in 3.21s ===============================================

Add session end state reason

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
When sessions fail, we don't know why unless we go into a drill down. This error tracking should be handled at the session level as well.

๐Ÿค” Is your feature request related to a problem?
Error session drill downs

๐ŸŽ‰ Describe the solution you'd like
Add a new param to sessions

๐Ÿ“š Have you considered any alternatives?
Take last failed event from a session. This seems kludgy though.

Python event timing is weird

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
The time gap between events is inconsistent. I think we may have a blocking issue with how we post data.

๐Ÿ”„ Reproduction Steps
Run this script:

import time


from agentops import AgentOps, Event

ao = AgentOps(api_key="1447cc5f-61b2-4967-ae1c-d30610bc4ca2")
time.sleep(1)
print(time.time())
ao.record(Event("SQIU_event", result="success"))
time.sleep(1)
print(time.time())
ao.record(Event("SQIU_event2", result="success"))
print(time.time())
ao.record(Event("SQIU_event2", result="success"))
print(time.time())
ao.record(Event("SQIU_event2", result="success"))
print(time.time())
ao.record(Event("SQIU_event2", result="success"))
print(time.time())
ao.record(Event("SQIU_event2", result="success"))
print(time.time())
ao.record(Event("SQIU_event2", result="success"))
time.sleep(1.5)
print(time.time())
ao.record(Event("SQIU_event", result="success"))
time.sleep(0.5)
print(time.time())
ao.record(Event("SQIU_event", result="success"))
time.sleep(2)
print(time.time())
ao.record(Event("SQIU_event", result="success"))
ao.end_session(end_state="fail")

The time gap between the events don't line up with the sleep times in the script:

> python add_events.py
1692249866.7725768
1692249867.77273
b'{"events": [{"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:26.772Z"}]}'
1692249870.3852417
1692249870.3853083
1692249870.385325
1692249870.3853374
1692249870.3853488
1692249871.8857806
b'{"events": [{"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event2", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:27.772Z"}, {"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event2", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:30.385Z"}, {"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event2", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:30.385Z"}, {"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event2", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:30.385Z"}, {"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event2", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:30.385Z"}, {"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event2", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:30.385Z"}]}'
1692249872.8345242
b'{"events": [{"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:31.885Z"}, {"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:32.834Z"}]}'
1692249874.835022
b'{"events": [{"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "event_type": "SQIU_event", "params": null, "output": null, "result": "success", "tags": null, "timestamp": "2023-08-16T22:24:34.835Z"}]}'
b'{"session": {"session_id": "e141b465-378b-4b79-b47c-a4386aaacdc7", "init_timestamp": "2023-08-16T22:24:25.772Z", "tags": null, "end_state": "fail", "rating": null, "end_timestamp": "2023-08-16T22:24:34.835Z"}}'

Make TOS more clear on API key create

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
We collect agent environment metadata on-run, but some users weren't clear about this. Create a modal/clear user indication that this data will be collected

๐Ÿค” Is your feature request related to a problem?
Requested on discord

๐ŸŽ‰ Describe the solution you'd like
On API key creation page, add a modal or indicator which data will be collected by the key

๐Ÿ“š Have you considered any alternatives?
Keep terms of service as is

Exits leave hanging threads

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
If a python script running agentops exits prematurely, then it will not send events to the server.

๐Ÿ”„ Reproduction Steps

  1. Instantiate agentops
  2. Crash script (fail an assert, etc.)
  3. Program will hang

๐Ÿ™ Expected Behavior
Program exits gracefully and should send an end_session state of Failure

The issue deals specifically with the worker

Replace tags as a list instead of dict

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Loading tags as a dictionary is problematic for the frontend. As such, @siyangqiu proposes changing to a list of strings

๐Ÿค” Is your feature request related to a problem?
If your feature request is related to a problem you're facing, describe it here. The more we understand your struggle, the better we can address it.

๐ŸŽ‰ Describe the solution you'd like
tags (Dict[str, str], optional): Tags that can be used for grouping or sorting later. e.g. {"llm": "GPT-4"}.
to
tags (List[str], optional): Tags that can be used for grouping or sorting later. e.g. "GPT-4".

๐Ÿ“š Have you considered any alternatives?
Status quo. Keep as dict.

๐Ÿ” Additional context
@siyangqiu please add additional thinking around this

Sessions are not sent to the dashboard until after `end_session`

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
When a session begins, events are POST'ed to the database, but sessions are only saved after end_session is called.

๐Ÿ”„ Reproduction Steps
Create a session, send events, but don't end the session.

๐Ÿ™ Expected Behavior
Post the session as soon as it is created. After end_session, update the session.

๐Ÿ“ธ Screenshots
Proposed fix, add start_session to the Worker:

    def start_session(self, session: Session) -> None:
        with self.lock:
            payload = {
                "session": session.__dict__
            }

            HttpClient.post(f'{self.config.endpoint}/sessions',
                            json.dumps(payload).encode("utf-8"),
                            self.config.api_key) 

Current end session should remain the same:

    def end_session(self, session: Session) -> None:
        self.stop_flag.set()
        self.thread.join()
        self.flush_queue()

        with self.lock:
            payload = {
                "session": session.__dict__
            }

            HttpClient.post(f'{self.config.endpoint}/sessions',
                            json.dumps(payload).encode("utf-8"),
                            self.config.api_key)

Add LlamaIndex callback handler

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Similar to Langchain, Llama Index also provides callback handlers. This is a potential opportunity to give built-in observability to agents built with this framework.

๐Ÿค” Is your feature request related to a problem?
A user in TokenCost might be a good initial pilot.

๐ŸŽ‰ Describe the solution you'd like
Implement the callback handler here: https://docs.llamaindex.ai/en/stable/api_reference/callbacks.html

๐Ÿ” Additional context
Before working on this, find at least a handful of LlamaIndex agent builders and trial with them

Add LangChain handler documentation support

๐Ÿ“š Documentation Update

๐Ÿ“˜ Describe the current state of documentation
Sync + Async handlers are now available with AgentOps and Langchain. Provide pages in the README.md as well as the documentation page.

"__setitem__" method not defined on type "EventType"Pylance

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
To improve Mypy typing, we should add item setters on Event objects. This eliminates a handful of errors and makes the code safer.

๐ŸŽ‰ Describe the solution you'd like
Add __setitem__ to Event and Session

Notebooks not running end-to-end + typos

๐Ÿ› Bug Report

Several of the Jupyter notebooks don't run end-to-end with the latest version of AgentOps. Additionally, there are a handful of spelling/grammar issues.

To improve this:

  1. Run each notebook top to bottom to ensure they work as expected
  2. Clean up any typos or grammar issues in them

Session Drill Down page does not refresh to the selected issue

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
When refreshing the drill down page, either via refresh button or browser refresh, the page still shows the previously used session rather than the latest. The session tab however, shows the latest session as selected. User must select another session and then select again the latest session in the session tab in order to show the latest session.

๐Ÿ”„ Reproduction Steps

  1. Generate a new session
  2. Go to session drill down page
  3. Hit refresh button

๐Ÿ™ Expected Behavior
After refreshing the drill down page should show the latest session/

๐Ÿ“ธ Screenshots
image

Thank you for helping us improve Agentops!

Working Code Examples

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Add a folder for examples using AgentOps. This can augment the documentation by offering runnable code.

Cannot import Langchain handler

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
There is a conflict between the agentops package version 0.0.14, which requires packaging==23.1, and the langchain-core package, which requires packaging>=23.2,<24.0. This conflict prevents pip from resolving the dependencies and installing the packages.

Create enum for session end states and event results

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Currently, session end states and event results are hard coded as strings instead of typed enums. These results should be success, indeterminate, and fail

Instead, we are inconsistent with database entries. Sessions, for example:
image

and Events:
image

๐Ÿค” Is your feature request related to a problem?
N/A

๐ŸŽ‰ Describe the solution you'd like
We'd like to create an enum for the possible result states for:

  1. Sessions
  2. Events

Decorators are unsafe

๐Ÿ› Bug Report

A handful of decorators crash in prod. This should never happen. In particular, this happens with the action_type type enforcement. We should get rid of this entirely now as we now track LLM calls with overrides

Params are not being sent to dashboard

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
The record action decorator does not send argument parameters correctly to the database. Only 1 arg param gets sent.

๐Ÿ”„ Reproduction Steps
Decorate a function with multiple arguments. Only 1 actually gets sent.

๐Ÿ™ Expected Behavior
All serializable args should be sent

Thank you for helping us improve Agentops!

"Application error: a client-side exception has occurred" on drilldown page

๐Ÿ› Bug Report

๐Ÿ”Ž Describe the Bug
When hovering the mouse on the Session Replay graph I get "Application error: a client-side exception has occurred (see the browser console for more information)."

๐Ÿ”„ Reproduction Steps
After running a session, go to Session Drilldown and hover the mouse on the Session Replay graph.

๐Ÿ™ Expected Behavior
Application not crashing :)

๐Ÿ“ธ Screenshots
image

๐Ÿ” Additional Context
From the browser console

145-b1c31d5a593e826b.js:1 TypeError: e.substring is not a function
at d (layout-daab6a9ae5cf92e0.js:1:17848)
at page-71a73c4069089a9a.js:1:6154
at Array.map ()
at I (page-71a73c4069089a9a.js:1:5940)
at Y (page-71a73c4069089a9a.js:1:9712)
at rk (fd9d1056-241e146bacb67727.js:1:40370)
at iB (fd9d1056-241e146bacb67727.js:1:116379)
at o4 (fd9d1056-241e146bacb67727.js:1:94632)
at fd9d1056-241e146bacb67727.js:1:94454
at o3 (fd9d1056-241e146bacb67727.js:1:94461)
at oQ (fd9d1056-241e146bacb67727.js:1:91948)
at oj (fd9d1056-241e146bacb67727.js:1:91373)
at MessagePort.w (145-b1c31d5a593e826b.js:6:29386)

Thank you for helping us improve Agentops!

Publish to PyPI

๐Ÿš€ Feature Request

๐Ÿ’ก Got a brilliant idea?
Currently, the repo is not pip downloadable.

๐ŸŽ‰ Describe the solution you'd like
Add agentops to pypi

Non-standard prompt args for LLMs

๐Ÿš€ Feature Request

Frequently enough, users create wrapper methods for LLM calls. As such, they don't always include the term "prompt" in their code.

๐Ÿ’ก Got a brilliant idea?
In the decorator, allow users to specify the prompt argument of the LLM caller function.

Async Langchain callback handler

๐Ÿš€ Feature Request

Some agents require async callback handlers. Create an implementation for this with Langchain. The API is more or less identical.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.