feat: migrate to claude sonnet 4 #4

Merged
naomi merged 2 commits from feat/claude-4 into main 2025-05-22 11:15:34 -07:00
8 changed files with 250 additions and 385 deletions

View File

@ -14,16 +14,16 @@
"author": "Naomi Carrigan",
"license": "See license in LICENSE.md",
"devDependencies": {
"@nhcarrigan/eslint-config": "5.1.0",
"@nhcarrigan/eslint-config": "5.2.0",
"@nhcarrigan/typescript-config": "4.0.0",
"@types/node": "22.13.1",
"eslint": "9.20.0",
"typescript": "5.7.3"
"@types/node": "22.15.21",
"eslint": "9.27.0",
"typescript": "5.8.3"
},
"dependencies": {
"@anthropic-ai/sdk": "0.36.3",
"@anthropic-ai/sdk": "0.52.0",
"@nhcarrigan/logger": "1.0.0",
"discord.js": "14.18.0",
"fastify": "5.2.1"
"discord.js": "14.19.3",
"fastify": "5.3.3"
}
}

605
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,11 @@ import { calculateCost } from "../utils/calculateCost.js";
import { isSubscribed } from "../utils/isSubscribed.js";
import { logger } from "../utils/logger.js";
import { replyToError } from "../utils/replyToError.js";
import type { ImageBlockParam } from "@anthropic-ai/sdk/resources/index.js";
import type { Base64ImageSource } from "@anthropic-ai/sdk/resources/index.js";
const isValidContentType = (
type: string,
): type is ImageBlockParam["source"]["media_type"] => {
): type is Base64ImageSource["media_type"] => {
return [
"image/jpg",
"image/jpeg",
@ -100,7 +100,7 @@ export const alt = async(
role: "user",
},
],
model: "claude-3-5-sonnet-latest",
model: "claude-sonnet-4-20250514",
system: `${personality} Your role in this conversation is to generate descriptive and accessible alt-text for the user's image. Be as descriptive as possible. Do not include ANYTHING in your response EXCEPT the actual alt-text. Wrap the text in a multi-line code block for easy copying.`,
temperature: 1,
});

View File

@ -31,7 +31,7 @@ export const evaluate = async(
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
max_tokens: 2000,
messages: [ { content: code, role: "user" } ],
model: "claude-3-5-sonnet-latest",
model: "claude-sonnet-4-20250514",
system: `${personality} Your role in this conversation is to evaluate the user's code and provide the result. Wrap ONLY THE CODE RESULT in a multi-line code block for easy copying.`,
temperature: 1,
});

View File

@ -32,7 +32,7 @@ export const mood = async(
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
max_tokens: 2000,
messages: [ { content: prompt, role: "user" } ],
model: "claude-3-5-sonnet-latest",
model: "claude-sonnet-4-20250514",
system: `${personality} Your role in this conversation is to analyse the text the user provides for the overall sentiment and mood of the author.`,
temperature: 1,
});

View File

@ -32,7 +32,7 @@ export const proofread = async(
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
max_tokens: 2000,
messages: [ { content: prompt, role: "user" } ],
model: "claude-3-5-sonnet-latest",
model: "claude-sonnet-4-20250514",
system: `${personality} Your role in this conversation is to proofread the text the user has provided. You should identify spelling and grammatical errors using British English.`,
temperature: 1,
});

View File

@ -32,7 +32,7 @@ export const query = async(
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
max_tokens: 2000,
messages: [ { content: prompt, role: "user" } ],
model: "claude-3-5-sonnet-latest",
model: "claude-sonnet-4-20250514",
system: `${personality} Your role in this conversation is to answer the user's question to the best of your abilities. When possible, include links to relevant sources.`,
temperature: 1,
});

View File

@ -32,7 +32,7 @@ export const summarise = async(
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
max_tokens: 2000,
messages: [ { content: prompt, role: "user" } ],
model: "claude-3-5-sonnet-latest",
model: "claude-sonnet-4-20250514",
system: `${personality} Your role in this conversation is to summarise the text the user has provided. Your goal is to reach 250 words or less. Wrap ONLY THE SUMMARY in multi-line code block so it is easy to copy.`,
temperature: 1,
});