From 2f9cde3dfa2d5481b4f989969dabe7ed8b2c6721 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Sat, 10 Aug 2024 23:01:03 +0530 Subject: [PATCH] some more fixes and cleanup --- agentops/llm_tracker.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/agentops/llm_tracker.py b/agentops/llm_tracker.py index f618b23e..c87655ea 100644 --- a/agentops/llm_tracker.py +++ b/agentops/llm_tracker.py @@ -653,12 +653,12 @@ def handle_stream_chunk(chunk: Message): self.llm_event.model = kwargs["model"] self.llm_event.prompt = kwargs["messages"][0]["content"] self.llm_event.prompt_tokens = chunk.message.usage.input_tokens - self.llm_event.completion = "" - elif isinstance(chunk, RawContentBlockStartEvent): self.llm_event.completion = { - "role": "assistant", - "content": chunk.content_block.text, + "role": chunk.message.role, + "content": "", # Always returned as [] in the this instance type } + elif isinstance(chunk, RawContentBlockStartEvent): + self.llm_event.completion["content"] += chunk.content_block.text elif isinstance(chunk, RawContentBlockDeltaEvent): self.llm_event.completion["content"] += chunk.delta.text elif isinstance(chunk, RawContentBlockStopEvent): @@ -1276,7 +1276,7 @@ def override_api(self): if module_version is None: logger.warning( - f"Cannot determine Anthropic version. Only Anthropic>=0.0.1 supported." + f"Cannot determine Anthropic version. Only Anthropic>=0.32.0 supported." ) if Version(module_version) >= parse("0.32.0"): @@ -1284,7 +1284,7 @@ def override_api(self): self.override_anthropic_async_completion() else: logger.warning( - f"Only Anthropic>=0.0.1 supported. v{module_version} found." + f"Only Anthropic>=0.32.0 supported. v{module_version} found." ) def stop_instrumenting(self):