@@ -10,8 +10,6 @@ import {
1010 createRequestTracker ,
1111 createUnauthorizedResponse ,
1212} from '@/lib/copilot/auth'
13- import { getCopilotModel } from '@/lib/copilot/config'
14- import { TITLE_GENERATION_SYSTEM_PROMPT , TITLE_GENERATION_USER_PROMPT } from '@/lib/copilot/prompts'
1513import { getBlocksAndToolsTool } from '@/lib/copilot/tools/server-tools/blocks/get-blocks-and-tools'
1614import { getEnvironmentVariablesTool } from '@/lib/copilot/tools/server-tools/user/get-environment-variables'
1715import { getOAuthCredentialsTool } from '@/lib/copilot/tools/server-tools/user/get-oauth-credentials'
@@ -28,6 +26,13 @@ import { createAnthropicFileContent, isSupportedFileType } from './file-utils'
2826
2927const logger = createLogger ( 'CopilotChatAPI' )
3028
29+ // Inlined minimal defaults (replacing legacy config/prompts)
30+ const DEFAULT_CHAT_MODEL = 'claude-3-haiku-20240307'
31+ const TITLE_GENERATION_SYSTEM_PROMPT =
32+ 'You are a helpful assistant that generates concise, descriptive titles for chat conversations. Create a title that captures the main topic or question being discussed. Keep it under 50 characters and make it specific and clear.'
33+ const TITLE_GENERATION_USER_PROMPT = ( userMessage : string ) =>
34+ `Generate a concise title for a conversation that starts with this user message: "${ userMessage } "\n\nReturn only the title text, nothing else.`
35+
3136// Sim Agent API configuration
3237const SIM_AGENT_API_URL = env . SIM_AGENT_API_URL || SIM_AGENT_API_URL_DEFAULT
3338
@@ -100,7 +105,9 @@ const ChatMessageSchema = z.object({
100105 */
101106async function generateChatTitle ( userMessage : string ) : Promise < string > {
102107 try {
103- const { provider, model } = getCopilotModel ( 'title' )
108+ // Use Anthropic Haiku by default for title generation
109+ const provider = 'anthropic'
110+ const model = DEFAULT_CHAT_MODEL
104111
105112 // Get the appropriate API key for the provider
106113 let apiKey : string | undefined
@@ -116,7 +123,7 @@ async function generateChatTitle(userMessage: string): Promise<string> {
116123 }
117124 }
118125
119- const response = await executeProviderRequest ( provider , {
126+ const response = await executeProviderRequest ( provider as any , {
120127 model,
121128 systemPrompt : TITLE_GENERATION_SYSTEM_PROMPT ,
122129 context : TITLE_GENERATION_USER_PROMPT ( userMessage ) ,
@@ -270,14 +277,13 @@ export async function POST(req: NextRequest) {
270277 }
271278 } else if ( createNewChat && workflowId ) {
272279 // Create new chat
273- const { provider, model } = getCopilotModel ( 'chat' )
274280 const [ newChat ] = await db
275281 . insert ( copilotChats )
276282 . values ( {
277283 userId : authenticatedUserId ,
278284 workflowId,
279285 title : null ,
280- model,
286+ model : DEFAULT_CHAT_MODEL ,
281287 messages : [ ] ,
282288 } )
283289 . returning ( )
@@ -688,7 +694,7 @@ export async function POST(req: NextRequest) {
688694 }
689695 if ( event . data ?. name === 'get_user_workflow' ) {
690696 logger . info (
691- `[${ tracker . requestId } ] get_user_workflow tool call received in stream; client will execute locally and post to /api/copilot/methods ` ,
697+ `[${ tracker . requestId } ] get_user_workflow tool call received in stream; client will execute locally and post to /api/copilot/tools/execute ` ,
692698 {
693699 toolCallId : event . data ?. id ,
694700 hasArgs : ! ! event . data ?. arguments ,
0 commit comments