TanGentleman / Augmenta

Automate RAG-powered workflows
MIT License
1 stars 0 forks source link

Issues when a collection directory has been formed, but an embedding failed #46

Open TanGentleman opened 4 months ago

TanGentleman commented 4 months ago

Error message:

(.venv) tan@Tan framework % python -m chat -rag
2024-07-07 16:13:15,338 - INFO - Rag config key rag_mode overridden
2024-07-07 16:13:15,338 - INFO - Rag mode set to True
2024-07-07 16:13:15,338 - INFO - Enabling RAG mode. Doing some validation steps
Collection ollama_example_collection exists!
Enter to continue, or type a new collection name.
2024-07-07 16:13:17,018 - INFO - DB exists! Replacing the manifest.json settings.
2024-07-07 16:13:17,019 - WARNING - Collection from DB not found in manifest.json
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/tan/Documents/GitHub/Augmenta/framework/chat.py", line 1200, in <module>
    main_cli()
  File "/Users/tan/Documents/GitHub/Augmenta/framework/chat.py", line 1175, in main_cli
    config = Config(config_override=config_override)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tan/Documents/GitHub/Augmenta/framework/classes.py", line 669, in __init__
    self.rag_settings = RagSettings(**config["RAG"])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tan/Documents/GitHub/Augmenta/framework/classes.py", line 139, in __init__
    self.rag_mode = True
    ^^^^^^^^^^^^^
  File "/Users/tan/Documents/GitHub/Augmenta/framework/classes.py", line 342, in rag_mode
    self.__enable_rag_mode(
  File "/Users/tan/Documents/GitHub/Augmenta/framework/classes.py", line 204, in __enable_rag_mode
    self.rag_llm = rag_llm
    ^^^^^^^^^^^^
  File "/Users/tan/Documents/GitHub/Augmenta/framework/classes.py", line 448, in rag_llm
    if self.chunk_size * self.k_excerpts > max_chars:
       ^^^^^^^^^^^^^^^
  File "/Users/tan/Documents/GitHub/Augmenta/framework/classes.py", line 399, in chunk_size
    return self.__chunk_size
           ^^^^^^^^^^^^^^^^^
AttributeError: 'RagSettings' object has no attribute '_RagSettings__chunk_size'. Did you mean: '_RagSettings__config'?

I think I can put a bandaid on this one but I want to diagnose it more thoroughly and maybe use the setter/getters more effectively

TanGentleman commented 4 months ago

Seems like this specifically happens when self.rag_llm is set before self.chunk_size, and this error happened because I didn't have a manifest entry to use the settings from. In this case, we should force a re-ingest to form a new manifest, and clear the DB.

Do do this, I would want to handle the case (collection exists + manifest missing) -> re-index using available rag_settings.

TanGentleman commented 4 months ago

Making great progress involving active.json to keep a current complete copy of the state + config. Here's the current error:

Enter your query: .r
Executing command
2024-07-07 16:59:34,578 - INFO - Rag mode set to True
2024-07-07 16:59:34,578 - INFO - Enabling RAG mode. Doing some validation steps
Collection ollama_example_collection exists!
Enter to continue, or type a new collection name.example_collection
Collection name set to example_collection
Collection example_collection exists!
Enter to continue, or type a new collection name.test
Collection name set to test
2024-07-07 17:00:01,946 - INFO - Checking if DB exists for inputs. Make sure this is after settings are finalized!
2024-07-07 17:00:01,946 - INFO - Set 1 inputs
{'rag_mode': True, 'collection_name': 'test', 'embedding_model': 'BAAI/bge-large-en-v1.5', 'method': 'chroma', 'chunk_size': 1000, 'chunk_overlap': 100, 'k_excerpts': 3, 'rag_llm': 'Qwen/Qwen2-72B-Instruct', 'inputs': ['https://example.com/'], 'multivector_enabled': False, 'multivector_method': 'summary'}
2024-07-07 17:00:01,946 - INFO - Primary model set to deepseek-coder
2024-07-07 17:00:01,946 - INFO - Backup model set to meta-llama/Llama-3-70b-chat-hf
2024-07-07 17:00:01,946 - INFO - System message set to You are a helpful AI.
2024-07-07 17:00:01,947 - INFO - Config initialized and set in active.json.
Already in RAG mode
Enter your query: info
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/tan/Documents/GitHub/Augmenta/framework/chat.py", line 1200, in <module>
    main_cli()
  File "/Users/tan/Documents/GitHub/Augmenta/framework/chat.py", line 1193, in main_cli
    chatbot.chat(prompt, persistence_enabled=persistence_enabled)
  File "/Users/tan/Documents/GitHub/Augmenta/framework/chat.py", line 1053, in chat
    self.get_rag_response(prompt, stream=stream)
  File "/Users/tan/Documents/GitHub/Augmenta/framework/chat.py", line 943, in get_rag_response
    assert self.rag_chain is not None, "RAG chain not initialized"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: RAG chain not initialized