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 { createAnthropic } from '@ai-sdk/anthropic';
|
||||||
import { wrapAISDKModel } from 'braintrust';
|
import { wrapLanguageModel } from 'ai';
|
||||||
|
import { BraintrustMiddleware } from 'braintrust';
|
||||||
|
|
||||||
export const anthropicModel = (modelId: string) => {
|
export const anthropicModel = (modelId: string) => {
|
||||||
const anthropic = createAnthropic({
|
const anthropic = createAnthropic({
|
||||||
|
@ -42,6 +43,9 @@ export const anthropicModel = (modelId: string) => {
|
||||||
}) as typeof fetch,
|
}) as typeof fetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wrap the model with Braintrust tracing and return it
|
// Wrap the model with Braintrust middleware
|
||||||
return wrapAISDKModel(anthropic(modelId));
|
return wrapLanguageModel({
|
||||||
|
model: anthropic(modelId),
|
||||||
|
middleware: BraintrustMiddleware({ debug: true }),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
import { createOpenAI } from '@ai-sdk/openai';
|
import { createOpenAI } from '@ai-sdk/openai';
|
||||||
import { wrapAISDKModel } from 'braintrust';
|
import { wrapLanguageModel } from 'ai';
|
||||||
|
import { BraintrustMiddleware } from 'braintrust';
|
||||||
|
|
||||||
export const openaiModel = (modelId: string) => {
|
export const openaiModel = (modelId: string) => {
|
||||||
const openai = createOpenAI({
|
const openai = createOpenAI({
|
||||||
apiKey: process.env.OPENAI_API_KEY,
|
apiKey: process.env.OPENAI_API_KEY,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wrap the model with Braintrust tracing and return it
|
// Wrap the model with Braintrust middleware
|
||||||
return wrapAISDKModel(openai(modelId));
|
return wrapLanguageModel({
|
||||||
|
model: openai(modelId),
|
||||||
|
middleware: BraintrustMiddleware({ debug: true }),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { createVertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
|
import { createVertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
|
||||||
import type { LanguageModelV2 } from '@ai-sdk/provider';
|
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 => {
|
export const vertexModel = (modelId: string): LanguageModelV2 => {
|
||||||
// Create a proxy that validates credentials on first use
|
// Create a proxy that validates credentials on first use
|
||||||
|
@ -70,8 +71,11 @@ export const vertexModel = (modelId: string): LanguageModelV2 => {
|
||||||
}) as typeof fetch,
|
}) as typeof fetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wrap the model with Braintrust tracing
|
// Wrap the model with Braintrust middleware
|
||||||
actualModel = wrapAISDKModel(vertex(modelId));
|
actualModel = wrapLanguageModel({
|
||||||
|
model: vertex(modelId),
|
||||||
|
middleware: BraintrustMiddleware({ debug: true }),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return actualModel;
|
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/toc": "^49.0.0"
|
||||||
"@platejs/toggle": "^49.0.0"
|
"@platejs/toggle": "^49.0.0"
|
||||||
axios: "^1.10.0"
|
axios: "^1.10.0"
|
||||||
"braintrust": "^0.0.209"
|
"braintrust": "^0.2.4"
|
||||||
dotenv: "^17.2.0"
|
dotenv: "^17.2.0"
|
||||||
drizzle-orm: "^0.44.2"
|
drizzle-orm: "^0.44.2"
|
||||||
hono: "^4.8.0"
|
hono: "^4.8.0"
|
||||||
|
|
Loading…
Reference in New Issue