Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt with sources example: create_new_library Error #718

Closed
williamsokol opened this issue May 13, 2024 · 2 comments
Closed

Prompt with sources example: create_new_library Error #718

williamsokol opened this issue May 13, 2024 · 2 comments

Comments

@williamsokol
Copy link

When running an unchanged version of /root/llmware/examples/Prompts/prompt_with_sources.py I will recieve an error:

root@6753ed4b24e5:~/llmware# /bin/python3 /root/llmware/examples/Prompts/prompt_with_sources.py
Example - prompt_with_sources - attaching several different knowledge sources to a Prompt directly.
/usr/local/lib/python3.10/dist-packages/pymongo/collection.py:1685: UserWarning: use an explicit session with no_cursor_timeout=True otherwise the cursor may still timeout after 30 minutes, for more info see https://mongodb.com/docs/v4.4/reference/method/cursor.noCursorTimeout/#session-idle-timeout-overrides-nocursortimeout
  return Cursor(self, *args, **kwargs)
Traceback (most recent call last):
  File "/root/llmware/examples/Prompts/prompt_with_sources.py", line 67, in <module>
    prompt_with_sources(model_name,library_name)
  File "/root/llmware/examples/Prompts/prompt_with_sources.py", line 19, in prompt_with_sources
    library = Library().create_new_library(library_name)
  File "/usr/local/lib/python3.10/dist-packages/llmware/library.py", line 146, in create_new_library
    library_exists = self.check_if_library_exists(library_name,account_name)
  File "/usr/local/lib/python3.10/dist-packages/llmware/library.py", line 300, in check_if_library_exists
    library_card = LibraryCatalog().get_library_card(library_name, account_name=account_name)
  File "/usr/local/lib/python3.10/dist-packages/llmware/library.py", line 836, in get_library_card
    db_record = CollectionRetrieval("library", account_name=account_name).lookup("library_name", library_name)
  File "/usr/local/lib/python3.10/dist-packages/llmware/resources.py", line 113, in lookup
    return self._retriever.lookup(key,value)
  File "/usr/local/lib/python3.10/dist-packages/llmware/resources.py", line 633, in lookup
    target = list(self.collection.find({key:value}, no_cursor_timeout=True))
  File "/usr/local/lib/python3.10/dist-packages/pymongo/cursor.py", line 1243, in next
    if len(self.__data) or self._refresh():
  File "/usr/local/lib/python3.10/dist-packages/pymongo/cursor.py", line 1160, in _refresh
    self.__send_message(q)
  File "/usr/local/lib/python3.10/dist-packages/pymongo/cursor.py", line 1039, in __send_message
    response = client._run_operation(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/_csot.py", line 108, in csot_wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1425, in _run_operation
    return self._retryable_read(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1534, in _retryable_read
    return self._retry_internal(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/_csot.py", line 108, in csot_wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1501, in _retry_internal
    ).run()
  File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 2347, in run
    return self._read() if self._is_read else self._write()
  File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 2477, in _read
    self._server = self._get_server()
  File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 2433, in _get_server
    return self._client._select_server(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/mongo_client.py", line 1316, in _select_server
    server = topology.select_server(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 369, in select_server
    server = self._select_server(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 347, in _select_server
    servers = self.select_servers(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 254, in select_servers
    server_descriptions = self._select_servers_loop(
  File "/usr/local/lib/python3.10/dist-packages/pymongo/topology.py", line 304, in _select_servers_loop
    raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 66429f6715cc1202ed232b27, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
root@6753ed4b24e5:~/llmware# 

I have ran many of the other examples with no issue, and I have the same exact error on a different computer. So I believe the issue is somewhere in the code but I am not sure where.

@doberst
Copy link
Contributor

doberst commented May 14, 2024

@williamsokol - thanks for sharing this and sorry that you ran into an issue with this example. If no database is specified, then by default, LLMWare will look for Mongo. I presume that you don't have a MongoDB instance running, so it throws the error. To solve this, please add the following two lines of code:

from llmware.configs import LLMWareConfig
LLMWareConfig().set_active_db("sqlite")

This will set the active db to 'sqlite' - which is used in most of the examples for 'no-install' required set up.

Please confirm back that this solves the issue. (Also, we will note this to add as comments in this and other examples.)

@doberst
Copy link
Contributor

doberst commented May 23, 2024

The example has been updated too to explicitly show setting the LLMWareConfig().set_active_db parameter. Marking the issue as closed.

@doberst doberst closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants