Skip to content

Commit 178aa90

Browse files
committed
Pass the model in, allow changing it
1 parent b467eba commit 178aa90

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

apps/webapp/app/env.server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,9 @@ const EnvironmentSchema = z.object({
975975
BULK_ACTION_BATCH_SIZE: z.coerce.number().int().default(100),
976976
BULK_ACTION_BATCH_DELAY_MS: z.coerce.number().int().default(200),
977977
BULK_ACTION_SUBBATCH_CONCURRENCY: z.coerce.number().int().default(5),
978+
979+
// AI Run Filter
980+
AI_RUN_FILTER_MODEL: z.string().optional(),
978981
});
979982

980983
export type Environment = z.infer<typeof EnvironmentSchema>;

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.ai-filter.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { openai } from "@ai-sdk/openai";
12
import { type ActionFunctionArgs, json } from "@remix-run/server-runtime";
23
import { tryCatch } from "@trigger.dev/core";
34
import { z } from "zod";
@@ -139,12 +140,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
139140
);
140141
}
141142

142-
const service = new AIRunFilterService({
143-
queryTags,
144-
queryVersions,
145-
queryQueues,
146-
queryTasks,
147-
});
143+
const service = new AIRunFilterService(
144+
{
145+
queryTags,
146+
queryVersions,
147+
queryQueues,
148+
queryTasks,
149+
},
150+
openai(env.AI_RUN_FILTER_MODEL ?? "gpt-4o-mini")
151+
);
148152

149153
const [error, result] = await tryCatch(service.call(text, environment.id));
150154
if (error) {

apps/webapp/app/v3/services/aiRunFilterService.server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { openai } from "@ai-sdk/openai";
22
import { type TaskTriggerSource } from "@trigger.dev/database";
3-
import { generateText, Output, tool } from "ai";
3+
import { generateText, LanguageModelV1, Output, tool } from "ai";
44
import { z } from "zod";
55
import { TaskRunListSearchFilters } from "~/components/runs/v3/RunFilters";
66
import { logger } from "~/services/logger.server";
@@ -79,13 +79,14 @@ export class AIRunFilterService {
7979
queryVersions: QueryVersions;
8080
queryQueues: QueryQueues;
8181
queryTasks: QueryTasks;
82-
}
82+
},
83+
private readonly model: LanguageModelV1 = openai("gpt-4o-mini")
8384
) {}
8485

8586
async call(text: string, environmentId: string): Promise<AIFilterResult> {
8687
try {
8788
const result = await generateText({
88-
model: openai("gpt-4o-mini"),
89+
model: this.model,
8990
experimental_output: Output.object({ schema: AIFilterResponseSchema }),
9091
tools: {
9192
lookupTags: tool({

apps/webapp/evals/aiRunFilter.eval.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
type QueryVersions,
99
} from "~/v3/services/aiRunFilterService.server";
1010
import dotenv from "dotenv";
11+
import { traceAISDKModel } from "evalite/ai-sdk";
12+
import { openai } from "@ai-sdk/openai";
1113

1214
dotenv.config({ path: "../../.env" });
1315

@@ -232,12 +234,15 @@ evalite("AI Run Filter", {
232234
];
233235
},
234236
task: async (input) => {
235-
const service = new AIRunFilterService({
236-
queryTags,
237-
queryVersions,
238-
queryQueues,
239-
queryTasks,
240-
});
237+
const service = new AIRunFilterService(
238+
{
239+
queryTags,
240+
queryVersions,
241+
queryQueues,
242+
queryTasks,
243+
},
244+
traceAISDKModel(openai("gpt-4o-mini"))
245+
);
241246

242247
const result = await service.call(input, "123456");
243248
return JSON.stringify(result);

0 commit comments

Comments
 (0)