Skip to content

Commit

Permalink
Merge pull request #7 from milancermak/dev/anthropic-input-tokens
Browse files Browse the repository at this point in the history
fix: anthropic usage from API response
  • Loading branch information
ponderingdemocritus authored Jan 14, 2025
2 parents 33f4422 + 923f68c commit b6a9e8c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/core/llm-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,17 @@ export class LLMClient {
temperature: this.config.temperature,
messages: [{ role: "user", content: prompt }],
},
{ signal }
{ signal },
);

return {
text: response.content[0].type === "text" ? response.content[0].text : "",
model: this.currentModel,
usage: {
prompt_tokens: 0, // Anthropic doesn't provide token counts
completion_tokens: 0,
total_tokens: 0,
prompt_tokens: response.usage.input_tokens,
completion_tokens: response.usage.output_tokens,
total_tokens: response.usage.input_tokens +
response.usage.output_tokens,
},
metadata: {
stop_reason: response.stop_reason,
Expand Down

0 comments on commit b6a9e8c

Please sign in to comment.