basic user-tailored UI

This commit is contained in:
Avraham Sakal
2025-09-18 10:45:00 -04:00
parent 83e3f867dd
commit 61540f9338
8 changed files with 43 additions and 34 deletions
+1
View File
@@ -16,6 +16,7 @@ export const data = async (pageContext: PageContextServer) => {
openrouter: getOpenrouter(
(pageContext.env?.OPENROUTER_API_KEY || env.OPENROUTER_API_KEY) as string
),
// jwt: pageContext.,
});
const [
+5 -4
View File
@@ -5,18 +5,19 @@ import {
} from "../../trpc/server";
export const conversations = router({
fetchAll: publicProcedure.query(async ({ ctx: { db } }) => {
return await db.conversations.findAll();
fetchAll: publicProcedure.query(async ({ ctx: { db, jwt } }) => {
console.log("jwt", jwt);
return await db.conversations.findAll({ userId: jwt?.id as string });
}),
fetchOne: publicProcedure
.input((x) => x as { id: string })
.query(async ({ input: { id }, ctx: { db } }) => {
return await db.conversations.findById(id);
}),
start: publicProcedure.mutation(async ({ ctx: { db } }) => {
start: publicProcedure.mutation(async ({ ctx: { db, jwt } }) => {
const row = {
title: "New Conversation",
userId: "019900bb-61b3-7333-b760-b27784dfe33b",
userId: jwt?.id as string,
};
return await db.conversations.create(row);
}),
+3 -3
View File
@@ -73,7 +73,7 @@ export const chat = router({
input: { conversationId, messages, systemPrompt, parameters },
ctx,
}) {
const { db, openrouter } = ctx;
const { db, openrouter, jwt } = ctx;
const factsCaller = createCallerFacts(ctx);
const messagesCaller = createCallerMessages(ctx);
const factTriggerCaller = createCallerFactTriggers(ctx);
@@ -173,7 +173,7 @@ export const chat = router({
});
const insertedFactsFromUserMessage = await db.facts.createMany(
factsFromUserMessageResponse.object.facts.map((fact) => ({
userId: "019900bb-61b3-7333-b760-b27784dfe33b",
userId: jwt?.id as string,
sourceMessageId: insertedUserMessage.id,
content: fact,
}))
@@ -228,7 +228,7 @@ export const chat = router({
const insertedFactsFromAssistantMessage = await db.facts.createMany(
factsFromAssistantMessageResponse.object.facts.map((factContent) => ({
userId: "019900bb-61b3-7333-b760-b27784dfe33b",
userId: jwt?.id as string,
sourceMessageId: insertedAssistantMessage.id,
content: factContent,
createdAt: new Date().toISOString(),