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
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
set and add tags then update the session
Braelyn Boyntoned4e9df2af37
diff --git a/agentops/client.py b/agentops/client.pyindex 455ffdb4..cb310152 100644--- a/agentops/client.py+++ b/agentops/client.py@@ -153,6 +153,21 @@ class Client:return decorator+ def add_tags(self, tags: List[str]):+ if self.session.tags is not None:+ self.session.tags.extend(tags)+ else:+ self.session.tags = tags++ self.worker.update_session(self.session)++ def set_tags(self, tags: List[str]):+ if self.session is None:+ raise Exception("You must create a session before assigning tags")++ self.session.tags = tags+ self.worker.update_session(self.session)+def _record_event_sync(self, func, event_name, tags, *args, **kwargs):init_time = get_ISO_time()func_args = inspect.signature(func).parametersdiff --git a/agentops/worker.py b/agentops/worker.pyindex 4876f2b5..63e40938 100644--- a/agentops/worker.py+++ b/agentops/worker.py@@ -96,6 +96,18 @@ class Worker:payload)).encode("utf-8"),self.config.api_key)+ def update_session(self, session: Session) -> None:+ with self.lock:+ payload = {+ "session": session.__dict__+ }++ HttpClient.post(f'{self.config.endpoint}/sessions',+ json.dumps(filter_unjsonable(+ payload)).encode("utf-8"),+ self.config.api_key,+ self.config.org_key)+def run(self) -> None:while not self.stop_flag.is_set():time.sleep(self.config.max_wait_time / 1000)