adds search support with exa
This commit is contained in:
@@ -5,6 +5,14 @@ export type ChatSummary = {
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type SearchSummary = {
|
||||
id: string;
|
||||
title: string | null;
|
||||
query: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type Message = {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
@@ -21,6 +29,34 @@ export type ChatDetail = {
|
||||
messages: Message[];
|
||||
};
|
||||
|
||||
export type SearchResultItem = {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
rank: number;
|
||||
title: string | null;
|
||||
url: string;
|
||||
publishedDate: string | null;
|
||||
author: string | null;
|
||||
text: string | null;
|
||||
highlights: string[] | null;
|
||||
highlightScores: number[] | null;
|
||||
score: number | null;
|
||||
favicon: string | null;
|
||||
image: string | null;
|
||||
};
|
||||
|
||||
export type SearchDetail = {
|
||||
id: string;
|
||||
title: string | null;
|
||||
query: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
requestId: string | null;
|
||||
latencyMs: number | null;
|
||||
error: string | null;
|
||||
results: SearchResultItem[];
|
||||
};
|
||||
|
||||
export type CompletionRequestMessage = {
|
||||
role: "system" | "user" | "assistant" | "tool";
|
||||
content: string;
|
||||
@@ -96,6 +132,42 @@ export async function getChat(chatId: string) {
|
||||
return data.chat;
|
||||
}
|
||||
|
||||
export async function listSearches() {
|
||||
const data = await api<{ searches: SearchSummary[] }>("/v1/searches");
|
||||
return data.searches;
|
||||
}
|
||||
|
||||
export async function createSearch(body?: { title?: string; query?: string }) {
|
||||
const data = await api<{ search: SearchSummary }>("/v1/searches", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body ?? {}),
|
||||
});
|
||||
return data.search;
|
||||
}
|
||||
|
||||
export async function getSearch(searchId: string) {
|
||||
const data = await api<{ search: SearchDetail }>(`/v1/searches/${searchId}`);
|
||||
return data.search;
|
||||
}
|
||||
|
||||
export async function runSearch(
|
||||
searchId: string,
|
||||
body: {
|
||||
query?: string;
|
||||
title?: string;
|
||||
type?: "auto" | "fast" | "deep" | "instant";
|
||||
numResults?: number;
|
||||
includeDomains?: string[];
|
||||
excludeDomains?: string[];
|
||||
}
|
||||
) {
|
||||
const data = await api<{ search: SearchDetail }>(`/v1/searches/${searchId}/run`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
return data.search;
|
||||
}
|
||||
|
||||
export async function runCompletion(body: {
|
||||
chatId: string;
|
||||
provider: "openai" | "anthropic" | "xai";
|
||||
|
||||
Reference in New Issue
Block a user