← all conversations

Ollama Network Access Suggestion

2025-06-044 turns6,005 charsgpt-4o
ollamanetwork-configurationpython-script

Summary

The user wants to modify the Python script to allow setting a custom host URL for Ollama, enabling network access instead of being hardcoded to localhost.

Messages

Great stuff! Might want to modify ollama code to allow for client host url to be set so that people can use this over their network? --- what do they mean --- post: In this repo I built a simple python script which scrapes RSS feeds and generates a news broadcast mp3 narrated by a realistic voice, using Ollama, so local LLM, to generate the summaries and final composed broadcast. You can specify whichever news sources you want in the feeds.yaml file, as well as the number of articles, as well as change the tone of the broadcast through editing the summary and broadcast generating prompts in the simple one file script. All you need is Ollama installed and then pull whichever models you want or can run locally, I like mistral for this use case, and you can change out the models as well as the voice of the narrator, using edge tts, easily at the beginning of the script. There is so much more you can do with this concept and build upon it. I made a version the other day which had a full Vite/React frontend and FastAPI backend which displayed each of the news stories, summaries, links, sorting abilities as well as UI to change the sources and read or listen to the broadcast. But I like the simplicity of this. Simply run the script and listen to the latest news in a brief broadcast from a myriad of viewpoints using your own choice of tone through editing the prompts. This all originated on a post where someone said AI would lead to people being less informed and I argued that if you use AI correctly it would actually make you more informed. So I decided to write a script which takes whichever news sources I want, in this case objectivity is my goal, as well I can alter the prompts which edit together the broadcast so that I do not have all of the interjected bias inherent in almost all news broadcasts nowadays. So therefore I posit I can use AI to help people be more informed rather than less, through allowing an individual to construct their own news broadcasts free of the biases inherent with having a "human" editor of the news. Soulless, but that is how I like my objective news content. Upvote 4 Downvote 3 Go to comments --- so tell me what the first comment meant
The first comment — **"Great stuff! Might want to modify ollama code to allow for client host url to be set so that people can use this over their network?"** — is suggesting a feature improvement to the script or setup described in the original post. Here's a breakdown of what it means: --- ### 🔧 **"Modify Ollama code to allow for client host URL to be set..."** - **Ollama**, by default, runs locally on `http://localhost:11434`. That means it's only accessible from the machine it's running on. - The commenter is suggesting modifying the **code (or Ollama config if possible)** so that it can listen on a specific **host IP (e.g., `0.0.0.0`)**, not just `localhost`. - This would allow other **devices on the same local network** to access the Ollama API running on that host machine. --- ### 🌐 **"...so that people can use this over their network?"** - Right now, if someone else on your Wi-Fi or LAN tries to call your machine’s Ollama instance, they’ll be blocked unless the server is set to accept connections from other hosts. - Making it accessible over the network would allow, for example: - A React/Vite frontend running on a laptop to call an Ollama backend running on a Raspberry Pi. - Multiple users in a home or office to access a single local Ollama instance for generating summaries. --- ### 🛠️ How You'd Do That (contextually speaking): - If modifying Ollama directly: you’d want to change its **bind address** from `localhost` to something like `0.0.0.0`. - If it's a **Python script** using a wrapper or proxy to call Ollama, allow it to set the **host URL as a variable or config parameter**, so it’s not hardcoded to `localhost`. --- ### ✅ In Short: The commenter is asking the author to make it so the script (or Ollama server) isn't limited to just the machine it's running on — but could be used by other devices over the local network, making it a lightweight shared service.
gpt-4o
f it’s a Python script using a wrapper or proxy to call Ollama, allow it to set the host URL as a variable or config parameter, so it’s not hardcoded to localhost.
Exactly. If the Python script calls the Ollama API, it's probably making HTTP requests to something like: ```python requests.post("http://localhost:11434/api/generate", json=payload) ``` In this case, `"http://localhost:11434"` is **hardcoded**, meaning it only works locally on the same machine. To allow network access, you'd want to **parameterize** the Ollama host URL. Here's how to do that: --- ### ✅ **Step-by-step modification:** #### 1. **Add a configurable host URL:** At the top of the script, you can define a variable: ```python OLLAMA_HOST = os.getenv("OLLAMA_HOST", "http://localhost:11434") ``` This uses an environment variable (`OLLAMA_HOST`) if it's set, otherwise defaults to localhost. You'll also need to import `os`: ```python import os ``` --- #### 2. **Use this variable in requests:** Update all API calls like: ```python requests.post(f"{OLLAMA_HOST}/api/generate", json=payload) ``` --- ### 📡 **To run over the network:** 1. Start Ollama with network access (bind to `0.0.0.0`): ```bash OLLAMA_HOST=0.0.0.0 ollama serve ``` > ⚠️ Be aware: binding to `0.0.0.0` exposes Ollama to anyone on your local network. Make sure you're in a trusted network or use firewall rules. 2. On another machine, set the `OLLAMA_HOST` env variable to point to the IP of the Ollama server: ```bash export OLLAMA_HOST=http://192.168.1.42:11434 python run_news_script.py ``` --- ### 🧠 Summary: The commenter meant: instead of hardcoding `"localhost"` in the script, let users **change the Ollama host via an environment variable or config option** — so they can run the script **from other devices on their local network**, using a shared LLM instance.
gpt-4o