Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion services/libs/common_services/src/services/llm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export interface IBedrockClientCredentials {
secretAccessKey: string
}

function firstTextBlock(content: Array<{ type?: string; text?: string }>): string {
return content.find((block) => block.type === 'text')?.text ?? content[0]?.text ?? ''
}

export class LlmService extends LoggerBase {
private readonly clientRegionMap: Map<string, BedrockRuntimeClient>
private readonly qx: QueryExecutor
Expand Down Expand Up @@ -134,7 +138,7 @@ export class LlmService extends LoggerBase {

const inputTokenCount = body.usage.input_tokens
const outputTokenCount = body.usage.output_tokens
const answer = body.content[0].text
const answer = firstTextBlock(body.content)

const pricing = LLM_MODEL_PRICING_MAP[settings.modelId]

Expand Down
1 change: 1 addition & 0 deletions services/libs/types/src/enums/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum LlmModelType {
CLAUDE_3_5_SONNET_V2 = 'anthropic.claude-3-5-sonnet-20241022-v2:0',
CLAUDE_3_OPUS = 'anthropic.claude-3-opus-20240229-v1:0',
CLAUDE_SONNET_4 = 'us.anthropic.claude-sonnet-4-20250514-v1:0',
CLAUDE_SONNET_5_5 = 'us.anthropic.claude-sonnet-5-5',
CLAUDE_HAIKU_4_5 = 'us.anthropic.claude-haiku-4-5-20251001-v1:0',
}

Expand Down
9 changes: 7 additions & 2 deletions services/libs/types/src/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const LLM_MODEL_REGION_MAP: Record<LlmModelType, string> = {
[LlmModelType.CLAUDE_3_5_SONNET]: 'us-east-1',
[LlmModelType.CLAUDE_3_5_SONNET_V2]: 'us-west-2',
[LlmModelType.CLAUDE_SONNET_4]: 'us-east-1',
[LlmModelType.CLAUDE_SONNET_5_5]: 'us-east-1',
[LlmModelType.CLAUDE_HAIKU_4_5]: 'us-east-1',
}

Expand All @@ -55,6 +56,10 @@ export const LLM_MODEL_PRICING_MAP: Record<LlmModelType, ILlmPricing> = {
costPer1000InputTokens: 0.003,
costPer1000OutputTokens: 0.015,
},
[LlmModelType.CLAUDE_SONNET_5_5]: {
costPer1000InputTokens: 0.002,
costPer1000OutputTokens: 0.01,
},
[LlmModelType.CLAUDE_HAIKU_4_5]: {
costPer1000InputTokens: 0.001,
costPer1000OutputTokens: 0.005,
Expand Down Expand Up @@ -159,11 +164,11 @@ export const LLM_SETTINGS: Record<LlmQueryType, ILlmSettings> = {
},
},
[LlmQueryType.PROJECT_EVALUATION]: {
modelId: LlmModelType.CLAUDE_SONNET_4,
modelId: LlmModelType.CLAUDE_SONNET_5_5,
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
ulemons marked this conversation as resolved.
arguments: {
max_tokens: 2000,
anthropic_version: 'bedrock-2023-05-31',
temperature: 0,
thinking: { type: 'between_tools' },
},
},
[LlmQueryType.ONBOARDING_REQUEST_PARSING]: {
Expand Down
Loading