Skip to content

Commit d54e588

Browse files
committed
chore: upgrade the vercel sdk, use new azure URL and remove ollama
1 parent e91a95a commit d54e588

File tree

5 files changed

+15
-102
lines changed

5 files changed

+15
-102
lines changed

.github/workflows/accuracy-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
MDB_OPEN_AI_API_KEY: ${{ secrets.ACCURACY_OPEN_AI_API_KEY }}
2222
MDB_GEMINI_API_KEY: ${{ secrets.ACCURACY_GEMINI_API_KEY }}
2323
MDB_AZURE_OPEN_AI_API_KEY: ${{ secrets.ACCURACY_AZURE_OPEN_AI_API_KEY }}
24-
MDB_AZURE_OPEN_AI_API_URL: ${{ vars.ACCURACY_AZURE_OPEN_AI_API_URL }}
24+
MDB_AZURE_OPEN_AI_API_URL: ${{ vars.ACCURACY_AZURE_OPEN_AI_API_URL_V2 }}
2525
MDB_ACCURACY_MDB_URL: ${{ secrets.ACCURACY_MDB_CONNECTION_STRING }}
2626
MDB_ACCURACY_MDB_DB: ${{ vars.ACCURACY_MDB_DB }}
2727
MDB_ACCURACY_MDB_COLLECTION: ${{ vars.ACCURACY_MDB_COLLECTION }}

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"knip": "^5.63.1",
8585
"mongodb": "^6.19.0",
8686
"mongodb-runner": "^5.9.2",
87-
"ollama-ai-provider": "^1.2.0",
8887
"openapi-types": "^12.1.3",
8988
"openapi-typescript": "^7.9.1",
9089
"prettier": "^3.6.2",

tests/accuracy/sdk/agent.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { LanguageModelV1, experimental_createMCPClient } from "ai";
2-
import { generateText } from "ai";
1+
import type { LanguageModel, experimental_createMCPClient } from "ai";
2+
import { stepCountIs, generateText } from "ai";
33
import type { Model } from "./models.js";
44

55
const systemPrompt = [
@@ -39,11 +39,11 @@ export interface Agent<Model = unknown, Tools = unknown, Result = unknown> {
3939

4040
export function getVercelToolCallingAgent(
4141
requestedSystemPrompt?: string
42-
): Agent<Model<LanguageModelV1>, VercelMCPClientTools, VercelAgentPromptResult> {
42+
): Agent<Model<LanguageModel>, VercelMCPClientTools, VercelAgentPromptResult> {
4343
return {
4444
async prompt(
4545
prompt: PromptDefinition,
46-
model: Model<LanguageModelV1>,
46+
model: Model<LanguageModel>,
4747
tools: VercelMCPClientTools
4848
): Promise<VercelAgentPromptResult> {
4949
let prompts: string[];
@@ -70,15 +70,15 @@ export function getVercelToolCallingAgent(
7070
system: [...systemPrompt, requestedSystemPrompt].filter(Boolean).join("\n"),
7171
prompt: p,
7272
tools,
73-
maxSteps: 100,
73+
stopWhen: stepCountIs(100),
7474
});
7575

7676
result.text += intermediateResult.text;
7777
result.messages.push(...intermediateResult.response.messages);
7878
result.respondingModel = intermediateResult.response.modelId;
79-
result.tokensUsage.completionTokens += intermediateResult.usage.completionTokens;
80-
result.tokensUsage.promptTokens += intermediateResult.usage.promptTokens;
81-
result.tokensUsage.totalTokens += intermediateResult.usage.totalTokens;
79+
result.tokensUsage.completionTokens += intermediateResult.usage.outputTokens ?? 0;
80+
result.tokensUsage.promptTokens += intermediateResult.usage.inputTokens ?? 0;
81+
result.tokensUsage.totalTokens += intermediateResult.usage.totalTokens ?? 0;
8282
}
8383

8484
return result;

tests/accuracy/sdk/models.ts

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import type { LanguageModelV1 } from "ai";
1+
import type { LanguageModel } from "ai";
22
import { createGoogleGenerativeAI } from "@ai-sdk/google";
33
import { createAzure } from "@ai-sdk/azure";
44
import { createOpenAI } from "@ai-sdk/openai";
5-
import { ollama } from "ollama-ai-provider";
65

7-
export interface Model<VercelModel extends LanguageModelV1 = LanguageModelV1> {
6+
export interface Model<VercelModel extends LanguageModel = LanguageModel> {
87
readonly modelName: string;
98
readonly provider: string;
109
readonly displayName: string;
@@ -24,7 +23,7 @@ export class OpenAIModel implements Model {
2423
return !!process.env.MDB_OPEN_AI_API_KEY;
2524
}
2625

27-
getModel(): LanguageModelV1 {
26+
getModel(): LanguageModel {
2827
return createOpenAI({
2928
apiKey: process.env.MDB_OPEN_AI_API_KEY,
3029
})(this.modelName);
@@ -43,10 +42,11 @@ export class AzureOpenAIModel implements Model {
4342
return !!process.env.MDB_AZURE_OPEN_AI_API_KEY && !!process.env.MDB_AZURE_OPEN_AI_API_URL;
4443
}
4544

46-
getModel(): LanguageModelV1 {
45+
getModel(): LanguageModel {
4746
return createAzure({
4847
baseURL: process.env.MDB_AZURE_OPEN_AI_API_URL,
4948
apiKey: process.env.MDB_AZURE_OPEN_AI_API_KEY,
49+
useDeploymentBasedUrls: true,
5050
apiVersion: "2024-12-01-preview",
5151
})(this.modelName);
5252
}
@@ -64,30 +64,13 @@ export class GeminiModel implements Model {
6464
return !!process.env.MDB_GEMINI_API_KEY;
6565
}
6666

67-
getModel(): LanguageModelV1 {
67+
getModel(): LanguageModel {
6868
return createGoogleGenerativeAI({
6969
apiKey: process.env.MDB_GEMINI_API_KEY,
7070
})(this.modelName);
7171
}
7272
}
7373

74-
export class OllamaModel implements Model {
75-
readonly provider = "Ollama";
76-
readonly displayName: string;
77-
78-
constructor(readonly modelName: string) {
79-
this.displayName = `${this.provider} - ${modelName}`;
80-
}
81-
82-
isAvailable(): boolean {
83-
return true;
84-
}
85-
86-
getModel(): LanguageModelV1 {
87-
return ollama(this.modelName);
88-
}
89-
}
90-
9174
const ALL_TESTABLE_MODELS: Model[] = [new AzureOpenAIModel("gpt-4o")];
9275

9376
export function getAvailableModels(): Model[] {

0 commit comments

Comments
 (0)