Skip to content

Commit

Permalink
Add token counts to llm message history
Browse files Browse the repository at this point in the history
  • Loading branch information
mcjustin committed Nov 12, 2024
1 parent 4b1aa55 commit a81ed7f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion static/ips/assets/js/llmChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ async function sendMessage() {
content: [{ type: "text", text: data.content}]
});

insertMessageIntoUi('assistant', "LLM: " + data.content);
const promptTokens = data.prompt_tokens;
const completionTokens = data.completion_tokens;

const formattedResponse = `LLM: ${data.content} (prompt_tokens=${promptTokens}, completion_tokens=${completionTokens})`;
insertMessageIntoUi('assistant', formattedResponse);
} catch (error) {
console.error('Error sending message to LLM:', error);
insertMessageIntoUi('error', 'Failed to get a response. Please try again.');
Expand Down

0 comments on commit a81ed7f

Please sign in to comment.