36 lines
870 B
TypeScript
36 lines
870 B
TypeScript
import {
|
|
conversationSchema,
|
|
conversationSummarySchema,
|
|
type ConversationResponse,
|
|
type ConversationSummaryResponse,
|
|
} from "@great-agent/web-contracts";
|
|
import { request } from "./request";
|
|
|
|
export async function listConversations(): Promise<
|
|
ConversationSummaryResponse[]
|
|
> {
|
|
return conversationSummarySchema
|
|
.array()
|
|
.parse(await request("/api/conversations"));
|
|
}
|
|
|
|
export async function getConversation(
|
|
id: string,
|
|
): Promise<ConversationResponse> {
|
|
return conversationSchema.parse(
|
|
await request(`/api/conversations/${encodeURIComponent(id)}`),
|
|
);
|
|
}
|
|
|
|
export async function listProjectConversations(
|
|
projectId: string,
|
|
): Promise<ConversationSummaryResponse[]> {
|
|
return conversationSummarySchema
|
|
.array()
|
|
.parse(
|
|
await request(
|
|
`/api/projects/${encodeURIComponent(projectId)}/conversations`,
|
|
),
|
|
);
|
|
}
|