Skip to content

Commit

Permalink
feat: Claude 3.7 Sonnet
Browse files Browse the repository at this point in the history
  • Loading branch information
ieedan committed Feb 25, 2025
1 parent 8e08856 commit 3a0af9e
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 116 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-singers-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"jsrepo": minor
---

feat: Update options for `Update with AI` to use Claude 3.7 Sonnet.
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
"@types/validate-npm-package-name": "^4.0.2",
"tsup": "^8.3.6",
"typescript": "^5.7.3",
"vitest": "^3.0.6"
"vitest": "^3.0.7"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.36.3",
"@anthropic-ai/sdk": "^0.37.0",
"@biomejs/js-api": "^0.7.1",
"@biomejs/wasm-nodejs": "^1.9.4",
"@clack/prompts": "^0.10.0",
Expand All @@ -65,7 +65,7 @@
"is-unicode-supported": "^2.1.0",
"node-fetch": "^3.3.2",
"octokit": "^4.1.2",
"ollama": "^0.5.13",
"ollama": "^0.5.14",
"openai": "^4.85.4",
"package-manager-detector": "^0.2.9",
"parse5": "^7.2.1",
Expand All @@ -75,7 +75,7 @@
"sisteransi": "^1.0.5",
"svelte": "^5.20.4",
"ts-morph": "^25.0.1",
"valibot": "1.0.0-rc.1",
"valibot": "1.0.0-rc.2",
"validate-npm-package-name": "^6.0.0",
"vue": "^3.5.13"
}
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/utils/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export interface Model {
}) => Promise<UpdateFileResult>;
}

export type ModelName = 'Claude 3.5 Sonnet' | 'ChatGPT 4o-mini' | 'ChatGPT 4o' | 'Phi4';
export type ModelName = 'Claude 3.7 Sonnet' | 'ChatGPT 4o-mini' | 'ChatGPT 4o' | 'Phi4';

type Prompt = {
system: string;
message: string;
};

const models: Record<ModelName, Model> = {
'Claude 3.5 Sonnet': {
'Claude 3.7 Sonnet': {
updateFile: async ({
originalFile,
newFile,
Expand All @@ -52,7 +52,7 @@ const models: Record<ModelName, Model> = {
}) => {
const apiKey = await getApiKey('Anthropic');

if (!verbose) loading.start(`Asking ${'Claude 3.5 Sonnet'}`);
if (!verbose) loading.start(`Asking ${'Claude 3.7 Sonnet'}`);

const prompt = createUpdatePrompt({
originalFile,
Expand All @@ -62,18 +62,18 @@ const models: Record<ModelName, Model> = {
});

verbose?.(
`Prompting ${'Claude 3.5 Sonnet'} with:\n${JSON.stringify(prompt, null, '\t')}`
`Prompting ${'Claude 3.7 Sonnet'} with:\n${JSON.stringify(prompt, null, '\t')}`
);

const text = await getNextCompletionAnthropic({
model: 'claude-3-5-sonnet-latest',
model: 'claude-3-7-sonnet-latest',
prompt,
apiKey,
messages,
maxTokens: (originalFile.content.length + newFile.content.length) * 2,
});

if (!verbose) loading.stop(`${'Claude 3.5 Sonnet'} updated the file`);
if (!verbose) loading.stop(`${'Claude 3.7 Sonnet'} updated the file`);

if (!text) return { content: newFile.content, prompt: prompt.message };

Expand Down
Loading

0 comments on commit 3a0af9e

Please sign in to comment.