ui: add Rerank tab to playground (#536)
Add a new Rerank tab to the playground that lets users test /v1/rerank endpoints. Supports a visual table editor and a JSON editor mode that stay in sync when toggling between them. - add rerankApi.ts with typed wrapper for /v1/rerank - add RerankInterface.svelte with query input, sortable document table, color-coded scores, auto-add row, cancel/clear, and token usage - add rerankLoading store to playgroundActivity derived store - register Rerank tab in Playground.svelte Updates #481
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export interface RerankResult {
|
||||
index: number;
|
||||
relevance_score: number;
|
||||
}
|
||||
|
||||
export interface RerankResponse {
|
||||
model: string;
|
||||
object: string;
|
||||
usage: { prompt_tokens: number; total_tokens: number };
|
||||
results: RerankResult[];
|
||||
}
|
||||
|
||||
export async function rerank(
|
||||
model: string,
|
||||
query: string,
|
||||
documents: string[],
|
||||
signal: AbortSignal
|
||||
): Promise<RerankResponse> {
|
||||
const response = await fetch("/v1/rerank", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ model, query, documents }),
|
||||
signal,
|
||||
});
|
||||
if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
|
||||
return response.json();
|
||||
}
|
||||
Reference in New Issue
Block a user