Skip to content

Commit

Permalink
WIP. Saving state of abstract Event to try another way
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieG committed Mar 4, 2024
1 parent 5f3f1a9 commit 9aae2aa
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 57 deletions.
10 changes: 0 additions & 10 deletions agentops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,3 @@
from .event import Event # TODO: Don't expose? Since it's abstract?
from .logger import AgentOpsLogger
from .enums import Models, EventType # TODO: Is EventType needed?

# Import event classes
from .events.action import ActionEvent
from .events.error import ErrorEvent
from .events.llm import LLMEvent
from .events.tool import ToolEvent

# TODO: Expose them at the package level?
# __all__ = ['Client', 'Event', 'AgentOpsLogger', 'Models',
# 'ActionEvent', 'ErrorEvent', 'LLMEvent', 'ToolEvent']
1 change: 1 addition & 0 deletions agentops/helpers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
import time
from datetime import datetime
from packaging.version import parse
Expand Down
136 changes: 136 additions & 0 deletions test_env.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found existing installation: agentops 0.0.22\n",
"Uninstalling agentops-0.0.22:\n",
" Successfully uninstalled agentops-0.0.22\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"Collecting agentops\n",
" Using cached agentops-0.0.22-py3-none-any.whl.metadata (5.1 kB)\n",
"Collecting requests==2.31.0 (from agentops)\n",
" Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)\n",
"Collecting pydantic>=1.9.0 (from agentops)\n",
" Using cached pydantic-2.6.3-py3-none-any.whl.metadata (84 kB)\n",
"Collecting packaging<24.0,>=23.1 (from agentops)\n",
" Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB)\n",
"Collecting charset-normalizer<4,>=2 (from requests==2.31.0->agentops)\n",
" Using cached charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl.metadata (33 kB)\n",
"Collecting idna<4,>=2.5 (from requests==2.31.0->agentops)\n",
" Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)\n",
"Collecting urllib3<3,>=1.21.1 (from requests==2.31.0->agentops)\n",
" Using cached urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)\n",
"Collecting certifi>=2017.4.17 (from requests==2.31.0->agentops)\n",
" Using cached certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)\n",
"Collecting annotated-types>=0.4.0 (from pydantic>=1.9.0->agentops)\n",
" Using cached annotated_types-0.6.0-py3-none-any.whl.metadata (12 kB)\n",
"Collecting pydantic-core==2.16.3 (from pydantic>=1.9.0->agentops)\n",
" Using cached pydantic_core-2.16.3-cp312-cp312-macosx_11_0_arm64.whl.metadata (6.5 kB)\n",
"Collecting typing-extensions>=4.6.1 (from pydantic>=1.9.0->agentops)\n",
" Using cached typing_extensions-4.10.0-py3-none-any.whl.metadata (3.0 kB)\n",
"Using cached agentops-0.0.22-py3-none-any.whl (18 kB)\n",
"Using cached requests-2.31.0-py3-none-any.whl (62 kB)\n",
"Using cached packaging-23.2-py3-none-any.whl (53 kB)\n",
"Using cached pydantic-2.6.3-py3-none-any.whl (395 kB)\n",
"Using cached pydantic_core-2.16.3-cp312-cp312-macosx_11_0_arm64.whl (1.7 MB)\n",
"Using cached annotated_types-0.6.0-py3-none-any.whl (12 kB)\n",
"Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)\n",
"Using cached charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl (119 kB)\n",
"Using cached idna-3.6-py3-none-any.whl (61 kB)\n",
"Using cached typing_extensions-4.10.0-py3-none-any.whl (33 kB)\n",
"Using cached urllib3-2.2.1-py3-none-any.whl (121 kB)\n",
"Installing collected packages: urllib3, typing-extensions, packaging, idna, charset-normalizer, certifi, annotated-types, requests, pydantic-core, pydantic, agentops\n",
" Attempting uninstall: urllib3\n",
" Found existing installation: urllib3 2.2.1\n",
" Uninstalling urllib3-2.2.1:\n",
" Successfully uninstalled urllib3-2.2.1\n",
" Attempting uninstall: typing-extensions\n",
" Found existing installation: typing_extensions 4.10.0\n",
" Uninstalling typing_extensions-4.10.0:\n",
" Successfully uninstalled typing_extensions-4.10.0\n",
" Attempting uninstall: packaging\n",
" Found existing installation: packaging 23.2\n",
" Uninstalling packaging-23.2:\n",
" Successfully uninstalled packaging-23.2\n",
" Attempting uninstall: idna\n",
" Found existing installation: idna 3.6\n",
" Uninstalling idna-3.6:\n",
" Successfully uninstalled idna-3.6\n",
" Attempting uninstall: charset-normalizer\n",
" Found existing installation: charset-normalizer 3.3.2\n",
" Uninstalling charset-normalizer-3.3.2:\n",
" Successfully uninstalled charset-normalizer-3.3.2\n",
" Attempting uninstall: certifi\n",
" Found existing installation: certifi 2024.2.2\n",
" Uninstalling certifi-2024.2.2:\n",
" Successfully uninstalled certifi-2024.2.2\n",
" Attempting uninstall: annotated-types\n",
" Found existing installation: annotated-types 0.6.0\n",
" Uninstalling annotated-types-0.6.0:\n",
" Successfully uninstalled annotated-types-0.6.0\n",
" Attempting uninstall: requests\n",
" Found existing installation: requests 2.31.0\n",
" Uninstalling requests-2.31.0:\n",
" Successfully uninstalled requests-2.31.0\n",
" Attempting uninstall: pydantic-core\n",
" Found existing installation: pydantic_core 2.16.3\n",
" Uninstalling pydantic_core-2.16.3:\n",
" Successfully uninstalled pydantic_core-2.16.3\n",
" Attempting uninstall: pydantic\n",
" Found existing installation: pydantic 2.6.3\n",
" Uninstalling pydantic-2.6.3:\n",
" Successfully uninstalled pydantic-2.6.3\n",
"Successfully installed agentops-0.0.22 annotated-types-0.6.0 certifi-2024.2.2 charset-normalizer-3.3.2 idna-3.6 packaging-23.2 pydantic-2.6.3 pydantic-core-2.16.3 requests-2.31.0 typing-extensions-4.10.0 urllib3-2.2.1\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip uninstall -y agentops\n",
"%pip install --upgrade --force-reinstall agentops\n",
"import agentops\n",
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"agentopsClient = agentops.Client(tags=[\"event-ABC-test\"], endpoint=\"http://localhost:8000\")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"from agentops import Event\n",
"action = agentopsClient.record(Event(tags=[\"howie-test\"], event_type=\"action\"))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "env",
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
61 changes: 14 additions & 47 deletions test_event_ABC.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,53 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing /Users/howardgil/Desktop/agentops/AgentOps-AI/agentops\n",
" Installing build dependencies ... \u001b[?25ldone\n",
"\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n",
"\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
"\u001b[?25hRequirement already satisfied: requests==2.31.0 in ./env/lib/python3.12/site-packages (from agentops==0.0.20) (2.31.0)\n",
"Requirement already satisfied: pydantic>=1.9.0 in ./env/lib/python3.12/site-packages (from agentops==0.0.20) (2.6.3)\n",
"Requirement already satisfied: packaging<24.0,>=23.1 in ./env/lib/python3.12/site-packages (from agentops==0.0.20) (23.2)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in ./env/lib/python3.12/site-packages (from requests==2.31.0->agentops==0.0.20) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in ./env/lib/python3.12/site-packages (from requests==2.31.0->agentops==0.0.20) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in ./env/lib/python3.12/site-packages (from requests==2.31.0->agentops==0.0.20) (2.2.1)\n",
"Requirement already satisfied: certifi>=2017.4.17 in ./env/lib/python3.12/site-packages (from requests==2.31.0->agentops==0.0.20) (2024.2.2)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in ./env/lib/python3.12/site-packages (from pydantic>=1.9.0->agentops==0.0.20) (0.6.0)\n",
"Requirement already satisfied: pydantic-core==2.16.3 in ./env/lib/python3.12/site-packages (from pydantic>=1.9.0->agentops==0.0.20) (2.16.3)\n",
"Requirement already satisfied: typing-extensions>=4.6.1 in ./env/lib/python3.12/site-packages (from pydantic>=1.9.0->agentops==0.0.20) (4.10.0)\n",
"Building wheels for collected packages: agentops\n",
" Building wheel for agentops (pyproject.toml) ... \u001b[?25ldone\n",
"\u001b[?25h Created wheel for agentops: filename=agentops-0.0.20-py3-none-any.whl size=20466 sha256=2ec5b069d7411bd7fbabe5ce448264cb4cb603e0a76a9f6edc2ead13392ff0bd\n",
" Stored in directory: /private/var/folders/jb/71y2z4v178jdr5xcgbxfm0gc0000gp/T/pip-ephem-wheel-cache-r78w781y/wheels/43/52/53/9286c77226c557a85392056462580d0d7db8d733d3a9c9be69\n",
"Successfully built agentops\n",
"Installing collected packages: agentops\n",
" Attempting uninstall: agentops\n",
" Found existing installation: agentops 0.0.20\n",
" Uninstalling agentops-0.0.20:\n",
" Successfully uninstalled agentops-0.0.20\n",
"Successfully installed agentops-0.0.20\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"outputs": [],
"source": [
"%pip install .\n",
"import agentops\n",
"agentopsClient = agentops.Client(api_key=\"e2d78f13-1585-4d45-b482-f67a42ae6099\", tags=[\"event-ABC-test\"])"
"agentopsClient = agentops.Client(api_key=\"\", tags=[\"event-ABC-test\"], endpoint=\"http://localhost:8000\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"action = agentops.ActionEvent(action_type=\"action-test\",detail=\"This is a test event\", logs=\"blah\")\n",
"event = agentopsClient.record(action)"
"event = agentopsClient.record(agentops.ActionEvent(action_type=\"action-test\", detail=\"This is a test event\", logs=\"blah\"))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"llmEvent = agentops.LLMEvent(model=\"gpt-4\",prompt=\"ligma\",prompt_tokens=\"69\",completion_tokens=\"420\")\n",
"event = agentopsClient.record(llmEvent)"
"# llmEvent = agentops_rename.LLMEvent(model=\"gpt-4\",prompt=\"ligma\",prompt_tokens=\"69\",completion_tokens=\"420\")\n",
"# event = agentopsClient.record(llmEvent)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"toolEvent = agentops.ToolEvent(name=\"tool-test\",inputs=\"test\",outputs=\"test\",logs=\"test\")\n",
"event = agentopsClient.record(toolEvent)"
"# toolEvent = agentops_rename.ToolEvent(name=\"tool-test\",inputs=\"test\",outputs=\"test\",logs=\"test\")\n",
"# event = agentopsClient.record(toolEvent)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"errorEvent = agentops.ErrorEvent(error_type=\"f\", code=\"404\", details=\"ligma\", logs=\"69\")\n",
"event = agentopsClient.record(errorEvent)"
"# errorEvent = agentops_rename.ErrorEvent(error_type=\"f\", code=\"404\", details=\"ligma\", logs=\"69\")\n",
"# event = agentopsClient.record(errorEvent)"
]
}
],
Expand Down

0 comments on commit 9aae2aa

Please sign in to comment.