Skip to content

Commit

Permalink
Working
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieG committed May 10, 2024
1 parent a800383 commit c3b9ff5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions agentops/llm_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,20 @@ def generator():
self.llm_event.agent_id = check_call_stack_for_agent_id()
self.llm_event.prompt = []
if response.chat_history:
role_map = {
"USER": "user",
"CHATBOT": "assistant",
"SYSTEM": "system"
}

for i in range(len(response.chat_history) - 1):
message = response.chat_history[i]
self.llm_event.prompt.append({"role": message.role, "content": message.message})
self.llm_event.prompt.append({"role": role_map.get(
message.role, message.role), "content": message.message})

last_message = response.chat_history[-1]
self.llm_event.completion = {
"role": response.chat_history[-1].role, "content": response.chat_history[-1].message}
"role": role_map.get(last_message.role, last_message.role), "content": last_message.message}
self.llm_event.prompt_tokens = response.meta.tokens.input_tokens
self.llm_event.completion_tokens = response.meta.tokens.output_tokens
self.llm_event.model = kwargs.get("model", "command-r-plus")
Expand Down

0 comments on commit c3b9ff5

Please sign in to comment.