[BUG] - <Error while uploading and indexing>
Description
I have the following error while uploading and indexing file (both in docker in direct installation)
Reproduction steps
1. Go to 'Files --> File Collection'
2. Drag and drop a pdf file and Click on 'Upload and index'
3. See error
Screenshots
No response
Logs
No response
Browsers
No response
OS
No response
Additional information
No response
I am using ollama as default and openaiembeddings from ollama
Hi please try edit the embedding model name in the File Collection setting to
ollama. This setting is a bit obscured, and we gonna move it to somewhere more visible soon.
Also probably need to switch LLM relevant ranking to ollama as well
(or you have slow machine, turn it off to save computation time in LLM call, tick off
Use LLM relevant score
Followed all the instructions, and now i'm getting this from docker logs - openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
I have ollama set as well
@zono50 under the LLMs specification, can you try adding api_key: none ?
Probably under the Embeddings model specification as well
I did the proposed solutions and now i'm getting - tenacity.RetryError: RetryError[<Future at 0x7591081bc400 state=finished raised APIConnectionError>]
I have verified that ollama is working as i am able to pull model info using open-webui currently
@zono50 hmm looks like it couldn't connect to ollama, can you provide the full log ?
docker logs - Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 575, in process_events response = await route_utils.call_process_api( File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 276, in call_process_api output = await app.get_blocks().process_api( File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1923, in process_api result = await self.call_function( File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1520, in call_function prediction = await utils.async_iteration(iterator) File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 663, in async_iteration return await iterator.anext() File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 656, in anext return await anyio.to_thread.run_sync( File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread return await future File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 859, in run result = context.run(func, *args) File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 639, in run_sync_iterator_async return next(iterator) File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 801, in gen_wrapper response = next(iterator) File "/app/libs/ktem/ktem/pages/chat/init.py", line 804, in chat_fn for response in pipeline.stream(chat_input, conversation_id, chat_history): File "/app/libs/ktem/ktem/reasoning/simple.py", line 660, in stream docs, infos = self.retrieve(message, history) File "/app/libs/ktem/ktem/reasoning/simple.py", line 488, in retrieve retriever_docs = retriever_node(text=query) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1097, in call raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1088, in call output = self.fl.exec(func, args, kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/backends/base.py", line 151, in exec return run(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 144, in call raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 141, in call _output = self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 117, in call return self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1017, in _runx return self.run(*args, **kwargs) File "/app/libs/ktem/ktem/index/file/pipelines.py", line 162, in run docs = self.vector_retrieval(text=text, top_k=self.top_k, **retrieval_kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1261, in exec return child(*args, **kwargs, fl_runstates=fl_runstates) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1097, in call raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1088, in call output = self.fl.exec(func, args, kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/backends/base.py", line 151, in exec return run(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 144, in call raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 141, in call _output = self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 117, in call return self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1017, in _runx return self.run(*args, **kwargs) File "/app/libs/kotaemon/kotaemon/indices/vectorindex.py", line 188, in run emb = self.embedding(text)[0].embedding File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1261, in exec return child(*args, **kwargs, fl_runstates=fl_runstates) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1675, in call return self._create_callable(getattr(self.ff_original_obj, "call"))( File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1663, in wrapper raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1661, in wrapper output = callable_obj(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 144, in call raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 141, in call _output = self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 117, in call return self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1261, in exec return child(*args, **kwargs, fl_runstates=fl_runstates) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1097, in call raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1088, in call output = self.fl.exec(func, args, kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/backends/base.py", line 151, in exec return run(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 144, in call raise e from None File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 141, in call _output = self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/middleware.py", line 117, in call return self.next_call(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/theflow/base.py", line 1017, in runx return self.run(*args, **kwargs) File "/app/libs/kotaemon/kotaemon/embeddings/base.py", line 10, in run return self.invoke(text, *args, **kwargs) File "/app/libs/kotaemon/kotaemon/embeddings/openai.py", line 104, in invoke resp = self.openai_response(client, input=input, **kwargs).dict() File "/usr/local/lib/python3.10/site-packages/tenacity/init.py", line 336, in wrapped_f return copy(f, *args, **kw) File "/usr/local/lib/python3.10/site-packages/tenacity/init.py", line 475, in call do = self.iter(retry_state=retry_state) File "/usr/local/lib/python3.10/site-packages/tenacity/init.py", line 376, in iter result = action(retry_state) File "/usr/local/lib/python3.10/site-packages/tenacity/init.py", line 419, in exc_check raise retry_exc from fut.exception() tenacity.RetryError: RetryError[<Future at 0x7591081bc400 state=finished raised APIConnectionError>]
Ollama logs - no logs showing for ollama since 30 minutes ago when i had some permissions issues i fixed up.
shouldd i be using host.docker.internal?
@zono50 the log indicates a problem connecting to the embedding endpoint, could you try making a request to that endpoint manually ? For reference please see the Usage section at https://ollama.com/blog/embedding-models
Still have the same error. See my settings.
When i run the traceback through Chatgpt, it gives me this - The error traceback you've provided suggests that there is an issue with making a connection to an API, specifically related to the openai_response method in the kotaemon/embeddings/openai.py file. The traceback culminates in a RetryError, which indicates that the code attempted to connect to the API multiple times but eventually gave up after exhausting the retry attempts. Is it still trying to connect to OpenAI?
@sostoli you mean still the AuthenticationError right ? Just to be sure, can you provide the log again ?
@sostoli @zono50 I think the problem might be: when the File Index is created, it can only be configured once (meaning you cannot change the embedding model once the Index has been created). So maybe it was configured with openai embedding by default and then that setting is fixed. One way to hot-fix this would be to create a new File Index and use that one instead. Can you guys try that out ?
Sure thing, and thanks for the great assistance! I did create a new file index, but how do i make my files use it?
@zono50 it should appear as a new tab under Files, can you see it there ?
@sostoli you mean still the AuthenticationError right ? Just to be sure, can you provide the log again ?
@sostoli @zono50 I think the problem might be: when the File Index is created, it can only be configured once (meaning you cannot change the embedding model once the Index has been created). So maybe it was configured with openai embedding by default and then that setting is fixed. One way to hot-fix this would be to create a new File Index and use that one instead. Can you guys try that out ?
Sorry for not posting the logs. I now have API key error while i am using ollama (check previous screenshots).
Here is the logs:
The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
@sostoli You probably having the same issue as @zono50. Could you try out the suggestion that I mentioned here ?
@sostoli you mean still the AuthenticationError right ? Just to be sure, can you provide the log again ?
@sostoli @zono50 I think the problem might be: when the File Index is created, it can only be configured once (meaning you cannot change the embedding model once the Index has been created). So maybe it was configured with openai embedding by default and then that setting is fixed. One way to hot-fix this would be to create a new File Index and use that one instead. Can you guys try that out ?
If i go to resource and index collection, it is there, but if i go to files, i don't see it there.
the new one i created is called file main -
@zono50 ah yes the new index has been created, you will need to upload your file again to the new one. You can see the Index kinda like a file database, so when you create a new one you would need to upload your files again.
Cool! where on this screen do i set the file index?
@zono50 this one
Notice that you now have 3 indices (databases), 2 file indices and 1 graph indices. Just choose from each one the file(s) you want to use with RAG.
gotcha, so i understand that part now. I have the 3 databases listed there i can query from. So i go to upload file, but when i go to files, it doesn't show under files_Main Collection, actually it.
Here's what i've done: I've deleted the file, went to file_main collection, uploaded the pdf, then went to homescreen, put in search through the pdf, and got the same error - tenacity.RetryError: RetryError[<Future at 0x7d48935fa500 state=finished raised APIConnectionError>]
@zono50 hmm I'm out of idea for now, maybe try a restart ?
@taprosoft any suggestion on this one ?
Any guidance on how to properly set this up?
@zono50 just copying the configs of the existing one is fine, you just have to make sure to set the embedding to the one you want to use in the specification.
@zono50 and don't forget to restart the app after creating a new index as noted in the UI.
@lone17 base on you guys conversation ,i think how about i just only switch the config file about OpenAI setting just for my local model or embeding?that can don't have to change anything ?
@Lbaiall Not sure I understand what you mean, could you please elaborate ?