dify icon indicating copy to clipboard operation
dify copied to clipboard

Integrated SearXNG search as built-in tool

Open junytang opened this issue 1 year ago • 5 comments

Description

Integrated SearXNG search engine as built-in tool. SearXNG is a meta search engine (https://github.com/searxng/searxng) which provides better search results than Google/Bing

Type of Change

  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  1. Run SearXNG container
docker run --rm \
             -d -p 8080:8080 \
             -v "${PWD}/searxng:/etc/searxng" \
             -e "BASE_URL=http://0.0.0.0:8080/" \
             -e "INSTANCE_NAME=searxng" \
             searxng/searxng
  1. Add following line in ${PWD}/searxng/settings.yml file
  # remove format to deny access, use lower case.
  # formats: [html, csv, json, rss]
  formats:
    - html
    - json    # <-- add this line 
  1. Add SearXNG Search tool
  2. Just like testing the built-in GoogleSearch tool

Suggested Checklist:

  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings
  • [ ] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • [ ] optional I have made corresponding changes to the documentation
  • [ ] optional I have added tests that prove my fix is effective or that my feature works
  • [ ] optional New and existing unit tests pass locally with my changes

junytang avatar Apr 11 '24 10:04 junytang

How can I solve this? image I have mapped 8080 to 8081 already.

Yeuoly avatar Apr 11 '24 11:04 Yeuoly

How can I solve this? image I have mapped 8080 to 8081 already.

Sorry, I forgot this:

Need to add following changes in SearXNG settings.yml file which locates in container volume

  # remove format to deny access, use lower case.
  # formats: [html, csv, json, rss]
  formats:
    - html
    - json ( <-- add this line )

junytang avatar Apr 11 '24 11:04 junytang

and then I ran into this issue image

Yeuoly avatar Apr 11 '24 11:04 Yeuoly

and then I ran into this issue image

This is an unrelated issue. You can just ignore it or add your secret _key for better security.

Does http://localhost:8081/search?q=test&format=json work in web browser ?

junytang avatar Apr 11 '24 11:04 junytang

Hello thank you for your contribution, you can add my wechat: crazyphage I will invite you to our contributor's group.

crazywoola avatar Apr 11 '24 13:04 crazywoola

Thx for contributing~

Yeuoly avatar Apr 12 '24 03:04 Yeuoly

Pls fix the CI error. BTW, would you mind write some tutorials about how to integrate SearXNG with Dify and create a PR to this repo ? , then link the help tooltip to there.

Yeuoly avatar Apr 12 '24 03:04 Yeuoly

Pls fix the CI error. BTW, would you mind write some tutorials about how to integrate SearXNG with Dify and create a PR to this repo ? , then link the help tooltip to there.

Sure.

Update: added

junytang avatar Apr 12 '24 03:04 junytang