From a36b488ca724df2955f97eaec707bb71e35f2e6a Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:06:40 -0500 Subject: [PATCH] set claude temperature, update claude default model (#434) --- book_maker/translator/claude_translator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/book_maker/translator/claude_translator.py b/book_maker/translator/claude_translator.py index 94b153d6..f21da6f9 100644 --- a/book_maker/translator/claude_translator.py +++ b/book_maker/translator/claude_translator.py @@ -19,12 +19,13 @@ def __init__( super().__init__(key, language) 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.model = "claude-3-5-sonnet-20241022" # default it for now self.language = language self.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: " ) + self.temperature = temperature def rotate_key(self): pass @@ -40,7 +41,8 @@ def translate(self, text): r = self.client.messages.create( max_tokens=4096, messages=message, - model="claude-3-haiku-20240307", # default it for now + temperature=self.temperature, + model=self.model, ) t_text = r.content[0].text # api limit rate and spider rule