bitswired / website-to-knowledge-base

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List index error while running the app

Kashif-Raza6 opened this issue · comments

Error details:
IndexError: list index out of range Traceback: File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script exec(code, module.__dict__) File "H:\Datathons\Imp Repos\website to knowledge base chatbot\website-to-knowledge-base-main\app.py", line 63, in <module> kb = get_knowledge_base(sitemap_url, pattern) File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 194, in wrapper return cached_func(*args, **kwargs) File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 223, in __call__ return self._get_or_create_cached_value(args, kwargs) File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 248, in _get_or_create_cached_value return self._handle_cache_miss(cache, value_key, func_args, func_kwargs) File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 302, in _handle_cache_miss computed_value = self._info.func(*func_args, **func_kwargs) File "H:\Datathons\Imp Repos\website to knowledge base chatbot\website-to-knowledge-base-main\app.py", line 47, in get_knowledge_base return KnowledgeBase( File "H:\Datathons\Imp Repos\website to knowledge base chatbot\website-to-knowledge-base-main\knowledge_base.py", line 75, in __init__ docsearch = Chroma.from_documents(docs, embeddings) File "F:\Programs\miniconda\lib\site-packages\langchain\vectorstores\chroma.py", line 412, in from_documents return cls.from_texts( File "F:\Programs\miniconda\lib\site-packages\langchain\vectorstores\chroma.py", line 380, in from_texts chroma_collection.add_texts(texts=texts, metadatas=metadatas, ids=ids) File "F:\Programs\miniconda\lib\site-packages\langchain\vectorstores\chroma.py", line 159, in add_texts self._collection.add( File "F:\Programs\miniconda\lib\site-packages\chromadb\api\models\Collection.py", line 82, in add ids = validate_ids(maybe_cast_one_to_many(ids)) File "F:\Programs\miniconda\lib\site-packages\chromadb\api\types.py", line 71, in maybe_cast_one_to_many if isinstance(target[0], (int, float)):

EDIT (better formatting):

IndexError: list index out of range
Traceback:
File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
File "H:\Datathons\Imp Repos\website to knowledge base chatbot\website-to-knowledge-base-main\app.py", line 63, in <module>
    kb = get_knowledge_base(sitemap_url, pattern)
File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 194, in wrapper
    return cached_func(*args, **kwargs)
File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 223, in __call__
    return self._get_or_create_cached_value(args, kwargs)
File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 248, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
File "F:\Programs\miniconda\lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 302, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)
File "H:\Datathons\Imp Repos\website to knowledge base chatbot\website-to-knowledge-base-main\app.py", line 47, in get_knowledge_base
    return KnowledgeBase(
File "H:\Datathons\Imp Repos\website to knowledge base chatbot\website-to-knowledge-base-main\knowledge_base.py", line 75, in __init__
    docsearch = Chroma.from_documents(docs, embeddings)
File "F:\Programs\miniconda\lib\site-packages\langchain\vectorstores\chroma.py", line 412, in from_documents
    return cls.from_texts(
File "F:\Programs\miniconda\lib\site-packages\langchain\vectorstores\chroma.py", line 380, in from_texts
    chroma_collection.add_texts(texts=texts, metadatas=metadatas, ids=ids)
File "F:\Programs\miniconda\lib\site-packages\langchain\vectorstores\chroma.py", line 159, in add_texts
    self._collection.add(
File "F:\Programs\miniconda\lib\site-packages\chromadb\api\models\Collection.py", line 82, in add
    ids = validate_ids(maybe_cast_one_to_many(ids))
File "F:\Programs\miniconda\lib\site-packages\chromadb\api\types.py", line 71, in maybe_cast_one_to_many
    if isinstance(target[0], (int, float)):
commented

Hey :)

Can you provide a bit more context?

  1. Did you modify the code or run it as it is in the repo?
  2. Also, could you provide the site map URL that you used to get this error (so I can reproduce and fix the issue if there is one)?
commented

I have the same issue. I ended up pulling down the exact code to make sure it wasn't a typo. Other than adding .env it is identical code and I have appears to be the same error. A requirements.txt might be helpful here.

EDIT: to get this error I run: python knowledge_base.py and I'm not using Poetry

commented

How do you install the dependencies?

You extracted the packages listed in pyproject.toml to a requirements.txt, then run pip install -r requirements.txt?

commented

How do you install the dependencies?

You extracted the packages listed in pyproject.toml to a requirements.txt, then run pip install -r requirements.txt?

Actually I figured it out. You have to set the pattern to None. It had a value in there that doesn't work.

commented

@coolrazor007 can you elaborate, where to set the pattern to None? This will be really helpful. Facing the same problem. Thanks

commented

The pattern has a default value of None normally:

pattern: Optional[str] = None,

commented

Nope @jimzer :( did not work for me !