-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from gnosis/gabriel/ollama-agent
Created Ollama Langchain agent
- Loading branch information
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from langchain_community.llms.ollama import Ollama | ||
|
||
from prediction_market_agent.agents.langchain_agent import LangChainAgent | ||
from prediction_market_agent.tools.ollama_utils import is_ollama_running | ||
|
||
|
||
class OllamaLangChainAgent(LangChainAgent): | ||
def __init__(self) -> None: | ||
# Make sure Ollama is running locally | ||
if not is_ollama_running(): | ||
raise EnvironmentError( | ||
"Ollama is not running, cannot instantiate Ollama agent" | ||
) | ||
llm = Ollama( | ||
model="mistral", base_url="http://localhost:11434" | ||
) # Mistral since it supports function calling | ||
super().__init__(llm=llm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import requests | ||
|
||
|
||
def is_ollama_running(base_url: str = "http://localhost:11434") -> bool: | ||
r = requests.get(f"{base_url}/api/tags") | ||
return r.status_code == 200 |