update fetch urls & web search show view

This commit is contained in:
duanfuxiang
2025-04-01 18:56:11 +08:00
parent 7642cc1410
commit c8d03bf799
25 changed files with 156 additions and 4967 deletions

View File

@@ -550,7 +550,7 @@ export function parseMsgBlocks(
urls = parsedUrls
}
} catch (error) {
console.error('Failed to parse URLs JSON', error)
// console.error('Failed to parse URLs JSON', error)
}
}
}

View File

@@ -32,7 +32,7 @@ function cosineSimilarity(vecA: number[], vecB: number[]): number {
async function serperSearch(query: string, serperApiKey: string, serperSearchEngine: string): Promise<SearchResult[]> {
return new Promise((resolve, reject) => {
const url = `${SERPER_BASE_URL}?q=${encodeURIComponent(query)}&engine=${serperSearchEngine}&api_key=${serperApiKey}&num=20`;
console.log("serper search url: ", url)
https.get(url, (res: any) => {
let data = '';
@@ -67,6 +67,7 @@ async function serperSearch(query: string, serperApiKey: string, serperSearchEng
}
});
}).on('error', (error: Error) => {
console.error("serper search error: ", error)
reject(error);
});
});
@@ -195,8 +196,8 @@ export async function fetchUrlContent(url: string, apiKey: string): Promise<stri
export async function webSearch(
query: string,
serperApiKey: string,
jinaApiKey: string,
serperSearchEngine: string,
jinaApiKey: string,
ragEngine: RAGEngine
): Promise<string> {
try {