Skip to content

Commit 27bdd94

Browse files
committed
server/llm: update llm packages
1 parent 8be3ca9 commit 27bdd94

File tree

7 files changed

+97
-84
lines changed

7 files changed

+97
-84
lines changed

src/.claude/settings.local.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
"Bash(pnpm tsc:*)",
55
"Bash(pnpm build:*)",
66
"Bash(git add:*)",
7-
"Bash(git commit:*)"
7+
"Bash(git commit:*)",
8+
"Bash(node:*)",
9+
"Bash(grep:*)",
10+
"Bash(find:*)",
11+
"WebFetch(domain:github.com)",
12+
"WebFetch(domain:cocalc.com)",
13+
"WebFetch(domain:doc.cocalc.com)",
14+
"Bash(npm show:*)"
815
],
916
"deny": []
1017
}
11-
}
18+
}

src/packages/pnpm-lock.yaml

Lines changed: 44 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/packages/server/llm/anthropic.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,11 @@ import { numTokens } from "./chatgpt-numtokens";
1919
const log = getLogger("llm:anthropic");
2020

2121
function getModelName(model: AnthropicModel): string {
22-
// The -4k and -8k variants have a limited context window (by us here) while offered for free
23-
if (model === "claude-3-sonnet-4k") {
24-
model = "claude-3-sonnet";
25-
} else if (model === "claude-3-haiku-8k") {
26-
model = "claude-3-haiku";
27-
} else if (model === "claude-3-opus-8k") {
28-
model = "claude-3-opus";
29-
} else if (model === "claude-3-5-sonnet-4k") {
30-
model = "claude-3-5-sonnet";
22+
const id = ANTHROPIC_VERSION[model];
23+
if (id == null) {
24+
throw new Error(`Anthropic model ${model} is no longer supported`);
3125
}
32-
// now we have a valid name, and we have to append their static version number
33-
return `${model}-${ANTHROPIC_VERSION[model]}`;
26+
return id;
3427
}
3528

3629
interface AnthropicOpts {

src/packages/server/llm/google-genai-client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ export class GoogleGenAIClient {
110110
model: modelName,
111111
apiKey: this.apiKey,
112112
maxOutputTokens: maxTokens,
113+
// Only enable thinking tokens for Gemini 2.5 models
114+
...(modelName === "gemini-2.5-flash" || modelName === "gemini-2.5-pro"
115+
? { maxReasoningTokens: 1024 }
116+
: {}),
113117
streaming: true,
114118
});
115119

@@ -155,8 +159,9 @@ export class GoogleGenAIClient {
155159
...history.map(({ content }) => content),
156160
]);
157161

158-
const { totalTokens: completion_tokens } =
159-
await geminiPro.countTokens(output);
162+
const { totalTokens: completion_tokens } = await geminiPro.countTokens(
163+
output,
164+
);
160165

161166
log.debug("chatGemini successful", { prompt_tokens, completion_tokens });
162167

src/packages/server/llm/test/00.test.ts renamed to src/packages/server/llm/test/models.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ test_llm("google")("Google GenAI", () => {
112112
test("gemini 2.0 flash lite works", async () => {
113113
llmGoogle("gemini-2.0-flash-lite-8k");
114114
});
115+
test("gemini 2.5 flash works", async () => {
116+
llmGoogle("gemini-2.5-flash-8k");
117+
});
118+
test("gemini 2.5 pro works", async () => {
119+
llmGoogle("gemini-2.5-pro-8k");
120+
});
115121
});
116122

117123
test_llm("mistralai")("Mistral AI", () => {
@@ -129,12 +135,14 @@ test_llm("mistralai")("Mistral AI", () => {
129135
});
130136

131137
test_llm("anthropic")("Anthropic", () => {
132-
const haiku: AnthropicModel = "claude-3-haiku";
133-
const sonnet: AnthropicModel = "claude-3-5-sonnet-4k";
134-
const opus: AnthropicModel = "claude-3-opus-8k";
138+
const haiku: AnthropicModel = "claude-3-5-haiku-8k";
139+
const sonnet: AnthropicModel = "claude-4-sonnet-8k";
140+
const opus: AnthropicModel = "claude-4-opus-8k";
135141

136142
test("model", () => {
137143
expect(isAnthropicModel(haiku)).toBe(true);
144+
expect(isAnthropicModel(sonnet)).toBe(true);
145+
expect(isAnthropicModel(opus)).toBe(true);
138146
});
139147

140148
test("haiku", async () => {

src/packages/server/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@
5555
"@google-cloud/storage-transfer": "^3.3.0",
5656
"@google/generative-ai": "^0.14.0",
5757
"@isaacs/ttlcache": "^1.4.1",
58-
"@langchain/anthropic": "^0.3.18",
59-
"@langchain/core": "^0.3.46",
60-
"@langchain/google-genai": "^0.2.4",
61-
"@langchain/mistralai": "^0.2.0",
62-
"@langchain/ollama": "^0.2.0",
63-
"@langchain/openai": "^0.5.5",
58+
"@langchain/anthropic": "^0.3.24",
59+
"@langchain/core": "^0.3.64",
60+
"@langchain/google-genai": "^0.2.15",
61+
"@langchain/mistralai": "^0.2.1",
62+
"@langchain/ollama": "^0.2.3",
63+
"@langchain/openai": "^0.6.1",
6464
"@node-saml/passport-saml": "^5.0.1",
6565
"@passport-js/passport-twitter": "^1.0.8",
6666
"@passport-next/passport-google-oauth2": "^1.0.0",
@@ -97,7 +97,7 @@
9797
"nanoid": "^3.3.8",
9898
"node-zendesk": "^5.0.13",
9999
"nodemailer": "^6.9.16",
100-
"openai": "^4.95.1",
100+
"openai": "^4.104.0",
101101
"parse-domain": "^5.0.0",
102102
"passport": "^0.6.0",
103103
"passport-activedirectory": "^1.0.4",

0 commit comments

Comments
 (0)