feat(history): 实现三模历史搜索、每日智能协同摘要与时间轴侧栏 (Phase P2)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { DailyDigest } from '../types/workbench';
|
||||
|
||||
export async function fetchDailyDigests(
|
||||
sessionId: string,
|
||||
from?: string,
|
||||
to?: string
|
||||
): Promise<DailyDigest[]> {
|
||||
const url = new URL('/api/v1/chat/digests', window.location.origin);
|
||||
url.searchParams.set('session_id', sessionId);
|
||||
if (from) url.searchParams.set('from', from);
|
||||
if (to) url.searchParams.set('to', to);
|
||||
|
||||
const res = await fetch(url.toString(), {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`fetchDailyDigests failed: HTTP ${res.status}`);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function generateDailyDigest(
|
||||
sessionId: string,
|
||||
dayKey: string
|
||||
): Promise<{ queued: boolean; digest: DailyDigest }> {
|
||||
const res = await fetch('/api/v1/chat/digests/generate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
session_id: sessionId,
|
||||
day_key: dayKey,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`generateDailyDigest failed: HTTP ${res.status}`);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { ChatSearchHit, ChatSearchMode } from '../types/workbench';
|
||||
|
||||
export interface SearchChatMessagesParams {
|
||||
sessionId: string;
|
||||
q: string;
|
||||
mode?: ChatSearchMode;
|
||||
category?: string;
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export async function searchChatMessages(params: SearchChatMessagesParams): Promise<ChatSearchHit[]> {
|
||||
const url = new URL('/api/v1/chat/search', window.location.origin);
|
||||
url.searchParams.set('session_id', params.sessionId);
|
||||
url.searchParams.set('q', params.q);
|
||||
|
||||
if (params.mode) {
|
||||
url.searchParams.set('mode', params.mode);
|
||||
}
|
||||
if (params.category && params.category !== 'all') {
|
||||
url.searchParams.set('category', params.category);
|
||||
}
|
||||
if (params.dateFrom) {
|
||||
url.searchParams.set('date_from', params.dateFrom);
|
||||
}
|
||||
if (params.dateTo) {
|
||||
url.searchParams.set('date_to', params.dateTo);
|
||||
}
|
||||
if (params.limit) {
|
||||
url.searchParams.set('limit', String(params.limit));
|
||||
}
|
||||
|
||||
const res = await fetch(url.toString(), {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`searchChatMessages failed: HTTP ${res.status}`);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
Reference in New Issue
Block a user