Add hybrid research copilot workspace
This commit is contained in:
44
lib/api.ts
44
lib/api.ts
@@ -15,6 +15,8 @@ import type {
|
||||
ResearchArtifact,
|
||||
ResearchArtifactKind,
|
||||
ResearchArtifactSource,
|
||||
ResearchCopilotSession,
|
||||
ResearchCopilotTurnResponse,
|
||||
ResearchJournalEntry,
|
||||
ResearchJournalEntryType,
|
||||
SearchAnswerResponse,
|
||||
@@ -226,6 +228,48 @@ export async function getResearchWorkspace(ticker: string) {
|
||||
}, 'Unable to fetch research workspace');
|
||||
}
|
||||
|
||||
export async function getResearchCopilotSession(ticker: string) {
|
||||
return await requestJson<{ session: ResearchCopilotSession | null }>({
|
||||
path: `/api/research/copilot/session?ticker=${encodeURIComponent(ticker.trim().toUpperCase())}`
|
||||
}, 'Unable to fetch research copilot session');
|
||||
}
|
||||
|
||||
export async function runResearchCopilotTurn(input: {
|
||||
ticker: string;
|
||||
query: string;
|
||||
sources?: SearchSource[];
|
||||
pinnedArtifactIds?: number[];
|
||||
memoSection?: ResearchMemoSection | null;
|
||||
}) {
|
||||
return await requestJson<ResearchCopilotTurnResponse>({
|
||||
path: '/api/research/copilot/turn',
|
||||
method: 'POST',
|
||||
body: {
|
||||
ticker: input.ticker.trim().toUpperCase(),
|
||||
query: input.query.trim(),
|
||||
...(input.sources && input.sources.length > 0 ? { sources: input.sources } : {}),
|
||||
...(input.pinnedArtifactIds && input.pinnedArtifactIds.length > 0 ? { pinnedArtifactIds: input.pinnedArtifactIds } : {}),
|
||||
...(input.memoSection ? { memoSection: input.memoSection } : {})
|
||||
}
|
||||
}, 'Unable to run research copilot turn');
|
||||
}
|
||||
|
||||
export async function queueResearchCopilotJob(input: {
|
||||
ticker: string;
|
||||
query: string;
|
||||
sources?: SearchSource[];
|
||||
}) {
|
||||
return await requestJson<{ task: Task }>({
|
||||
path: '/api/research/copilot/job',
|
||||
method: 'POST',
|
||||
body: {
|
||||
ticker: input.ticker.trim().toUpperCase(),
|
||||
query: input.query.trim(),
|
||||
...(input.sources && input.sources.length > 0 ? { sources: input.sources } : {})
|
||||
}
|
||||
}, 'Unable to queue research brief');
|
||||
}
|
||||
|
||||
export async function listResearchLibrary(input: {
|
||||
ticker: string;
|
||||
q?: string;
|
||||
|
||||
Reference in New Issue
Block a user