You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { PageContextServer } from "vike/types";
|
|
import { createCaller } from "../../../server/trpc/chat.js";
|
|
import { getDbClient } from "../../../database/postgres.js";
|
|
import { getOpenrouter } from "../../../server/provider.js";
|
|
import { env } from "../../../server/env.js";
|
|
|
|
export type Data = Awaited<ReturnType<typeof data>>;
|
|
|
|
export const data = async (pageContext: PageContextServer) => {
|
|
const { id } = pageContext.routeParams;
|
|
const caller = createCaller({
|
|
openrouter: getOpenrouter(
|
|
(pageContext.env?.OPENROUTER_API_KEY || env.OPENROUTER_API_KEY) as string
|
|
),
|
|
// jwt: pageContext.,
|
|
dbClient: getDbClient(
|
|
(pageContext.env?.POSTGRES_CONNECTION_STRING ||
|
|
env.POSTGRES_CONNECTION_STRING) as string
|
|
),
|
|
});
|
|
|
|
const [
|
|
conversation,
|
|
// messages,
|
|
// facts,
|
|
// factTriggers
|
|
] = await Promise.all([
|
|
caller.conversations.fetchOne({ id }),
|
|
// caller.conversations.fetchMessages({ conversationId: id }),
|
|
// caller.facts.fetchByConversationId({ conversationId: id }),
|
|
// caller.factTriggers.fetchByConversationId({ conversationId: id }),
|
|
]);
|
|
|
|
return {
|
|
conversation,
|
|
// messages,
|
|
// facts,
|
|
// factTriggers
|
|
};
|
|
};
|