mirror of https://github.com/buster-so/buster.git
move to newer braintrust version
This commit is contained in:
parent
1d0d312ff3
commit
a7ced93c6e
|
@ -1,5 +1,6 @@
|
|||
import { createAnthropic } from '@ai-sdk/anthropic';
|
||||
import { wrapAISDKModel } from 'braintrust';
|
||||
import { wrapLanguageModel } from 'ai';
|
||||
import { BraintrustMiddleware } from 'braintrust';
|
||||
|
||||
export const anthropicModel = (modelId: string) => {
|
||||
const anthropic = createAnthropic({
|
||||
|
@ -42,6 +43,9 @@ export const anthropicModel = (modelId: string) => {
|
|||
}) as typeof fetch,
|
||||
});
|
||||
|
||||
// Wrap the model with Braintrust tracing and return it
|
||||
return wrapAISDKModel(anthropic(modelId));
|
||||
// Wrap the model with Braintrust middleware
|
||||
return wrapLanguageModel({
|
||||
model: anthropic(modelId),
|
||||
middleware: BraintrustMiddleware({ debug: true }),
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
import { createOpenAI } from '@ai-sdk/openai';
|
||||
import { wrapAISDKModel } from 'braintrust';
|
||||
import { wrapLanguageModel } from 'ai';
|
||||
import { BraintrustMiddleware } from 'braintrust';
|
||||
|
||||
export const openaiModel = (modelId: string) => {
|
||||
const openai = createOpenAI({
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
});
|
||||
|
||||
// Wrap the model with Braintrust tracing and return it
|
||||
return wrapAISDKModel(openai(modelId));
|
||||
// Wrap the model with Braintrust middleware
|
||||
return wrapLanguageModel({
|
||||
model: openai(modelId),
|
||||
middleware: BraintrustMiddleware({ debug: true }),
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { createVertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
|
||||
import type { LanguageModelV2 } from '@ai-sdk/provider';
|
||||
import { wrapAISDKModel } from 'braintrust';
|
||||
import { wrapLanguageModel } from 'ai';
|
||||
import { BraintrustMiddleware } from 'braintrust';
|
||||
|
||||
export const vertexModel = (modelId: string): LanguageModelV2 => {
|
||||
// Create a proxy that validates credentials on first use
|
||||
|
@ -70,8 +71,11 @@ export const vertexModel = (modelId: string): LanguageModelV2 => {
|
|||
}) as typeof fetch,
|
||||
});
|
||||
|
||||
// Wrap the model with Braintrust tracing
|
||||
actualModel = wrapAISDKModel(vertex(modelId));
|
||||
// Wrap the model with Braintrust middleware
|
||||
actualModel = wrapLanguageModel({
|
||||
model: vertex(modelId),
|
||||
middleware: BraintrustMiddleware({ debug: true }),
|
||||
});
|
||||
}
|
||||
return actualModel;
|
||||
};
|
||||
|
|
558
pnpm-lock.yaml
558
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -29,7 +29,7 @@ catalog:
|
|||
"@platejs/toc": "^49.0.0"
|
||||
"@platejs/toggle": "^49.0.0"
|
||||
axios: "^1.10.0"
|
||||
"braintrust": "^0.0.209"
|
||||
"braintrust": "^0.2.4"
|
||||
dotenv: "^17.2.0"
|
||||
drizzle-orm: "^0.44.2"
|
||||
hono: "^4.8.0"
|
||||
|
|
Loading…
Reference in New Issue