Add search and RAG workspace flows
This commit is contained in:
51
lib/api.ts
51
lib/api.ts
@@ -14,6 +14,9 @@ import type {
|
||||
PortfolioSummary,
|
||||
ResearchJournalEntry,
|
||||
ResearchJournalEntryType,
|
||||
SearchAnswerResponse,
|
||||
SearchResult,
|
||||
SearchSource,
|
||||
Task,
|
||||
TaskStatus,
|
||||
TaskTimeline,
|
||||
@@ -295,6 +298,54 @@ export async function listFilings(query?: { ticker?: string; limit?: number }) {
|
||||
return await unwrapData<{ filings: Filing[] }>(result, 'Unable to fetch filings');
|
||||
}
|
||||
|
||||
export async function searchKnowledge(input: {
|
||||
query: string;
|
||||
ticker?: string;
|
||||
sources?: SearchSource[];
|
||||
limit?: number;
|
||||
}) {
|
||||
const result = await client.api.search.get({
|
||||
$query: {
|
||||
q: input.query.trim(),
|
||||
...(input.ticker?.trim()
|
||||
? { ticker: input.ticker.trim().toUpperCase() }
|
||||
: {}),
|
||||
...(input.sources && input.sources.length > 0
|
||||
? { sources: input.sources }
|
||||
: {}),
|
||||
...(typeof input.limit === 'number'
|
||||
? { limit: input.limit }
|
||||
: {})
|
||||
}
|
||||
});
|
||||
|
||||
return await unwrapData<{ results: SearchResult[] }>(result, 'Unable to search indexed sources');
|
||||
}
|
||||
|
||||
export async function getSearchAnswer(input: {
|
||||
query: string;
|
||||
ticker?: string;
|
||||
sources?: SearchSource[];
|
||||
limit?: number;
|
||||
}) {
|
||||
return await requestJson<SearchAnswerResponse>({
|
||||
path: '/api/search/answer',
|
||||
method: 'POST',
|
||||
body: {
|
||||
query: input.query.trim(),
|
||||
...(input.ticker?.trim()
|
||||
? { ticker: input.ticker.trim().toUpperCase() }
|
||||
: {}),
|
||||
...(input.sources && input.sources.length > 0
|
||||
? { sources: input.sources }
|
||||
: {}),
|
||||
...(typeof input.limit === 'number'
|
||||
? { limit: input.limit }
|
||||
: {})
|
||||
}
|
||||
}, 'Unable to generate cited answer');
|
||||
}
|
||||
|
||||
export async function getCompanyAnalysis(ticker: string) {
|
||||
const result = await client.api.analysis.company.get({
|
||||
$query: {
|
||||
|
||||
Reference in New Issue
Block a user