Skip to content

Commit 57c55b4

Browse files
authored
feat: add support for Claude 3.7 Sonnet model in backend and frontend (#742)
1 parent a890a5f commit 57c55b4

File tree

7 files changed

+51
-27
lines changed

7 files changed

+51
-27
lines changed

backend/app/bedrock.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,29 @@
22

33
import logging
44
import os
5-
from typing import TypeGuard, Dict, Any, Optional, Tuple, TYPE_CHECKING
5+
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, TypeGuard
66

77
from app.config import BEDROCK_PRICING
88
from app.config import DEFAULT_GENERATION_CONFIG as DEFAULT_CLAUDE_GENERATION_CONFIG
99
from app.config import DEFAULT_MISTRAL_GENERATION_CONFIG
10-
1110
from app.repositories.models.custom_bot import GenerationParamsModel
1211
from app.repositories.models.custom_bot_guardrails import BedrockGuardrailsModel
1312
from app.routes.schemas.conversation import type_model_name
1413
from app.utils import get_bedrock_runtime_client
1514

1615
if TYPE_CHECKING:
1716
from app.agents.tools.agent_tool import AgentTool
18-
from app.repositories.models.conversation import (
19-
SimpleMessageModel,
20-
ContentModel,
21-
)
17+
from app.repositories.models.conversation import ContentModel, SimpleMessageModel
18+
from mypy_boto3_bedrock_runtime.literals import ConversationRoleType
2219
from mypy_boto3_bedrock_runtime.type_defs import (
23-
ConverseStreamRequestRequestTypeDef,
24-
MessageTypeDef,
25-
ConverseResponseTypeDef,
2620
ContentBlockTypeDef,
21+
ConverseResponseTypeDef,
22+
ConverseStreamRequestRequestTypeDef,
2723
GuardrailConverseContentBlockTypeDef,
2824
InferenceConfigurationTypeDef,
25+
MessageTypeDef,
2926
SystemContentBlockTypeDef,
3027
)
31-
from mypy_boto3_bedrock_runtime.literals import ConversationRoleType
3228

3329
logger = logging.getLogger(__name__)
3430
logger.setLevel(logging.INFO)
@@ -275,6 +271,7 @@ def get_model_id(
275271
"claude-v3-opus": "anthropic.claude-3-opus-20240229-v1:0",
276272
"claude-v3.5-sonnet": "anthropic.claude-3-5-sonnet-20240620-v1:0",
277273
"claude-v3.5-sonnet-v2": "anthropic.claude-3-5-sonnet-20241022-v2:0",
274+
"claude-v3.7-sonnet": "anthropic.claude-3-7-sonnet-20250219-v1:0",
278275
"claude-v3.5-haiku": "anthropic.claude-3-5-haiku-20241022-v1:0",
279276
"mistral-7b-instruct": "mistral.mistral-7b-instruct-v0:2",
280277
"mixtral-8x7b-instruct": "mistral.mixtral-8x7b-instruct-v0:1",
@@ -292,6 +289,7 @@ def get_model_id(
292289
"claude-v3-opus",
293290
"claude-v3.5-sonnet",
294291
"claude-v3.5-sonnet-v2",
292+
"claude-v3.7-sonnet",
295293
"claude-v3.5-haiku",
296294
"amazon-nova-pro",
297295
"amazon-nova-lite",

backend/app/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class EmbeddingConfig(TypedDict):
5555
"claude-v3-sonnet": {"input": 0.00300, "output": 0.01500},
5656
"claude-v3.5-sonnet": {"input": 0.00300, "output": 0.01500},
5757
"claude-v3.5-sonnet-v2": {"input": 0.00300, "output": 0.01500},
58+
"claude-v3.7-sonnet": {"input": 0.00300, "output": 0.01500},
5859
"mistral-7b-instruct": {"input": 0.00015, "output": 0.0002},
5960
"mixtral-8x7b-instruct": {"input": 0.00045, "output": 0.0007},
6061
"mistral-large": {"input": 0.008, "output": 0.024},
@@ -72,6 +73,7 @@ class EmbeddingConfig(TypedDict):
7273
"output": 0.00240,
7374
},
7475
"claude-v3-sonnet": {"input": 0.00300, "output": 0.01500},
76+
"claude-v3.7-sonnet": {"input": 0.00300, "output": 0.01500},
7577
"claude-v3-opus": {"input": 0.01500, "output": 0.07500},
7678
"mistral-7b-instruct": {"input": 0.00015, "output": 0.0002},
7779
"mixtral-8x7b-instruct": {"input": 0.00045, "output": 0.0007},
@@ -104,6 +106,7 @@ class EmbeddingConfig(TypedDict):
104106
"claude-v3-sonnet": {"input": 0.00300, "output": 0.01500},
105107
"claude-v3.5-sonnet": {"input": 0.00300, "output": 0.01500},
106108
"claude-v3.5-sonnet-v2": {"input": 0.00300, "output": 0.01500},
109+
"claude-v3.7-sonnet": {"input": 0.00300, "output": 0.01500},
107110
"claude-v3-opus": {"input": 0.01500, "output": 0.07500},
108111
"mistral-7b-instruct": {"input": 0.00015, "output": 0.0002},
109112
"mixtral-8x7b-instruct": {"input": 0.00045, "output": 0.0007},

backend/app/routes/schemas/conversation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"claude-v3-sonnet",
1212
"claude-v3.5-sonnet",
1313
"claude-v3.5-sonnet-v2",
14+
"claude-v3.7-sonnet",
1415
"claude-v3.5-haiku",
1516
"claude-v3-haiku",
1617
"claude-v3-opus",

frontend/src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const AVAILABLE_MODEL_KEYS = [
106106
'claude-v3-sonnet',
107107
'claude-v3.5-sonnet',
108108
'claude-v3.5-sonnet-v2',
109+
'claude-v3.7-sonnet',
109110
'claude-v3-haiku',
110111
'claude-v3.5-haiku',
111112
'mistral-7b-instruct',

frontend/src/hooks/useModel.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ const useModel = (botId?: string | null, activeModels?: ActiveModels) => {
107107
description: t('model.claude-v3.5-sonnet-v2.description'),
108108
supportMediaType: CLAUDE_SUPPORTED_MEDIA_TYPES,
109109
},
110+
{
111+
modelId: 'claude-v3.7-sonnet',
112+
label: t('model.claude-v3.7-sonnet.label'),
113+
description: t('model.claude-v3.7-sonnet.description'),
114+
supportMediaType: CLAUDE_SUPPORTED_MEDIA_TYPES,
115+
},
110116
{
111117
modelId: 'claude-v3-opus',
112118
label: t('model.claude-v3-opus.label'),
@@ -252,9 +258,7 @@ const useModel = (botId?: string | null, activeModels?: ActiveModels) => {
252258
}
253259
}
254260
// eslint-disable-next-line react-hooks/exhaustive-deps
255-
}, [
256-
botId,
257-
]);
261+
}, [botId]);
258262

