basic user-tailored UI
This commit is contained in:
@@ -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,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
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user