davidshtian / Bedrock-ChatBot-with-LangChain-and-Streamlit

A simple and clear example for implement a chatbot with Bedrock (Claude and Mistral) + LangChain + Streamlit.
62 stars 24 forks source link

Web Search - TypeError: can only concatenate str (not "list") to str #3

Closed madtank closed 5 months ago

madtank commented 5 months ago

Love the new feature!

When using web search I got this error TypeError: can only concatenate str (not "list") to str. This resolved my issue. Let me know if you know the issue, or want me to open a PR.

import ast def web_or_local(prompt: str, web_local: str) -> str: if web_local == "Web": search = SerpAPIWrapper() search_text = search.run(prompt)

Convert search_text to a list

    search_text = ast.literal_eval(search_text)
    web_contect = "Here is the web search result: \n\n<search>\n\n" + '\n'.join(search_text) + "\n\n</search>\n\n"
    prompt = web_contect + prompt
    return prompt
else:
    return prompt
madtank commented 5 months ago

Maybe it was a glitch, I tried again, and worked fine.