259263
const model = useMemo(() => {
260264
return filteredModels.find(

frontend/src/i18n/en/index.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const translation = {
3535
description:
3636
'The latest version of Claude 3.5. An enhanced model that builds on v1 with higher accuracy and performance.',
3737
},
38+
'claude-v3.7-sonnet': {
39+
label: 'Claude 3.7 Sonnet',
40+
description:
41+
'Hybrid reasoning model balancing quick responses and deep analytical capabilities.',
42+
},
3843
'claude-v3.5-haiku': {
3944
label: 'Claude 3.5 (Haiku) v1',
4045
description:
@@ -46,15 +51,18 @@ const translation = {
4651
},
4752
'mistral-7b-instruct': {
4853
label: 'Mistral 7B',
49-
description: 'Supports English text generation tasks with natural coding capabilities'
54+
description:
55+
'Supports English text generation tasks with natural coding capabilities',
5056
},
5157
'mixtral-8x7b-instruct': {
5258
label: 'Mistral-8x7B',
53-
description: "A popular, high-quality, sparse Mixture-of-Experts (MoE) model, that is ideal for text summarization, question and answering, text classification, text completion, and code generation."
59+
description:
60+
'A popular, high-quality, sparse Mixture-of-Experts (MoE) model, that is ideal for text summarization, question and answering, text classification, text completion, and code generation.',
5461
},
5562
'mistral-large': {
5663
label: 'Mistral Large',
57-
description: "Ideal for complex tasks that require substantial reasoning capabilities, or ones that are highly specialized, such as Synthetic Text Generation or Code Generation."
64+
description:
65+
'Ideal for complex tasks that require substantial reasoning capabilities, or ones that are highly specialized, such as Synthetic Text Generation or Code Generation.',
5866
},
5967
'amazon-nova-pro': {
6068
label: 'Amazon Nova Pro',
@@ -723,15 +731,16 @@ How would you categorize this email?`,
723731
},
724732
advancedConfigration: {
725733
existKnowledgeBaseId: {
726-
label: "ID for the Amazon Bedrock Knowledge Base",
727-
description: "Please specify ID that your existing Amazon Bedrock knowledge base.",
734+
label: 'ID for the Amazon Bedrock Knowledge Base',
735+
description:
736+
'Please specify ID that your existing Amazon Bedrock knowledge base.',
728737
createNewKb: {
729738
label: 'Create New Knowledge Base',
730739
},
731740
existing: {
732741
label: 'Use your existing knowledge base',
733-
}
734-
}
742+
},
743+
},
735744
},
736745
},
737746
error: {

frontend/src/i18n/ja/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const translation = {
3838
description:
3939
'Claude 3.5の最新バージョン。v1をさらに強化し、より高い精度とパフォーマンスを提供',
4040
},
41+
'claude-v3.7-sonnet': {
42+
label: 'Claude 3.7 Sonnet',
43+
description: '迅速な応答と深い分析能力を両立するハイブリッド推論モデル',
44+
},
4145
'claude-v3.5-haiku': {
4246
label: 'Claude 3.5 (Haiku) v1',
4347
description: 'Haiku最新バージョン。精度を保ち、高速な応答を実現',
@@ -48,14 +52,17 @@ const translation = {
4852
},
4953
'mistral-7b-instruct': {
5054
label: 'Mistral 7B',
51-
description: '自然なコーディング機能で英語のテキスト生成タスクをサポートします'
55+
description:
56+
'自然なコーディング機能で英語のテキスト生成タスクをサポートします',
5257
},
5358
'mixtral-8x7b-instruct': {
5459
label: 'Mistral-8x7B',
55-
description: 'Mixtral-8x7BはMistral AIによって開発された基盤モデルで、英語、フランス語、ドイツ語、イタリア語、スペイン語のテキストをサポートし、コード生成機能を備えています。'
60+
description:
61+
'Mixtral-8x7BはMistral AIによって開発された基盤モデルで、英語、フランス語、ドイツ語、イタリア語、スペイン語のテキストをサポートし、コード生成機能を備えています。',
5662
},
5763
'mistral-large': {
58-
label: '実質的な推論機能を必要とする複雑なタスクや、合成テキスト生成およびコード生成などの高度に専門化されたタスクに最適です',
64+
label:
65+
'実質的な推論機能を必要とする複雑なタスクや、合成テキスト生成およびコード生成などの高度に専門化されたタスクに最適です',
5966
},
6067
'amazon-nova-pro': {
6168
label: 'Amazon Nova Pro',
@@ -718,16 +725,17 @@ const translation = {
718725
},
719726
advancedConfigration: {
720727
existKnowledgeBaseId: {
721-
label: "既存のAmazon Bedrock Knowledge BaseのID",
722-
description: "既存のAmazon Bedrock Knowledge Baseを使用することができる",
728+
label: '既存のAmazon Bedrock Knowledge BaseのID',
729+
description:
730+
'既存のAmazon Bedrock Knowledge Baseを使用することができる',
723731
createNewKb: {
724732
label: '新規のナレッジを作成する',
725733
},
726734
existing: {
727735
label: '外部のナレッジ(Knowledge Base)を利用する',
728-
}
736+
},
729737
},
730-
}
738+
},
731739
},
732740
error: {
733741
answerResponse: '回答中にエラーが発生しました。',

0 commit comments

Comments
 (0)