Hi @Max_Moura , Thanks for the sample code, But Still I am facing the same error.
The only change I made was the ollama mode. I’ll share what happened, after the first execution it prompted me to pip install ollama
raise ImportError("Ollama Embedder requires extra dependencies. Install with `pip install ollama`") from None
ImportError: Ollama Embedder requires extra dependencies. Install with `pip install ollama`
Then After Installed it and executed the main again I was stuck (Waited 5-10 mins) at the following:
D:\Sample\8.sample_code_provided\venv\Lib\site-packages\pydantic\_internal\_generate_schema.py:623: UserWarning: <built-in function callable> is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.
warn(
D:\Sample\8.sample_code_provided\venv\Lib\site-packages\ollama\_types.py:81: PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
if key in self.model_fields:
D:\Sample\8.sample_code_provided\venv\Lib\site-packages\embedchain\embedder\ollama.py:27: LangChainDeprecationWarning: The class `OllamaEmbeddings` was deprecated in LangChain 0.3.1 and will be removed in 1.0.0. An updated version of the class exists in the :class:`~langchain-ollama package and should be used instead. To use it run `pip install -U :class:`~langchain-ollama` and import as `from :class:`~langchain_ollama import OllamaEmbeddings``.
embeddings = OllamaEmbeddings(model=self.config.model, base_url=config.base_url)
Inserting batches in chromadb: 0%| | 0/3 [00:00<?, ?it/s]
So naturally I keyboard interrupted using clt+c and this is complete error code:
D:\Sample\8.sample_code_provided\venv\Lib\site-packages\pydantic\_internal\_generate_schema.py:623: UserWarning: <built-in function callable> is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.
warn(
D:\Sample\8.sample_code_provided\venv\Lib\site-packages\ollama\_types.py:81: PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
if key in self.model_fields:
D:\Sample\8.sample_code_provided\venv\Lib\site-packages\embedchain\embedder\ollama.py:27: LangChainDeprecationWarning: The class `OllamaEmbeddings` was deprecated in LangChain 0.3.1 and will be removed in 1.0.0. An updated version of the class exists in the :class:`~langchain-ollama package and should be used instead. To use it run `pip install -U :class:`~langchain-ollama` and import as `from :class:`~langchain_ollama import OllamaEmbeddings``.
embeddings = OllamaEmbeddings(model=self.config.model, base_url=config.base_url)
Inserting batches in chromadb: 0%| | 0/3 [02:18<?, ?it/s]
Traceback (most recent call last):
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Sample\8.sample_code_provided\main.py", line 16, in <module>
pdf_search_tool = PDFSearchTool(
^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\crewai_tools\tools\pdf_search_tool\pdf_search_tool.py", line 34, in __init__
self.add(pdf)
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\crewai_tools\tools\pdf_search_tool\pdf_search_tool.py", line 60, in add
super().add(*args, **kwargs)
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\crewai_tools\tools\rag\rag_tool.py", line 57, in add
self.adapter.add(*args, **kwargs)
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\crewai_tools\adapters\pdf_embedchain_adapter.py", line 32, in add
self.embedchain_app.add(*args, **kwargs)
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\embedchain\embedchain.py", line 192, in add
documents, metadatas, _ids, new_chunks = self._load_and_embed(
^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\embedchain\embedchain.py", line 416, in _load_and_embed
self.db.add(documents=batch_docs, metadatas=batch_meta, ids=batch_ids, **kwargs)
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\embedchain\vectordb\chroma.py", line 159, in add
self.collection.add(
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\chromadb\api\models\Collection.py", line 81, in add
add_request = self._validate_and_prepare_add_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\chromadb\api\models\CollectionCommon.py", line 90, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\chromadb\api\models\CollectionCommon.py", line 213, in _validate_and_prepare_add_request
add_embeddings = self._embed_record_set(record_set=add_records)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\chromadb\api\models\CollectionCommon.py", line 526, in _embed_record_set
return self._embed(input=record_set[field]) # type: ignore[literal-required]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\chromadb\api\models\CollectionCommon.py", line 539, in _embed
return self._embedding_function(input=input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\chromadb\api\types.py", line 466, in __call__
result = call(self, input)
^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\embedchain\embedder\base.py", line 20, in __call__
return self.embedding_fn(input)
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\langchain_community\embeddings\ollama.py", line 214, in embed_documents
embeddings = self._embed(instruction_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\langchain_community\embeddings\ollama.py", line 202, in _embed
return [self._process_emb_response(prompt) for prompt in iter_]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\langchain_community\embeddings\ollama.py", line 167, in _process_emb_response
res = requests.post(
^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\requests\api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\requests\adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\urllib3\connectionpool.py", line 493, in _make_request
conn.request(
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\urllib3\connection.py", line 445, in request
self.endheaders()
File "C:\Users\OpenMail \AppData\Roaming\uv\python\cpython-3.12.10-windows-x86_64-none\Lib\http\client.py", line 1333, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\OpenMail \AppData\Roaming\uv\python\cpython-3.12.10-windows-x86_64-none\Lib\http\client.py", line 1093, in _send_output
self.send(msg)
File "C:\Users\OpenMail \AppData\Roaming\uv\python\cpython-3.12.10-windows-x86_64-none\Lib\http\client.py", line 1037, in send
self.connect()
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\urllib3\connection.py", line 276, in connect
self.sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\urllib3\connection.py", line 198, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Sample\8.sample_code_provided\venv\Lib\site-packages\urllib3\util\connection.py", line 81, in create_connection
sock.close()
File "C:\Users\OpenMail \AppData\Roaming\uv\python\cpython-3.12.10-windows-x86_64-none\Lib\socket.py", line 501, in close
def close(self):
KeyboardInterrupt
^C
To run this code I created a new venv using uv and install the latest crewai and crewai[tools], and python 3.12.10