Skip to content

Commit

Permalink
decrease tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
siriustaikun committed Aug 31, 2024
1 parent 702118a commit 7c5d21f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion functions/bot/components/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const translate = async function handler(
const res = await anthropic.messages.create({
model: "claude-3-5-sonnet-20240620",
// max_tokens: 1024,
max_tokens: 1024,
max_tokens: 450,
messages: [
{ role: "user", content: `${await loadTrainingSample()}${sampleText}` },
],
Expand All @@ -65,6 +65,11 @@ export const translate = async function handler(
txt = JSON.parse(txt);
} catch (e) {}

try {
// remove starting and ending quote
txt = txt.replace(/^"|"$/g, "");
} catch (e) {}

return txt
.replace("\n\n", "")
.replace(/\_/g, "\\_")
Expand Down

0 comments on commit 7c5d21f

Please sign in to comment.