Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searxng as search provider [free, open source] #338

Open
flozi00 opened this issue Jul 10, 2023 · 5 comments
Open

Searxng as search provider [free, open source] #338

flozi00 opened this issue Jul 10, 2023 · 5 comments
Labels
back This issue is related to the Svelte backend or the DB

Comments

@flozi00
Copy link
Contributor

flozi00 commented Jul 10, 2023

https://github.com/searxng/searxng
https://searx.space/

Searx would be an free alternative for personal use to the serp providers.
What do you think about integrating it ?
I could start an PR for that if you are open for

@nsarrazin nsarrazin added the back This issue is related to the Svelte backend or the DB label Jul 11, 2023
@nsarrazin
Copy link
Collaborator

Hey! I think it would be nice to support an open source search tool for sure. Feel free to open a PR with an integration and let me know if you need help.

@flozi00
Copy link
Contributor Author

flozi00 commented Jul 11, 2023

Great, I will add it tomorrow

It's only one file, correct ? https://github.com/huggingface/chat-ui/blob/main/src/lib/server/websearch/searchWeb.ts

@nsarrazin
Copy link
Collaborator

Thanks! Yes it's this file, you can also add an empty entry to the .env so people know it's a field that can be filled.

@flozi00
Copy link
Contributor Author

flozi00 commented Jul 11, 2023

export async function searchSearx(query: string) {
	query = encodeURI(query);
	const response = await fetch("https://searx.dresden.network/search?categories=general&format=json&q=" + query, {
		method: "GET",
		headers: {
			"Content-type": "application/json; charset=UTF-8",
		},
	});

	/* eslint-disable @typescript-eslint/no-explicit-any */
	var data = (await response.json()) as Record<string, any>;

	if (!response.ok) {
		throw new Error(
			data["message"] ??
			`Searx API returned error code ${response.status} - ${response.statusText}`
		);
	}

	for (let i = 0; i < data.results.length; i++) {
		data.results[i]["link"] = data.results[i]["url"];
	}

	return {
		organic_results: data["results"] ?? [],
		knowledge_graph: data["infoboxes"][0]["content"] ?? null,
		answer_box: data["answers"] ?? null,
	};
}

I never used ts, so maybe its faster if you pick up this code and add it, otherwise i will play more around with that
For example I dont find where to add the if statement to show the search in web option in UI

@gary149
Copy link
Collaborator

gary149 commented Sep 18, 2023

Feel free to open a PR for it (adding it to the 2 existing providers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back This issue is related to the Svelte backend or the DB
Projects
None yet
Development

No branches or pull requests

3 participants