mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-06 04:35:03 -05:00
Lint
This commit is contained in:
@@ -242,6 +242,7 @@ IMPORTANT: Always provide complete, helpful responses. If you add citations, con
|
||||
})
|
||||
|
||||
// Store citations for later use in the main streaming handler
|
||||
|
||||
;(streamResponse as any)._citations = responseCitations
|
||||
|
||||
return streamResponse
|
||||
@@ -435,7 +436,12 @@ export async function POST(req: NextRequest) {
|
||||
const assistantMessage = {
|
||||
id: crypto.randomUUID(),
|
||||
role: 'assistant',
|
||||
content: typeof response === 'string' ? response : (typeof response === 'object' && 'content' in response ? response.content : '[Error generating response]') || '[Error generating response]',
|
||||
content:
|
||||
typeof response === 'string'
|
||||
? response
|
||||
: (typeof response === 'object' && 'content' in response
|
||||
? response.content
|
||||
: '[Error generating response]') || '[Error generating response]',
|
||||
timestamp: new Date().toISOString(),
|
||||
citations: citations.length > 0 ? citations : undefined,
|
||||
}
|
||||
@@ -464,7 +470,12 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
response: typeof response === 'string' ? response : (typeof response === 'object' && 'content' in response ? response.content : '[Error generating response]') || '[Error generating response]',
|
||||
response:
|
||||
typeof response === 'string'
|
||||
? response
|
||||
: (typeof response === 'object' && 'content' in response
|
||||
? response.content
|
||||
: '[Error generating response]') || '[Error generating response]',
|
||||
chatId: currentChat?.id,
|
||||
citations: extractCitationsFromResponse(response),
|
||||
metadata: {
|
||||
|
||||
@@ -48,7 +48,7 @@ function ModalCopilotMessage({ message }: CopilotModalMessage) {
|
||||
if (!citations || citations.length === 0) return text
|
||||
|
||||
let processedText = text
|
||||
|
||||
|
||||
// Replace [1], [2], [3] etc. with clickable citation icons
|
||||
processedText = processedText.replace(/\[(\d+)\]/g, (match, num) => {
|
||||
const citationIndex = Number.parseInt(num) - 1
|
||||
|
||||
@@ -277,7 +277,7 @@ export const Copilot = forwardRef<CopilotRef, CopilotProps>(
|
||||
// Reload chats in background to get the updated list
|
||||
loadChats()
|
||||
}
|
||||
|
||||
|
||||
// Mark stream as complete to exit outer loop
|
||||
streamComplete = true
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user