feat: add anthropic claude-2.1 support (#1591)

This commit is contained in:
takatost 2023-11-22 01:46:19 +08:00 • committed by GitHub
commit 4a55d5729d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 13 deletions

View file

@ -32,9 +32,12 @@ class AnthropicProvider(BaseModelProvider):
if model_type == ModelType.TEXT_GENERATION:
return [
{
'id': 'claude-instant-1',
'name': 'claude-instant-1',
'id': 'claude-2.1',
'name': 'claude-2.1',
'mode': ModelMode.CHAT.value,
'features': [
ModelFeature.AGENT_THOUGHT.value
]
},
{
'id': 'claude-2',
@ -44,6 +47,11 @@ class AnthropicProvider(BaseModelProvider):
ModelFeature.AGENT_THOUGHT.value
]
},
{
'id': 'claude-instant-1',
'name': 'claude-instant-1',
'mode': ModelMode.CHAT.value,
},
]
else:
return []
@ -73,12 +81,18 @@ class AnthropicProvider(BaseModelProvider):
:param model_type:
:return:
"""
model_max_tokens = {
'claude-instant-1': 100000,
'claude-2': 100000,
'claude-2.1': 200000,
}
return ModelKwargsRules(
temperature=KwargRule[float](min=0, max=1, default=1, precision=2),
top_p=KwargRule[float](min=0, max=1, default=0.7, precision=2),
presence_penalty=KwargRule[float](enabled=False),
frequency_penalty=KwargRule[float](enabled=False),
max_tokens=KwargRule[int](alias="max_tokens_to_sample", min=10, max=100000, default=256, precision=0),
max_tokens=KwargRule[int](alias="max_tokens_to_sample", min=10, max=model_max_tokens.get(model_name, 100000), default=256, precision=0),
)
@classmethod

View file

@ -23,8 +23,14 @@
"currency": "USD"
},
"claude-2": {
"prompt": "11.02",
"completion": "32.68",
"prompt": "8.00",
"completion": "24.00",
"unit": "0.000001",
"currency": "USD"
},
"claude-2.1": {
"prompt": "8.00",
"completion": "24.00",
"unit": "0.000001",
"currency": "USD"
}