Skip to content

Commit 6efb116

Browse files
committed
updates
1 parent 625b528 commit 6efb116

36 files changed

+760
-3821
lines changed

apps/sim/app/api/copilot/chat/route.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,7 @@ describe('Copilot Chat API Route', () => {
7878
model: 'claude-3-haiku-20240307',
7979
})
8080

81-
vi.doMock('@/lib/copilot/config', () => ({
82-
getCopilotModel: mockGetCopilotModel,
83-
}))
84-
85-
vi.doMock('@/lib/copilot/prompts', () => ({
86-
TITLE_GENERATION_SYSTEM_PROMPT: 'Generate a title',
87-
TITLE_GENERATION_USER_PROMPT: vi.fn((msg) => `Generate title for: ${msg}`),
88-
}))
81+
// No longer using copilot config or prompts; mocks removed
8982

9083
mockExecuteProviderRequest.mockResolvedValue({
9184
content: 'Generated Title',

apps/sim/app/api/copilot/chat/route.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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'
1513
import { getBlocksAndToolsTool } from '@/lib/copilot/tools/server-tools/blocks/get-blocks-and-tools'
1614
import { getEnvironmentVariablesTool } from '@/lib/copilot/tools/server-tools/user/get-environment-variables'
1715
import { getOAuthCredentialsTool } from '@/lib/copilot/tools/server-tools/user/get-oauth-credentials'
@@ -28,6 +26,13 @@ import { createAnthropicFileContent, isSupportedFileType } from './file-utils'
2826

2927
const 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
3237
const SIM_AGENT_API_URL = env.SIM_AGENT_API_URL || SIM_AGENT_API_URL_DEFAULT
3338

@@ -100,7 +105,9 @@ const ChatMessageSchema = z.object({
100105
*/
101106
async 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

Comments
 (0)