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):