feat: add error handling to SearXNG search provider
This commit is contained in:
parent
0226de7c39
commit
379ba6996d
@ -50,16 +50,20 @@ export const searxngSearch = async (query: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const docs: Document<Record<string, any>>[] = []
|
const docs: Document<Record<string, any>>[] = []
|
||||||
for (const result of searchResults) {
|
try {
|
||||||
const loader = new PageAssistHtmlLoader({
|
for (const result of searchResults) {
|
||||||
html: "",
|
const loader = new PageAssistHtmlLoader({
|
||||||
url: result.link
|
html: "",
|
||||||
})
|
url: result.link
|
||||||
|
})
|
||||||
const documents = await loader.loadByURL()
|
|
||||||
documents.forEach((doc) => {
|
const documents = await loader.loadByURL()
|
||||||
docs.push(doc)
|
documents.forEach((doc) => {
|
||||||
})
|
docs.push(doc)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ollamaUrl = await getOllamaURL()
|
const ollamaUrl = await getOllamaURL()
|
||||||
@ -79,7 +83,7 @@ export const searxngSearch = async (query: string) => {
|
|||||||
const chunks = await textSplitter.splitDocuments(docs)
|
const chunks = await textSplitter.splitDocuments(docs)
|
||||||
const store = new MemoryVectorStore(ollamaEmbedding)
|
const store = new MemoryVectorStore(ollamaEmbedding)
|
||||||
await store.addDocuments(chunks)
|
await store.addDocuments(chunks)
|
||||||
|
|
||||||
const resultsWithEmbeddings = await store.similaritySearch(query, 3)
|
const resultsWithEmbeddings = await store.similaritySearch(query, 3)
|
||||||
|
|
||||||
const searchResult = resultsWithEmbeddings.map((result) => {
|
const searchResult = resultsWithEmbeddings.map((result) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user