From 22851f3f2af7409004ae1b1e6e084e9a454d2392 Mon Sep 17 00:00:00 2001 From: boon Date: Wed, 27 Mar 2024 12:05:01 +0800 Subject: [PATCH 1/5] Add claude 3 to bedrock provider --- llms/providers/bedrock_anthropic.py | 6 ++++++ setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/llms/providers/bedrock_anthropic.py b/llms/providers/bedrock_anthropic.py index 8f9b4b4..bacb030 100644 --- a/llms/providers/bedrock_anthropic.py +++ b/llms/providers/bedrock_anthropic.py @@ -17,6 +17,8 @@ class BedrockAnthropicProvider(AnthropicProvider): "token_limit": 100_000, }, "anthropic.claude-v2": {"prompt": 11.02, "completion": 32.68, "token_limit": 100_000}, + "anthropic.claude-3-haiku-20240307-v1:0": {"prompt": 0.25, "completion": 1.25, "token_limit": 200_000, "output_limit": 4_096}, + "anthropic.claude-3-sonnet-20240229-v1:0": {"prompt": 3.00, "completion": 15, "token_limit": 200_000, "output_limit": 4_096}, } def __init__( @@ -54,3 +56,7 @@ def __init__( aws_region=aws_region, **async_client_kwargs, ) + + @property + def support_message_api(self): + return "claude-3" in self.model \ No newline at end of file diff --git a/setup.py b/setup.py index 2a282f4..4cbe1a4 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="pyllms", - version="0.4.3", + version="0.4.4", description="Minimal Python library to connect to LLMs (OpenAI, Anthropic, Google Palm2/Vertex, AI21, Cohere, Aleph-Alpha, HuggingfaceHub), with a built-in model performance benchmark.", long_description=long_description, long_description_content_type="text/markdown", From 6a261eb153fcaadc203189c1e6e616b81121dd79 Mon Sep 17 00:00:00 2001 From: boon Date: Wed, 27 Mar 2024 12:23:13 +0800 Subject: [PATCH 2/5] Use AnthropicBedrock from anthropic py sdk --- llms/providers/bedrock_anthropic.py | 6 +++--- setup.py | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/llms/providers/bedrock_anthropic.py b/llms/providers/bedrock_anthropic.py index bacb030..5ce721c 100644 --- a/llms/providers/bedrock_anthropic.py +++ b/llms/providers/bedrock_anthropic.py @@ -3,7 +3,7 @@ import os from typing import Union -import anthropic_bedrock +from anthropic import AnthropicBedrock, AsyncAnthropicBedrock from .anthropic import AnthropicProvider @@ -41,7 +41,7 @@ def __init__( if client_kwargs is None: client_kwargs = {} - self.client = anthropic_bedrock.AnthropicBedrock( + self.client = AnthropicBedrock( aws_access_key=aws_access_key, aws_secret_key=aws_secret_key, aws_region=aws_region, @@ -50,7 +50,7 @@ def __init__( if async_client_kwargs is None: async_client_kwargs = {} - self.async_client = anthropic_bedrock.AsyncAnthropicBedrock( + self.async_client = AsyncAnthropicBedrock( aws_access_key=aws_access_key, aws_secret_key=aws_secret_key, aws_region=aws_region, diff --git a/setup.py b/setup.py index 4cbe1a4..9e219cd 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,6 @@ "openai>=1", "tiktoken", "anthropic>=0.18", - "anthropic_bedrock", "ai21", "cohere", "aleph-alpha-client", From 4e8525bdc1cb6b25a2456ea1f3d2ba206789cbec Mon Sep 17 00:00:00 2001 From: Boon <49676590+bkiat1123@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:59:01 +0800 Subject: [PATCH 3/5] Relax protobuf version requirement --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9e219cd..a6f3b08 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ "huggingface_hub", "google-cloud-aiplatform", "prettytable", - "protobuf~=3.20.3", + "protobuf>=3.20.3", "grpcio~=1.54.2", "google-generativeai", "mistralai", From 18d8af8eea53b692e4273b6da790386f4f63c8b6 Mon Sep 17 00:00:00 2001 From: Boon <49676590+bkiat1123@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:58:03 +0800 Subject: [PATCH 4/5] Add gpt-4-turbo --- llms/providers/openai.py | 1 + 1 file changed, 1 insertion(+) diff --git a/llms/providers/openai.py b/llms/providers/openai.py index fe09a06..f31ff2c 100644 --- a/llms/providers/openai.py +++ b/llms/providers/openai.py @@ -17,6 +17,7 @@ class OpenAIProvider(BaseProvider): "gpt-4": {"prompt": 30.0, "completion": 60.0, "token_limit": 8192, "is_chat": True}, "gpt-4-1106-preview": {"prompt": 10.0, "completion": 30.0, "token_limit": 128000, "is_chat": True, "output_limit": 4_096}, "gpt-4-turbo-preview": {"prompt": 10.0, "completion": 30.0, "token_limit": 128000, "is_chat": True, "output_limit": 4_096}, + "gpt-4-turbo": {"prompt": 10.0, "completion": 30.0, "token_limit": 128000, "is_chat": True, "output_limit": 4_096}, } def __init__( From 26676df4b56f69a0dc32e07d2e8ca7b3dfa30b88 Mon Sep 17 00:00:00 2001 From: Boon <49676590+bkiat1123@users.noreply.github.com> Date: Thu, 25 Apr 2024 01:20:44 +0800 Subject: [PATCH 5/5] Correct anthropic param name --- llms/providers/anthropic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llms/providers/anthropic.py b/llms/providers/anthropic.py index 3731ade..8b70565 100644 --- a/llms/providers/anthropic.py +++ b/llms/providers/anthropic.py @@ -147,7 +147,7 @@ def _prepare_message_inputs( "messages": messages, "system": system_message, "temperature": temperature, - "max_tokens": max_tokens, + "max_tokens_to_sample": max_tokens, "stop_sequences": stop_sequences, } return model_inputs