From 7c520b52c16c69beb24c789d282bf6c99f7a4248 Mon Sep 17 00:00:00 2001 From: crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:38:55 +0800 Subject: [PATCH] feat: update aws bedrock (#3326) Co-authored-by: chenhe --- .../bedrock/llm/amazon.titan-text-express-v1.yaml | 2 -- .../bedrock/llm/amazon.titan-text-lite-v1.yaml | 2 -- .../model_providers/bedrock/llm/anthropic.claude-v1.yaml | 1 + .../bedrock/llm/cohere.command-light-text-v14.yaml | 2 +- .../bedrock/llm/cohere.command-text-v14.yaml | 6 +++--- api/core/model_runtime/model_providers/bedrock/llm/llm.py | 6 +----- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-express-v1.yaml b/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-express-v1.yaml index 64f992b913..543c16d5cd 100644 --- a/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-express-v1.yaml +++ b/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-express-v1.yaml @@ -2,8 +2,6 @@ model: amazon.titan-text-express-v1 label: en_US: Titan Text G1 - Express model_type: llm -features: - - agent-thought model_properties: mode: chat context_size: 8192 diff --git a/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-lite-v1.yaml b/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-lite-v1.yaml index 69b298b571..2c6151c239 100644 --- a/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-lite-v1.yaml +++ b/api/core/model_runtime/model_providers/bedrock/llm/amazon.titan-text-lite-v1.yaml @@ -2,8 +2,6 @@ model: amazon.titan-text-lite-v1 label: en_US: Titan Text G1 - Lite model_type: llm -features: - - agent-thought model_properties: mode: chat context_size: 4096 diff --git a/api/core/model_runtime/model_providers/bedrock/llm/anthropic.claude-v1.yaml b/api/core/model_runtime/model_providers/bedrock/llm/anthropic.claude-v1.yaml index cb2271d401..6a714b1055 100644 --- a/api/core/model_runtime/model_providers/bedrock/llm/anthropic.claude-v1.yaml +++ b/api/core/model_runtime/model_providers/bedrock/llm/anthropic.claude-v1.yaml @@ -50,3 +50,4 @@ pricing: output: '0.024' unit: '0.001' currency: USD +deprecated: true diff --git a/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-light-text-v14.yaml b/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-light-text-v14.yaml index 1fad910058..7450009551 100644 --- a/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-light-text-v14.yaml +++ b/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-light-text-v14.yaml @@ -22,7 +22,7 @@ parameter_rules: min: 0 max: 500 default: 0 - - name: max_tokens_to_sample + - name: max_tokens use_template: max_tokens required: true default: 4096 diff --git a/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-text-v14.yaml b/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-text-v14.yaml index ed775afd7a..6aea5be170 100644 --- a/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-text-v14.yaml +++ b/api/core/model_runtime/model_providers/bedrock/llm/cohere.command-text-v14.yaml @@ -8,9 +8,9 @@ model_properties: parameter_rules: - name: temperature use_template: temperature - - name: top_p + - name: p use_template: top_p - - name: top_k + - name: k label: zh_Hans: 取样数量 en_US: Top k @@ -19,7 +19,7 @@ parameter_rules: zh_Hans: 仅从每个后续标记的前 K 个选项中采样。 en_US: Only sample from the top K options for each subsequent token. required: false - - name: max_tokens_to_sample + - name: max_tokens use_template: max_tokens required: true default: 4096 diff --git a/api/core/model_runtime/model_providers/bedrock/llm/llm.py b/api/core/model_runtime/model_providers/bedrock/llm/llm.py index 3dbbcb9b4f..0b0959eaa0 100644 --- a/api/core/model_runtime/model_providers/bedrock/llm/llm.py +++ b/api/core/model_runtime/model_providers/bedrock/llm/llm.py @@ -503,7 +503,7 @@ class BedrockLargeLanguageModel(LargeLanguageModel): if model_prefix == "amazon": payload["textGenerationConfig"] = { **model_parameters } - payload["textGenerationConfig"]["stopSequences"] = ["User:"] + (stop if stop else []) + payload["textGenerationConfig"]["stopSequences"] = ["User:"] payload["inputText"] = self._convert_messages_to_prompt(prompt_messages, model_prefix) @@ -513,10 +513,6 @@ class BedrockLargeLanguageModel(LargeLanguageModel): payload["maxTokens"] = model_parameters.get("maxTokens") payload["prompt"] = self._convert_messages_to_prompt(prompt_messages, model_prefix) - # jurassic models only support a single stop sequence - if stop: - payload["stopSequences"] = stop[0] - if model_parameters.get("presencePenalty"): payload["presencePenalty"] = {model_parameters.get("presencePenalty")} if model_parameters.get("frequencyPenalty"):