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

reqs

reibs806ab9aa3b38
diff --git a/agentops/worker.py b/agentops/worker.py
index f2e98838..9851e2b9 100644
--- a/agentops/worker.py
+++ b/agentops/worker.py
@@ -28,13 +28,23 @@ class Worker:
events = self.queue
self.queue = []
- payload = {
- "events": events
- }
+ payload = {"events": events}
- HttpClient.post(f'{self.config.endpoint}/events',
- json.dumps(payload).encode("utf-8"),
- self.config.api_key)
+ HttpClient.post(
+ f"{self.config.endpoint}/events",
+ json.dumps(payload).encode("utf-8"),
+ self.config.api_key,
+ )
+
+ 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,
+ )
def end_session(self, session: Session) -> None:
self.stop_flag.set()
@@ -42,13 +52,13 @@ class Worker:
self.flush_queue()
with self.lock:
- payload = {
- "session": session.__dict__
- }
+ payload = {"session": session.__dict__}
- HttpClient.post(f'{self.config.endpoint}/sessions',
- json.dumps(payload).encode("utf-8"),
- self.config.api_key)
+ HttpClient.post(
+ f"{self.config.endpoint}/sessions",
+ json.dumps(payload).encode("utf-8"),
+ self.config.api_key,
+ )
def run(self) -> None:
while not self.stop_flag.is_set():
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..f488d775
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,23 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "agentops"
+version = "0.0.1"
+authors = [
+ { name="Alex Reibman", email="[email protected]" },
+ { name="Shawn Qiu", email="[email protected]" }
+]
+description = "Python SDK for developing AI agent evals and observability"
+readme = "README.md"
+requires-python = ">=3.7"
+classifiers = [
+ "Programming Language :: Python :: 3",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+]
+
+[project.urls]
+"Homepage" = "https://github.com/AgentOps-AI/agentops"
+"Bug Tracker" = "https://github.com/AgentOps-AI/agentops/issues"
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 00000000..dd5a435b
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,3 @@
+pytest==7.4.0
+requests==2.31.0
+requests-mock==1.11.0
\ No newline at end of file