Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: better type for responseId

Marc Seitz49df36f65a9e
diff --git a/ee/features/ai/lib/chat/send-message.ts b/ee/features/ai/lib/chat/send-message.ts
index 98d4eac3..66b4fb23 100644
--- a/ee/features/ai/lib/chat/send-message.ts
+++ b/ee/features/ai/lib/chat/send-message.ts
@@ -73,6 +73,11 @@ If you cannot find the answer in the documents, say so clearly.`,
};
}
+ const latestMessage = history.at(-1);
+ const previousResponseId =
+ (latestMessage?.metadata as { responseId?: string } | null)?.responseId ??
+ null;
+
// Use AI SDK streamText with file_search tool
const result = streamText({
model: openai.responses("gpt-4o-mini"),
@@ -82,11 +87,7 @@ If you cannot find the answer in the documents, say so clearly.`,
},
providerOptions: {
openai: {
- previousResponseId:
- history.length > 0
- ? (history[history.length - 1].metadata as { responseId: string })
- ?.responseId
- : null,
+ previousResponseId,
} satisfies OpenAIResponsesProviderOptions,
},
onFinish: async ({ text, usage, response }) => {