Skip to content

Commit

Permalink
set claude temperature, update claude default model (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
cce authored Nov 28, 2024
1 parent b42a33d commit a36b488
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions book_maker/translator/claude_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a36b488

Please sign in to comment.