nsarrazin HF staff commited on
Commit
2bee53b
1 Parent(s): c30d191

Set message id on server side (#696)

Browse files
src/routes/conversation/[id]/+page.svelte CHANGED
@@ -111,14 +111,12 @@
111
 
112
  files = [];
113
 
114
- const responseId = randomUUID();
115
  const response = await fetch(`${base}/conversation/${$page.params.id}`, {
116
  method: "POST",
117
  headers: { "Content-Type": "application/json" },
118
  body: JSON.stringify({
119
  inputs: message,
120
  id: messageId,
121
- response_id: responseId,
122
  is_retry: isRetry,
123
  web_search: $webSearchParameters.useSearch,
124
  files: isRetry ? undefined : resizedImages,
 
111
 
112
  files = [];
113
 
 
114
  const response = await fetch(`${base}/conversation/${$page.params.id}`, {
115
  method: "POST",
116
  headers: { "Content-Type": "application/json" },
117
  body: JSON.stringify({
118
  inputs: message,
119
  id: messageId,
 
120
  is_retry: isRetry,
121
  web_search: $webSearchParameters.useSearch,
122
  files: isRetry ? undefined : resizedImages,
src/routes/conversation/[id]/+server.ts CHANGED
@@ -90,7 +90,6 @@ export async function POST({ request, locals, params, getClientAddress }) {
90
 
91
  const {
92
  inputs: newPrompt,
93
- response_id: responseId,
94
  id: messageId,
95
  is_retry,
96
  web_search: webSearch,
@@ -99,7 +98,6 @@ export async function POST({ request, locals, params, getClientAddress }) {
99
  .object({
100
  inputs: z.string().trim().min(1),
101
  id: z.optional(z.string().uuid()),
102
- response_id: z.optional(z.string().uuid()),
103
  is_retry: z.optional(z.boolean()),
104
  web_search: z.optional(z.boolean()),
105
  files: z.optional(z.array(z.string())),
@@ -268,7 +266,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
268
  content: output.token.text.trimStart(),
269
  webSearch: webSearchResults,
270
  updates: updates,
271
- id: (responseId as Message["id"]) || crypto.randomUUID(),
272
  createdAt: new Date(),
273
  updatedAt: new Date(),
274
  },
 
90
 
91
  const {
92
  inputs: newPrompt,
 
93
  id: messageId,
94
  is_retry,
95
  web_search: webSearch,
 
98
  .object({
99
  inputs: z.string().trim().min(1),
100
  id: z.optional(z.string().uuid()),
 
101
  is_retry: z.optional(z.boolean()),
102
  web_search: z.optional(z.boolean()),
103
  files: z.optional(z.array(z.string())),
 
266
  content: output.token.text.trimStart(),
267
  webSearch: webSearchResults,
268
  updates: updates,
269
+ id: crypto.randomUUID(),
270
  createdAt: new Date(),
271
  updatedAt: new Date(),
272
  },