Skip to content

Commit 67cebe4

Browse files
authored
Added Ollama Model provider (strnad#23)
thanks 👍
1 parent 2c56e8d commit 67cebe4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: app/llms.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ def create_groq_llm(model, temperature):
3636
return ChatGroq(groq_api_key=api_key, model_name=model, temperature=temperature, max_tokens=4095)
3737
else:
3838
raise ValueError("Groq API key not set in .env file")
39-
39+
40+
def create_ollama_llm(model, temperature):
41+
host = os.getenv('OLLAMA_HOST')
42+
if host:
43+
return ChatOllama(base_url=host,model=model, temperature=temperature)
44+
else:
45+
raise ValueError("Ollama Host is not set in .env file")
46+
4047
# def create_googleai_llm(model, temperature):
4148
# api_key = os.getenv('GOOGLE_API_KEY')
4249
# if api_key:
@@ -77,6 +84,10 @@ def create_lmstudio_llm(model, temperature):
7784
# "models": ["mistralai/Mistral-7B-Instruct-v0.2", "mistralai/Codestral-22B-v0.1", "EleutherAI/gpt-neo-2.7B"],
7885
# "create_llm": create_huggingfacehub_llm
7986
# },
87+
"Ollama": {
88+
"models": ["codellama","llama3.1"],
89+
"create_llm": create_ollama_llm
90+
},
8091
"Anthropic": {
8192
"models": ["claude-3-5-sonnet-20240620"],
8293
"create_llm": create_anthropic_llm

Diff for: requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ langchain-community
55
langchain-openai
66
langchain-groq
77
langchain-anthropic
8+
langchain-ollama
89
streamlit
910
python-dotenv

0 commit comments

Comments
 (0)