obsolete `messages` db layer

master
Avraham Sakal 3 weeks ago
parent 3941b73b03
commit a41b97b442

@ -1,7 +1,7 @@
import { router, publicProcedure, createCallerFactory } from "./server";
import { MODEL_NAME } from "../provider.js";
import { generateObject, generateText, jsonSchema } from "ai";
import type { DraftMessage } from "../../types.js";
import type { CommittedMessage, DraftMessage } from "../../types.js";
const runningSummarySystemPrompt = ({
previousRunningSummary,
@ -46,13 +46,18 @@ Generate a new running summary of the conversation.`;
export const messages = router({
fetchByConversationId: publicProcedure
.input((x) => x as { conversationId: string })
.query(async ({ input: { conversationId }, ctx: { db } }) => {
return await db.messages.findByConversationId(conversationId);
.query(async ({ input: { conversationId }, ctx: { dbClient } }) => {
const rows = (await dbClient
.selectFrom("messages")
.selectAll()
.where("conversationId", "=", conversationId)
.execute()) as Array<CommittedMessage>;
return rows;
}),
deleteOne: publicProcedure
.input((x) => x as { id: string })
.mutation(async ({ input: { id }, ctx: { db } }) => {
await db.messages.delete(id);
.mutation(async ({ input: { id }, ctx: { dbClient } }) => {
await dbClient.deleteFrom("messages").where("id", "=", id).execute();
return { success: true };
}),
generateRunningSummary: publicProcedure

Loading…
Cancel
Save