MCPcopy Index your code
hub / github.com/simstudioai/sim / fireTitleGeneration

Function fireTitleGeneration

apps/sim/lib/copilot/request/lifecycle/start.ts:415–469  ·  view source on GitHub ↗
(params: {
  chatId?: string
  currentChat: CurrentChatSummary
  isNewChat: boolean
  userId?: string
  message: string
  titleModel: string
  titleProvider?: string
  workspaceId?: string
  requestId: string
  publisher: StreamWriter
  otelContext?: Context
})

Source from the content-addressed store, hash-verified

413// ---------------------------------------------------------------------------
414
415function fireTitleGeneration(params: {
416 chatId?: string
417 currentChat: CurrentChatSummary
418 isNewChat: boolean
419 userId?: string
420 message: string
421 titleModel: string
422 titleProvider?: string
423 workspaceId?: string
424 requestId: string
425 publisher: StreamWriter
426 otelContext?: Context
427}): void {
428 const {
429 chatId,
430 currentChat,
431 isNewChat,
432 userId,
433 message,
434 titleModel,
435 titleProvider,
436 workspaceId,
437 requestId,
438 publisher,
439 otelContext,
440 } = params
441 if (!chatId || currentChat?.title || !isNewChat) return
442
443 requestChatTitle({
444 message,
445 model: titleModel,
446 provider: titleProvider,
447 userId,
448 workspaceId,
449 otelContext,
450 })
451 .then(async (title) => {
452 if (!title) return
453 await db.update(copilotChats).set({ title }).where(eq(copilotChats.id, chatId))
454 await publisher.publish({
455 type: MothershipStreamV1EventType.session,
456 payload: { kind: MothershipStreamV1SessionKind.title, title },
457 })
458 if (workspaceId) {
459 chatPubSub?.publishStatusChanged({
460 workspaceId,
461 chatId,
462 type: 'renamed',
463 })
464 }
465 })
466 .catch((error) => {
467 logger.error(`[${requestId}] Title generation failed:`, error)
468 })
469}
470
471// ---------------------------------------------------------------------------
472// Chat title helper

Callers 1

startFunction · 0.85

Calls 5

requestChatTitleFunction · 0.85
errorMethod · 0.80
setMethod · 0.65
publishMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected