mirror of https://github.com/buster-so/buster.git
move everything over to gpt5
This commit is contained in:
parent
4c7cd84e88
commit
14092b08be
|
@ -5,7 +5,7 @@ import { generateObject } from 'ai';
|
||||||
import { wrapTraced } from 'braintrust';
|
import { wrapTraced } from 'braintrust';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { thinkAndPrepWorkflowInputSchema } from '../../../schemas/workflow-schemas';
|
import { thinkAndPrepWorkflowInputSchema } from '../../../schemas/workflow-schemas';
|
||||||
import { Haiku35 } from '../../../utils/models/haiku-3-5';
|
import { GPT5Nano } from '../../../utils/models/gpt-5-nano';
|
||||||
import { appendToConversation, standardizeMessages } from '../../../utils/standardizeMessages';
|
import { appendToConversation, standardizeMessages } from '../../../utils/standardizeMessages';
|
||||||
import type { AnalystRuntimeContext } from '../../../workflows/analyst-workflow';
|
import type { AnalystRuntimeContext } from '../../../workflows/analyst-workflow';
|
||||||
import { formatAnalysisTypeRouterPrompt } from './format-analysis-type-router-prompt';
|
import { formatAnalysisTypeRouterPrompt } from './format-analysis-type-router-prompt';
|
||||||
|
@ -68,7 +68,7 @@ const execution = async ({
|
||||||
const tracedAnalysisType = wrapTraced(
|
const tracedAnalysisType = wrapTraced(
|
||||||
async () => {
|
async () => {
|
||||||
const { object } = await generateObject({
|
const { object } = await generateObject({
|
||||||
model: Haiku35,
|
model: GPT5Nano,
|
||||||
schema: analysisTypeSchema,
|
schema: analysisTypeSchema,
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
|
@ -77,8 +77,13 @@ const execution = async ({
|
||||||
},
|
},
|
||||||
...messages,
|
...messages,
|
||||||
],
|
],
|
||||||
temperature: 0,
|
temperature: 1,
|
||||||
maxTokens: 500,
|
providerOptions: {
|
||||||
|
openai: {
|
||||||
|
parallelToolCalls: false,
|
||||||
|
reasoningEffort: 'minimal',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { thinkAndPrepWorkflowInputSchema } from '../schemas/workflow-schemas';
|
||||||
import { createTodoList } from '../tools/planning-thinking-tools/create-todo-item-tool';
|
import { createTodoList } from '../tools/planning-thinking-tools/create-todo-item-tool';
|
||||||
import { ChunkProcessor } from '../utils/database/chunk-processor';
|
import { ChunkProcessor } from '../utils/database/chunk-processor';
|
||||||
import { ReasoningHistorySchema } from '../utils/memory/types';
|
import { ReasoningHistorySchema } from '../utils/memory/types';
|
||||||
import { Sonnet4 } from '../utils/models/sonnet-4';
|
import { GPT5 } from '../utils/models/gpt-5';
|
||||||
import { RetryWithHealingError, isRetryWithHealingError } from '../utils/retry';
|
import { RetryWithHealingError, isRetryWithHealingError } from '../utils/retry';
|
||||||
import { appendToConversation, standardizeMessages } from '../utils/standardizeMessages';
|
import { appendToConversation, standardizeMessages } from '../utils/standardizeMessages';
|
||||||
import { createOnChunkHandler } from '../utils/streaming';
|
import { createOnChunkHandler } from '../utils/streaming';
|
||||||
|
@ -188,14 +188,17 @@ The TODO list should break down each aspect of the user request into tasks, base
|
||||||
|
|
||||||
const DEFAULT_OPTIONS = {
|
const DEFAULT_OPTIONS = {
|
||||||
maxSteps: 1,
|
maxSteps: 1,
|
||||||
temperature: 0,
|
temperature: 1,
|
||||||
maxTokens: 300,
|
openai: {
|
||||||
|
parallelToolCalls: false,
|
||||||
|
reasoningEffort: 'minimal',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const todosAgent = new Agent({
|
export const todosAgent = new Agent({
|
||||||
name: 'Create Todos',
|
name: 'Create Todos',
|
||||||
instructions: todosInstructions,
|
instructions: todosInstructions,
|
||||||
model: Sonnet4,
|
model: GPT5,
|
||||||
tools: {
|
tools: {
|
||||||
createTodoList,
|
createTodoList,
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,6 +7,7 @@ import type { CoreMessage } from 'ai';
|
||||||
import { wrapTraced } from 'braintrust';
|
import { wrapTraced } from 'braintrust';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { thinkAndPrepWorkflowInputSchema } from '../schemas/workflow-schemas';
|
import { thinkAndPrepWorkflowInputSchema } from '../schemas/workflow-schemas';
|
||||||
|
import { GPT5Mini } from '../utils/models/gpt-5-mini';
|
||||||
import { Haiku35 } from '../utils/models/haiku-3-5';
|
import { Haiku35 } from '../utils/models/haiku-3-5';
|
||||||
import { appendToConversation, standardizeMessages } from '../utils/standardizeMessages';
|
import { appendToConversation, standardizeMessages } from '../utils/standardizeMessages';
|
||||||
import type { AnalystRuntimeContext } from '../workflows/analyst-workflow';
|
import type { AnalystRuntimeContext } from '../workflows/analyst-workflow';
|
||||||
|
@ -265,7 +266,7 @@ const extractValuesSearchStepExecution = async ({
|
||||||
const tracedValuesExtraction = wrapTraced(
|
const tracedValuesExtraction = wrapTraced(
|
||||||
async () => {
|
async () => {
|
||||||
const { object } = await generateObject({
|
const { object } = await generateObject({
|
||||||
model: Haiku35,
|
model: GPT5Mini,
|
||||||
schema: llmOutputSchema,
|
schema: llmOutputSchema,
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
|
@ -274,6 +275,13 @@ const extractValuesSearchStepExecution = async ({
|
||||||
},
|
},
|
||||||
...messages,
|
...messages,
|
||||||
],
|
],
|
||||||
|
temperature: 1,
|
||||||
|
providerOptions: {
|
||||||
|
openai: {
|
||||||
|
parallelToolCalls: false,
|
||||||
|
reasoningEffort: 'minimal',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { thinkAndPrepWorkflowInputSchema } from '../schemas/workflow-schemas';
|
||||||
import { Haiku35 } from '../utils/models/haiku-3-5';
|
import { Haiku35 } from '../utils/models/haiku-3-5';
|
||||||
import { appendToConversation, standardizeMessages } from '../utils/standardizeMessages';
|
import { appendToConversation, standardizeMessages } from '../utils/standardizeMessages';
|
||||||
import type { AnalystRuntimeContext } from '../workflows/analyst-workflow';
|
import type { AnalystRuntimeContext } from '../workflows/analyst-workflow';
|
||||||
|
import { GPT5Mini } from '../utils/models/gpt-5-mini';
|
||||||
|
|
||||||
const inputSchema = thinkAndPrepWorkflowInputSchema;
|
const inputSchema = thinkAndPrepWorkflowInputSchema;
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ const generateChatTitleExecution = async ({
|
||||||
const tracedChatTitle = wrapTraced(
|
const tracedChatTitle = wrapTraced(
|
||||||
async () => {
|
async () => {
|
||||||
const { object } = await generateObject({
|
const { object } = await generateObject({
|
||||||
model: Haiku35,
|
model: GPT5Mini,
|
||||||
schema: llmOutputSchema,
|
schema: llmOutputSchema,
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
|
@ -76,6 +77,13 @@ const generateChatTitleExecution = async ({
|
||||||
},
|
},
|
||||||
...messages,
|
...messages,
|
||||||
],
|
],
|
||||||
|
temperature: 1,
|
||||||
|
providerOptions: {
|
||||||
|
openai: {
|
||||||
|
parallelToolCalls: false,
|
||||||
|
reasoningEffort: 'minimal',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
import type { LanguageModelV1 } from '@ai-sdk/provider';
|
||||||
|
import { createFallback } from './ai-fallback';
|
||||||
|
import { openaiModel } from './providers/openai';
|
||||||
|
|
||||||
|
// Lazy initialization to allow mocking in tests
|
||||||
|
let _gpt5Instance: ReturnType<typeof createFallback> | null = null;
|
||||||
|
|
||||||
|
function initializeGPT5() {
|
||||||
|
if (_gpt5Instance) {
|
||||||
|
return _gpt5Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build models array based on available credentials
|
||||||
|
const models: LanguageModelV1[] = [];
|
||||||
|
|
||||||
|
// Only include OpenAI if API key is available
|
||||||
|
if (process.env.OPENAI_API_KEY) {
|
||||||
|
try {
|
||||||
|
models.push(openaiModel('gpt-5-mini-2025-08-07'));
|
||||||
|
console.info('GPT5: OpenAI model added to fallback chain');
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('GPT5: Failed to initialize OpenAI model:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we have at least one model
|
||||||
|
if (models.length === 0) {
|
||||||
|
throw new Error('No AI models available. Please set OPENAI_API_KEY environment variable.');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.info(`GPT5: Initialized with ${models.length} model(s) in fallback chain`);
|
||||||
|
|
||||||
|
_gpt5Instance = createFallback({
|
||||||
|
models,
|
||||||
|
modelResetInterval: 60000,
|
||||||
|
retryAfterOutput: true,
|
||||||
|
onError: (err) => console.error(`FALLBACK. Here is the error: ${err}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
return _gpt5Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export a proxy that initializes on first use
|
||||||
|
export const GPT5Mini = new Proxy({} as ReturnType<typeof createFallback>, {
|
||||||
|
get(_target, prop) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
// Direct property access without receiver to avoid proxy conflicts
|
||||||
|
return instance[prop as keyof typeof instance];
|
||||||
|
},
|
||||||
|
has(_target, prop) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
return prop in instance;
|
||||||
|
},
|
||||||
|
ownKeys(_target) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
return Reflect.ownKeys(instance);
|
||||||
|
},
|
||||||
|
getOwnPropertyDescriptor(_target, prop) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
return Reflect.getOwnPropertyDescriptor(instance, prop);
|
||||||
|
},
|
||||||
|
});
|
|
@ -0,0 +1,62 @@
|
||||||
|
import type { LanguageModelV1 } from '@ai-sdk/provider';
|
||||||
|
import { createFallback } from './ai-fallback';
|
||||||
|
import { openaiModel } from './providers/openai';
|
||||||
|
|
||||||
|
// Lazy initialization to allow mocking in tests
|
||||||
|
let _gpt5Instance: ReturnType<typeof createFallback> | null = null;
|
||||||
|
|
||||||
|
function initializeGPT5() {
|
||||||
|
if (_gpt5Instance) {
|
||||||
|
return _gpt5Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build models array based on available credentials
|
||||||
|
const models: LanguageModelV1[] = [];
|
||||||
|
|
||||||
|
// Only include OpenAI if API key is available
|
||||||
|
if (process.env.OPENAI_API_KEY) {
|
||||||
|
try {
|
||||||
|
models.push(openaiModel('gpt-5-nano-2025-08-07'));
|
||||||
|
console.info('GPT5: OpenAI model added to fallback chain');
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('GPT5: Failed to initialize OpenAI model:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we have at least one model
|
||||||
|
if (models.length === 0) {
|
||||||
|
throw new Error('No AI models available. Please set OPENAI_API_KEY environment variable.');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.info(`GPT5: Initialized with ${models.length} model(s) in fallback chain`);
|
||||||
|
|
||||||
|
_gpt5Instance = createFallback({
|
||||||
|
models,
|
||||||
|
modelResetInterval: 60000,
|
||||||
|
retryAfterOutput: true,
|
||||||
|
onError: (err) => console.error(`FALLBACK. Here is the error: ${err}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
return _gpt5Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export a proxy that initializes on first use
|
||||||
|
export const GPT5Nano = new Proxy({} as ReturnType<typeof createFallback>, {
|
||||||
|
get(_target, prop) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
// Direct property access without receiver to avoid proxy conflicts
|
||||||
|
return instance[prop as keyof typeof instance];
|
||||||
|
},
|
||||||
|
has(_target, prop) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
return prop in instance;
|
||||||
|
},
|
||||||
|
ownKeys(_target) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
return Reflect.ownKeys(instance);
|
||||||
|
},
|
||||||
|
getOwnPropertyDescriptor(_target, prop) {
|
||||||
|
const instance = initializeGPT5();
|
||||||
|
return Reflect.getOwnPropertyDescriptor(instance, prop);
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in New Issue