mamei16 / LLM_Web_search

An extension for oobabooga/text-generation-webui that enables the LLM to search the web using DuckDuckGo
GNU Affero General Public License v3.0
161 stars 24 forks source link

Unexpected Keyword 'action' #66

Closed adamoutler closed 3 months ago

adamoutler commented 3 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. create a docker container with Textgen web ui. https://github.com/Atinoda/text-generation-webui-docker
  2. Install LLM_Web_search
  3. execute the pip install extensions/LLM_Web_search/requirements.txt --upgrade
  4. restart textgen.
  5. Go to 'textenwebui'
  6. Command ai to say search_web("uber")
  7. observe warnings and Check logs
    Llama.generate: prefix-match hit
    LLM_Web_search | Searching for uber...
    LLM_Web_search | 'https://m.uber.com/' generated an exception: 0, message='', url=URL('https://m.uber.com/')
    LLM_Web_search | uber generated an exception: catch_warnings.__init__() got an unexpected keyword argument 'action'
    Output generated in 4.08 seconds (6.63 tokens/s, 27 tokens, context 1125, seed 1792952730)
    Llama.generate: prefix-match hit

Expected behavior I expect a search occurs and results are used by the AI. I observe an error.

Screenshots

image

mamei16 commented 3 months ago

Hi, thank you for the report!

Regarding the first exception, it appears that somehow the mobile website of Uber causes an unclear issue with aiohttp, the library that is used to download websites. No exception occurs when I try to use requests to download this website instead. I think the best way to get a solution is to raise the issue with https://github.com/aio-libs/aiohttp directly. A minimal example provoking the exception is this:

import aiohttp
import asyncio

headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0",
               "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
               "Accept-Language": "en-US,en;q=0.5"}
url = 'https://m.uber.com/'

async def async_fetch_url(url):
    async with aiohttp.ClientSession(headers=headers) as session:
        resp = await session.get(url)
        return await resp.text()

asyncio.run(async_fetch_url(url))

Regarding the second exception: It appears that somewhere between Python 3.10 and Python 3.11, the keyword arguments of the warnings.catch_warnings context manager where changed (compare https://docs.python.org/3.10/library/warnings.html#warnings.catch_warnings and https://docs.python.org/3.11/library/warnings.html#warnings.catch_warnings). The python version installed by the oobabooga installer is 3.11, which is also the version this extension is programmed for. However, https://github.com/Atinoda/text-generation-webui-docker is based on Ubuntu 22.04, which results in Python 3.10 being installed in the image.

I suggest that you create an issue on the docker image project page and ask the Ubuntu base version to be updated to 23.x, which will result in python 3.11 being installed. This should resolve the catch_warnings exception.

adamoutler commented 3 months ago

With all due respect, I'm new at this tool and just hacking around here. I don't have time or want responsiblity for answering followup questions on aiohttp. But a python upgrade seems appropriate. Will handle that one.

mamei16 commented 3 months ago

Understandable, have a nice day.