Skip to content

Commit

Permalink
take ollama server url from env
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed Sep 18, 2024
1 parent 693c49f commit a62b2c7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
12 changes: 1 addition & 11 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,6 @@
}
],
"results": {
"alphastats/gui/utils/ollama_utils.py": [
{
"type": "Secret Keyword",
"filename": "alphastats/gui/utils/ollama_utils.py",
"hashed_secret": "8ed4322e8e2790b8c928d381ce8d07cfd966e909",
"is_verified": false,
"line_number": 69,
"is_secret": false
}
],
"docs/workflow_mq.html": [
{
"type": "Base64 High Entropy String",
Expand All @@ -160,5 +150,5 @@
}
]
},
"generated_at": "2024-09-18T07:09:01Z"
"generated_at": "2024-09-18T09:54:14Z"
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ alphastats gui
```
If you get an `AxiosError: Request failed with status code 403'` when uploading files, try running `DISABLE_XSRF=1 alphastats gui`.

If you want to use local Large Language Models to help interpret the data, you would need to download and install ollama (https://ollama.com/download).
If you want to use local Large Language Models to help interpret the data,
you need to download and install ollama (https://ollama.com/download). The url of the server can be set by the
environmental variable `OLLAMA_BASE_URL` (defaults to `http://localhost:11434`)

AlphaStats can be imported as a Python package into any Python script or notebook with the command `import alphastats`.
A brief [Jupyter notebook tutorial](nbs/getting_started.ipynb) on how to use the API is also present in the [nbs folder](nbs).
Expand Down
4 changes: 2 additions & 2 deletions alphastats/gui/pages/05_LLM.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def select_analysis():
["gpt4o", "llama3.1 70b"],
index=0 if st.session_state["api_type"] == "gpt4o" else 1,
)
base_url = "http://localhost:11434/v1"

api_key = None
if st.session_state["api_type"] == "gpt4o":
api_key = st.text_input("Enter OpenAI API Key", type="password")
Expand Down Expand Up @@ -298,7 +298,7 @@ def select_analysis():
else:
st.session_state["llm_integration"] = LLMIntegration(
api_type="ollama",
base_url=base_url,
base_url=os.getenv("OLLAMA_BASE_URL", None),
dataset=st.session_state["dataset"],
metadata=st.session_state["dataset"].metadata,
)
Expand Down
5 changes: 2 additions & 3 deletions alphastats/gui/utils/ollama_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ def __init__(
):
self.api_type = api_type
if api_type == "ollama":
self.client = OpenAI(
base_url=base_url or "http://localhost:11434/v1", api_key="ollama"
)
url = f"{base_url or 'http://localhost:11434'}/v1"
self.client = OpenAI(base_url=url, api_key="ollama")
self.model = "llama3.1:70b"
else:
self.client = OpenAI(api_key=api_key)
Expand Down

0 comments on commit a62b2c7

Please sign in to comment.