neuml / txtchat

💭 Retrieval augmented generation (RAG) and language model powered search applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyError: 'result'

dominikstein-ibm opened this issue · comments

starting the agent with
python -m txtchat.agent summary.yml
but it always fails with this error:

2023-02-24 17:05:16,673 [INFO] call: Starting agent
Traceback (most recent call last):
File "XXX/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "XXX/.pyenv/versions/3.8.13/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "XXX/txtchat/src/python/txtchat/agent/main.py", line 24, in
agent()
File "XXX/txtchat/agent/base.py", line 42, in call
self.start()
File "XXX/txtchatgit/txtchat/src/python/txtchat/agent/rocketchat.py", line 47, in start
asyncio.run(self.run())
File "XXX/.pyenv/versions/3.8.13/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "XXX/.pyenv/versions/3.8.13/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "XXX/txtchat/src/python/txtchat/agent/rocketchat.py", line 56, in run
await self.chat.start(*self.parameters())
File "/XXX/.pyenv/versions/3.8.13/lib/python3.8/site-packages/rocketchat_async/core.py", line 25, in start
self.user_id = await self._login(username, password)
File "/XXX/.pyenv/versions/3.8.13/lib/python3.8/site-packages/rocketchat_async/core.py", line 46, in _login
return await Login.call(self._dispatcher, username, password)
File "XXX/.pyenv/versions/3.8.13/lib/python3.8/site-packages/rocketchat_async/methods.py", line 59, in call
return cls._parse(response)
File "XXX/.pyenv/versions/3.8.13/lib/python3.8/site-packages/rocketchat_async/methods.py", line 52, in _parse
return response['result']['id']
KeyError: 'result'

Thank you for this issue and #2. Did you install txtai and txtchat from source? I still haven't pushed the latest releases of either to PyPI.

Hi David, thanks for the quick response. I also thought about this since I saw txtai 5.4.0 being referenced, but its not released yet. It might actually be the reason for this behaviour. Could you push to PyPI? Would be awesome :)
Also I'm building a demo using my own data (embedding index) which uses the Docker Image and REST API. Once you pushed 5.4.0 to PyPI will I be able to use the Docker Container in 5.4.0 as well?

Will do. It will be released next week, still have a few more things I want to add in for txtai 5.4

In the meantime, running the following should allow you to get things running locally.

pip install git+https://github.com/neuml/txtai

thanks! I found the reason. the KeyError happens when the environment variable is not set correctly.
Somehow "username" was silently overriden with another value on my system.
I changed the source code locally to check for "rcusername" and "rcpassword" to avoid this. checking for generic "username" env variable might cause some trouble for others as well, due to the ambuigity of the "username".

Just made a change to restructure both the parameters and env variables to require an AGENT prefix. In other words, URL is now AGENT_URL and so forth.

If entering through the YAML config, the parameters are under an agent key. i.e. agent: url: <url>