PDF bot error uploaded pdf file but cannot chat due to below error

Open
#108 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
docker, ollama, python, streamlit
Domain
ai, backend

Research direction

Start in pdf_bot.py at main() around lines 91 and 95, then reproduce the uploaded-PDF chat flow and inspect the Ollama container logs for the terminated llama runner. Done means the PDF can be queried without the Ollama 500 error, with the failure cause confirmed.

Written by the indexing model from the issue text.

Description

pdf_bot-1 | 2024-01-04 06:36:05.583 Embedding: Using SentenceTransformer
pdf_bot-1 | 2024-01-04 06:36:05.583 LLM: Using Ollama: llama2
api-1 | INFO: 127.0.0.1:44452 - "GET / HTTP/1.1" 200 OK
api-1 | INFO: 127.0.0.1:44454 - "GET / HTTP/1.1" 200 OK
api-1 | INFO: 127.0.0.1:48628 - "GET / HTTP/1.1" 200 OK
pdf_bot-1 | 2024-01-04 06:36:21.249 Uncaught app exception
pdf_bot-1 | Traceback (most recent call last):
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
pdf_bot-1 | exec(code, module.dict)
pdf_bot-1 | File "/app/pdf_bot.py", line 95, in
pdf_bot-1 | main()
pdf_bot-1 | File "/app/pdf_bot.py", line 91, in main
pdf_bot-1 | qa.run(query, callbacks=[stream_handler])
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 507, in run
pdf_bot-1 | return self(args[0], callbacks=callbacks, tags=tags, metadata=metadata)[
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 312, in call
pdf_bot-1 | raise e
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 306, in call
pdf_bot-1 | self._call(inputs, run_manager=run_manager)
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/retrieval_qa/base.py", line 144, in _call
pdf_bot-1 | answer = self.combine_documents_chain.run(
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 512, in run
pdf_bot-1 | return self(kwargs, callbacks=callbacks, tags=tags, metadata=metadata)[
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 312, in call
pdf_bot-1 | raise e
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 306, in call
pdf_bot-1 | self._call(inputs, run_manager=run_manager)
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/combine_documents/base.py", line 136, in _call
pdf_bot-1 | output, extra_return_dict = self.combine_docs(
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/combine_documents/stuff.py", line 244, in combine_docs
pdf_bot-1 | return self.llm_chain.predict(callbacks=callbacks, **inputs), {}
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/llm.py", line 293, in predict
pdf_bot-1 | return self(kwargs, callbacks=callbacks)[self.output_key]
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 312, in call
pdf_bot-1 | raise e
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/base.py", line 306, in call
pdf_bot-1 | self._call(inputs, run_manager=run_manager)
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/llm.py", line 103, in _call
pdf_bot-1 | response = self.generate([inputs], run_manager=run_manager)
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain/chains/llm.py", line 115, in generate
pdf_bot-1 | return self.llm.generate_prompt(
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 496, in generate_prompt
pdf_bot-1 | return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 383, in generate
pdf_bot-1 | raise e
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 373, in generate
pdf_bot-1 | self._generate_with_cache(
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 529, in _generate_with_cache
pdf_bot-1 | return self._generate(
pdf_bot-1 | ^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_community/chat_models/ollama.py", line 209, in _generate
pdf_bot-1 | final_chunk = self._chat_stream_with_aggregation(
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_community/chat_models/ollama.py", line 168, in _chat_stream_with_aggregation
pdf_bot-1 | for stream_resp in self._create_chat_stream(messages, stop, **kwargs):
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_community/chat_models/ollama.py", line 155, in _create_chat_stream
pdf_bot-1 | yield from self._create_stream(
pdf_bot-1 | ^^^^^^^^^^^^^^^^^^^^
pdf_bot-1 | File "/usr/local/lib/python3.11/site-packages/langchain_community/llms/ollama.py", line 203, in _create_stream
pdf_bot-1 | raise ValueError(
pdf_bot-1 | ValueError: Ollama call failed with status code 500. Details: llama runner process has terminated
api-1 | INFO: 127.0.0.1:48632 - "GET / HTTP/1.1" 200 OK
api-1 | INFO: 127.0.0.1:52504 - "GET / HTTP/1.1" 200 OK
api-1 | INFO: 127.0.0.1:52510 - "GET / HTTP/1.1" 200 OK
api-1 | INFO: 127.0.0.1:38514 - "GET / HTTP/1.1" 200 OK
api-1 | INFO: 127.0.0.1:38516 - "GET / HTTP/1.1" 200 OK

Dominant language
Python
Stars
5.4k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker/genai-stack

All issues in docker/genai-stack

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.