Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Claude 3.7 Sonnet + Add guidance for dynamic registries #460

Merged
merged 4 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
24 changes: 6 additions & 18 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@
"bugs": {
"url": "https://github.com/ieedan/jsrepo/issues"
},
"keywords": [
"repo",
"cli",
"svelte",
"vue",
"typescript",
"javascript",
"shadcn",
"registry"
],
"keywords": ["repo", "cli", "svelte", "vue", "typescript", "javascript", "shadcn", "registry"],
"type": "module",
"exports": {
".": {
Expand All @@ -34,10 +25,7 @@
},
"bin": "./dist/index.js",
"main": "./dist/index.js",
"files": [
"./schemas/**/*",
"dist/**/*"
],
"files": ["./schemas/**/*", "dist/**/*"],
"scripts": {
"start": "tsup --silent && node ./dist/index.js",
"build": "tsup",
Expand All @@ -56,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 @@ -77,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 @@ -87,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
Loading