set claude temperature, update claude default model

This commit is contained in:
cce 2024-11-27 21:00:04 -05:00
parent b42a33d9a8
commit fafbd60a78
No known key found for this signature in database

View File

@ -19,12 +19,13 @@ class Claude(Base):
super().__init__(key, language) super().__init__(key, language)
self.api_url = f"{api_base}" if api_base else "https://api.anthropic.com" self.api_url = f"{api_base}" if api_base else "https://api.anthropic.com"
self.client = Anthropic(base_url=api_base, api_key=key, timeout=20) self.client = Anthropic(base_url=api_base, api_key=key, timeout=20)
self.model = "claude-3-5-sonnet-20241022" # default it for now
self.language = language self.language = language
self.prompt_template = ( self.prompt_template = (
prompt_template prompt_template
or "\n\nHuman: Help me translate the text within triple backticks into {language} and provide only the translated result.\n```{text}```\n\nAssistant: " or "\n\nHuman: Help me translate the text within triple backticks into {language} and provide only the translated result.\n```{text}```\n\nAssistant: "
) )
self.temperature = temperature
def rotate_key(self): def rotate_key(self):
pass pass
@ -40,7 +41,8 @@ class Claude(Base):
r = self.client.messages.create( r = self.client.messages.create(
max_tokens=4096, max_tokens=4096,
messages=message, messages=message,
model="claude-3-haiku-20240307", # default it for now temperature=self.temperature,
model=self.model,
) )
t_text = r.content[0].text t_text = r.content[0].text
# api limit rate and spider rule # api limit rate and spider rule