nsarrazin HF staff commited on
Commit
d196c64
1 Parent(s): 1d6151d

Store user agent in conversation (#940)

Browse files

* Store user agent on conversation creation

* casing header

src/lib/types/Conversation.ts CHANGED
@@ -23,4 +23,6 @@ export interface Conversation extends Timestamps {
23
 
24
  preprompt?: string;
25
  assistantId?: Assistant["_id"];
 
 
26
  }
 
23
 
24
  preprompt?: string;
25
  assistantId?: Assistant["_id"];
26
+
27
+ userAgent?: string;
28
  }
src/routes/conversation/+server.ts CHANGED
@@ -105,6 +105,7 @@ export const POST: RequestHandler = async ({ locals, request }) => {
105
  assistantId: values.assistantId ? new ObjectId(values.assistantId) : undefined,
106
  createdAt: new Date(),
107
  updatedAt: new Date(),
 
108
  embeddingModel,
109
  ...(locals.user ? { userId: locals.user._id } : { sessionId: locals.sessionId }),
110
  ...(values.fromShare ? { meta: { fromShareId: values.fromShare } } : {}),
 
105
  assistantId: values.assistantId ? new ObjectId(values.assistantId) : undefined,
106
  createdAt: new Date(),
107
  updatedAt: new Date(),
108
+ userAgent: request.headers.get("User-Agent") ?? undefined,
109
  embeddingModel,
110
  ...(locals.user ? { userId: locals.user._id } : { sessionId: locals.sessionId }),
111
  ...(values.fromShare ? { meta: { fromShareId: values.fromShare } } : {}),