mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2026-04-09 05:14:26 +00:00
Compare commits
3 Commits
f83f813bd7
...
b02f5aa37f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b02f5aa37f | ||
|
|
a2f2ac532e | ||
|
|
1763ee9d1f |
@@ -19,6 +19,9 @@ class APISearchAgent {
|
||||
chatHistory: input.chatHistory,
|
||||
followUp: input.followUp,
|
||||
llm: input.config.llm,
|
||||
}).catch((err) => {
|
||||
console.error(`Error executing widgets: ${err}`);
|
||||
return [];
|
||||
});
|
||||
|
||||
let searchPromise: Promise<ResearcherOutput> | null = null;
|
||||
|
||||
@@ -38,11 +38,30 @@ export const searchSearxng = async (
|
||||
});
|
||||
}
|
||||
|
||||
const res = await fetch(url);
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 10000);
|
||||
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`SearXNG error: ${res.statusText}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
const results: SearxngSearchResult[] = data.results;
|
||||
const suggestions: string[] = data.suggestions;
|
||||
|
||||
return { results, suggestions };
|
||||
} catch (err: any) {
|
||||
if (err.name === 'AbortError') {
|
||||
throw new Error('SearXNG search timed out');
|
||||
}
|
||||
throw err;
|
||||
} finally {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user