techwithtim / AI-Agent-Code-Generator

66 stars 35 forks source link

ModuleNotFoundError: No module named 'llama_index.llms.ollama' #1

Open justin107d opened 2 months ago

justin107d commented 2 months ago

This is not an error specific to this project but I have been unable to get the repos on llama_index to work on my computer. I have looked around on the llama_index issue forums and the only advice I have gotten was to reinstall or roll back and I still get similar errors. Does anyone else have similar issues?

Commands used:

python -m venv venv
venv/Scripts/activate
pip install -r requirements.txt
pip install llama_index==0.10.25

Error:

(venv) PS C:\Users\XXXXX\AI-Agent-Code-Generator> python main.py
Traceback (most recent call last):
  File "C:\Users\XXXXX\AI-Agent-Code-Generator\main.py", line 1, in <module>
    from llama_index.llms.ollama import Ollama
ModuleNotFoundError: No module named 'llama_index.llms.ollama'

If it helps, the cmake file failed when loading llama_cpp_python

shon-Rocky commented 2 months ago

Install this on your cmd

pip install llama-index-llms-ollama 

Then run this code. specify your model in model="". In my case I used "phi3" model.

from llama_index.llms.ollama import Ollama

llm = Ollama(model="phi3", request_timeout=30.0)

response = llm.complete("What is the capital of France?")
print(response)

for more clarification check this link

https://docs.llamaindex.ai/en/stable/api_reference/llms/ollama/