Skip to content

Commit

Permalink
Set message id on server side (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin authored Jan 16, 2024
1 parent c30d191 commit 2bee53b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 0 additions & 2 deletions src/routes/conversation/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@
files = [];
const responseId = randomUUID();
const response = await fetch(`${base}/conversation/${$page.params.id}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
inputs: message,
id: messageId,
response_id: responseId,
is_retry: isRetry,
web_search: $webSearchParameters.useSearch,
files: isRetry ? undefined : resizedImages,
Expand Down
4 changes: 1 addition & 3 deletions src/routes/conversation/[id]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export async function POST({ request, locals, params, getClientAddress }) {

const {
inputs: newPrompt,
response_id: responseId,
id: messageId,
is_retry,
web_search: webSearch,
Expand All @@ -99,7 +98,6 @@ export async function POST({ request, locals, params, getClientAddress }) {
.object({
inputs: z.string().trim().min(1),
id: z.optional(z.string().uuid()),
response_id: z.optional(z.string().uuid()),
is_retry: z.optional(z.boolean()),
web_search: z.optional(z.boolean()),
files: z.optional(z.array(z.string())),
Expand Down Expand Up @@ -268,7 +266,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
content: output.token.text.trimStart(),
webSearch: webSearchResults,
updates: updates,
id: (responseId as Message["id"]) || crypto.randomUUID(),
id: crypto.randomUUID(),
createdAt: new Date(),
updatedAt: new Date(),
},
Expand Down

0 comments on commit 2bee53b

Please sign in to comment.