diff --git a/backend/app/bedrock.py b/backend/app/bedrock.py index abe87ee6b..5460e00e4 100644 --- a/backend/app/bedrock.py +++ b/backend/app/bedrock.py @@ -2,12 +2,11 @@ import logging import os -from typing import TypeGuard, Dict, Any, Optional, Tuple, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, TypeGuard from app.config import BEDROCK_PRICING from app.config import DEFAULT_GENERATION_CONFIG as DEFAULT_CLAUDE_GENERATION_CONFIG from app.config import DEFAULT_MISTRAL_GENERATION_CONFIG - from app.repositories.models.custom_bot import GenerationParamsModel from app.repositories.models.custom_bot_guardrails import BedrockGuardrailsModel from app.routes.schemas.conversation import type_model_name @@ -15,20 +14,17 @@ if TYPE_CHECKING: from app.agents.tools.agent_tool import AgentTool - from app.repositories.models.conversation import ( - SimpleMessageModel, - ContentModel, - ) + from app.repositories.models.conversation import ContentModel, SimpleMessageModel + from mypy_boto3_bedrock_runtime.literals import ConversationRoleType from mypy_boto3_bedrock_runtime.type_defs import ( - ConverseStreamRequestRequestTypeDef, - MessageTypeDef, - ConverseResponseTypeDef, ContentBlockTypeDef, + ConverseResponseTypeDef, + ConverseStreamRequestRequestTypeDef, GuardrailConverseContentBlockTypeDef, InferenceConfigurationTypeDef, + MessageTypeDef, SystemContentBlockTypeDef, ) - from mypy_boto3_bedrock_runtime.literals import ConversationRoleType logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) @@ -275,6 +271,7 @@ def get_model_id( "claude-v3-opus": "anthropic.claude-3-opus-20240229-v1:0", "claude-v3.5-sonnet": "anthropic.claude-3-5-sonnet-20240620-v1:0", "claude-v3.5-sonnet-v2": "anthropic.claude-3-5-sonnet-20241022-v2:0", + "claude-v3.7-sonnet": "anthropic.claude-3-7-sonnet-20250219-v1:0", "claude-v3.5-haiku": "anthropic.claude-3-5-haiku-20241022-v1:0", "mistral-7b-instruct": "mistral.mistral-7b-instruct-v0:2", "mixtral-8x7b-instruct": "mistral.mixtral-8x7b-instruct-v0:1", @@ -292,6 +289,7 @@ def get_model_id( "claude-v3-opus", "claude-v3.5-sonnet", "claude-v3.5-sonnet-v2", + "claude-v3.7-sonnet", "claude-v3.5-haiku", "amazon-nova-pro", "amazon-nova-lite", diff --git a/backend/app/config.py b/backend/app/config.py index 7e30e195a..2a3625a42 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -55,6 +55,7 @@ class EmbeddingConfig(TypedDict): "claude-v3-sonnet": {"input": 0.00300, "output": 0.01500}, "claude-v3.5-sonnet": {"input": 0.00300, "output": 0.01500}, "claude-v3.5-sonnet-v2": {"input": 0.00300, "output": 0.01500}, + "claude-v3.7-sonnet": {"input": 0.00300, "output": 0.01500}, "mistral-7b-instruct": {"input": 0.00015, "output": 0.0002}, "mixtral-8x7b-instruct": {"input": 0.00045, "output": 0.0007}, "mistral-large": {"input": 0.008, "output": 0.024}, @@ -72,6 +73,7 @@ class EmbeddingConfig(TypedDict): "output": 0.00240, }, "claude-v3-sonnet": {"input": 0.00300, "output": 0.01500}, + "claude-v3.7-sonnet": {"input": 0.00300, "output": 0.01500}, "claude-v3-opus": {"input": 0.01500, "output": 0.07500}, "mistral-7b-instruct": {"input": 0.00015, "output": 0.0002}, "mixtral-8x7b-instruct": {"input": 0.00045, "output": 0.0007}, @@ -104,6 +106,7 @@ class EmbeddingConfig(TypedDict): "claude-v3-sonnet": {"input": 0.00300, "output": 0.01500}, "claude-v3.5-sonnet": {"input": 0.00300, "output": 0.01500}, "claude-v3.5-sonnet-v2": {"input": 0.00300, "output": 0.01500}, + "claude-v3.7-sonnet": {"input": 0.00300, "output": 0.01500}, "claude-v3-opus": {"input": 0.01500, "output": 0.07500}, "mistral-7b-instruct": {"input": 0.00015, "output": 0.0002}, "mixtral-8x7b-instruct": {"input": 0.00045, "output": 0.0007}, diff --git a/backend/app/routes/schemas/conversation.py b/backend/app/routes/schemas/conversation.py index 3e57fccfd..15e632d54 100644 --- a/backend/app/routes/schemas/conversation.py +++ b/backend/app/routes/schemas/conversation.py @@ -11,6 +11,7 @@ "claude-v3-sonnet", "claude-v3.5-sonnet", "claude-v3.5-sonnet-v2", + "claude-v3.7-sonnet", "claude-v3.5-haiku", "claude-v3-haiku", "claude-v3-opus", diff --git a/frontend/src/constants/index.ts b/frontend/src/constants/index.ts index c6dc8ef63..0ae4e9779 100644 --- a/frontend/src/constants/index.ts +++ b/frontend/src/constants/index.ts @@ -106,6 +106,7 @@ export const AVAILABLE_MODEL_KEYS = [ 'claude-v3-sonnet', 'claude-v3.5-sonnet', 'claude-v3.5-sonnet-v2', + 'claude-v3.7-sonnet', 'claude-v3-haiku', 'claude-v3.5-haiku', 'mistral-7b-instruct', diff --git a/frontend/src/hooks/useModel.ts b/frontend/src/hooks/useModel.ts index cff89179c..9fefb120a 100644 --- a/frontend/src/hooks/useModel.ts +++ b/frontend/src/hooks/useModel.ts @@ -107,6 +107,12 @@ const useModel = (botId?: string | null, activeModels?: ActiveModels) => { description: t('model.claude-v3.5-sonnet-v2.description'), supportMediaType: CLAUDE_SUPPORTED_MEDIA_TYPES, }, + { + modelId: 'claude-v3.7-sonnet', + label: t('model.claude-v3.7-sonnet.label'), + description: t('model.claude-v3.7-sonnet.description'), + supportMediaType: CLAUDE_SUPPORTED_MEDIA_TYPES, + }, { modelId: 'claude-v3-opus', label: t('model.claude-v3-opus.label'), @@ -252,9 +258,7 @@ const useModel = (botId?: string | null, activeModels?: ActiveModels) => { } } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [ - botId, - ]); + }, [botId]); const model = useMemo(() => { return filteredModels.find( diff --git a/frontend/src/i18n/en/index.ts b/frontend/src/i18n/en/index.ts index 48702a7ee..b2d283aef 100644 --- a/frontend/src/i18n/en/index.ts +++ b/frontend/src/i18n/en/index.ts @@ -35,6 +35,11 @@ const translation = { description: 'The latest version of Claude 3.5. An enhanced model that builds on v1 with higher accuracy and performance.', }, + 'claude-v3.7-sonnet': { + label: 'Claude 3.7 Sonnet', + description: + 'Hybrid reasoning model balancing quick responses and deep analytical capabilities.', + }, 'claude-v3.5-haiku': { label: 'Claude 3.5 (Haiku) v1', description: @@ -46,15 +51,18 @@ const translation = { }, 'mistral-7b-instruct': { label: 'Mistral 7B', - description: 'Supports English text generation tasks with natural coding capabilities' + description: + 'Supports English text generation tasks with natural coding capabilities', }, 'mixtral-8x7b-instruct': { label: 'Mistral-8x7B', - 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." + 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.', }, 'mistral-large': { label: 'Mistral Large', - description: "Ideal for complex tasks that require substantial reasoning capabilities, or ones that are highly specialized, such as Synthetic Text Generation or Code Generation." + description: + 'Ideal for complex tasks that require substantial reasoning capabilities, or ones that are highly specialized, such as Synthetic Text Generation or Code Generation.', }, 'amazon-nova-pro': { label: 'Amazon Nova Pro', @@ -723,15 +731,16 @@ How would you categorize this email?`, }, advancedConfigration: { existKnowledgeBaseId: { - label: "ID for the Amazon Bedrock Knowledge Base", - description: "Please specify ID that your existing Amazon Bedrock knowledge base.", + label: 'ID for the Amazon Bedrock Knowledge Base', + description: + 'Please specify ID that your existing Amazon Bedrock knowledge base.', createNewKb: { label: 'Create New Knowledge Base', }, existing: { label: 'Use your existing knowledge base', - } - } + }, + }, }, }, error: { diff --git a/frontend/src/i18n/ja/index.ts b/frontend/src/i18n/ja/index.ts index 3072aefad..ff635f409 100644 --- a/frontend/src/i18n/ja/index.ts +++ b/frontend/src/i18n/ja/index.ts @@ -38,6 +38,10 @@ const translation = { description: 'Claude 3.5の最新バージョン。v1をさらに強化し、より高い精度とパフォーマンスを提供', }, + 'claude-v3.7-sonnet': { + label: 'Claude 3.7 Sonnet', + description: '迅速な応答と深い分析能力を両立するハイブリッド推論モデル', + }, 'claude-v3.5-haiku': { label: 'Claude 3.5 (Haiku) v1', description: 'Haiku最新バージョン。精度を保ち、高速な応答を実現', @@ -48,14 +52,17 @@ const translation = { }, 'mistral-7b-instruct': { label: 'Mistral 7B', - description: '自然なコーディング機能で英語のテキスト生成タスクをサポートします' + description: + '自然なコーディング機能で英語のテキスト生成タスクをサポートします', }, 'mixtral-8x7b-instruct': { label: 'Mistral-8x7B', - description: 'Mixtral-8x7BはMistral AIによって開発された基盤モデルで、英語、フランス語、ドイツ語、イタリア語、スペイン語のテキストをサポートし、コード生成機能を備えています。' + description: + 'Mixtral-8x7BはMistral AIによって開発された基盤モデルで、英語、フランス語、ドイツ語、イタリア語、スペイン語のテキストをサポートし、コード生成機能を備えています。', }, 'mistral-large': { - label: '実質的な推論機能を必要とする複雑なタスクや、合成テキスト生成およびコード生成などの高度に専門化されたタスクに最適です', + label: + '実質的な推論機能を必要とする複雑なタスクや、合成テキスト生成およびコード生成などの高度に専門化されたタスクに最適です', }, 'amazon-nova-pro': { label: 'Amazon Nova Pro', @@ -718,16 +725,17 @@ const translation = { }, advancedConfigration: { existKnowledgeBaseId: { - label: "既存のAmazon Bedrock Knowledge BaseのID", - description: "既存のAmazon Bedrock Knowledge Baseを使用することができる", + label: '既存のAmazon Bedrock Knowledge BaseのID', + description: + '既存のAmazon Bedrock Knowledge Baseを使用することができる', createNewKb: { label: '新規のナレッジを作成する', }, existing: { label: '外部のナレッジ(Knowledge Base)を利用する', - } + }, }, - } + }, }, error: { answerResponse: '回答中にエラーが発生しました。',