langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
52.71k stars 7.71k forks source link

Google Search Api not Working #10325

Open dsnetgo opened 3 weeks ago

dsnetgo commented 3 weeks ago

Self Checks

Dify version

11.0

Cloud or Self Hosted

Cloud, Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

Hi. Google Search Api not Working.

Can you fix this? On version 9.2 everything works. It doesn't work on version 10.x, 11.x

bcbc

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

dosubot[bot] commented 3 weeks ago

I found a similar unsolved discussion titled Google Search Api not Working and a closed issue titled Google search tool just return one search result. The closed issue suggests a solution related to the _process_response method in the SerpAPI class. The issue was that the method only returned the first result when the result type was "text". The suggested fix involves modifying the method to aggregate multiple results into a single string or a list. Here's an example modification:

elif "organic_results" in res.keys() and len(res["organic_results"]) > 0:
    snippets = [result["snippet"] for result in res["organic_results"] if "snippet" in result.keys()]
    toret = "\n".join(snippets)

This change collects the "snippet" from each result and joins them into a single string separated by newlines. You might want to check if this solution applies to your case and adjust your code accordingly [1][2].

To continue talking to Dosu, mention @dosu.