Skip to content

Commit

Permalink
Merge pull request #41 from fertkir/port-customization
Browse files Browse the repository at this point in the history
ollama port customization
  • Loading branch information
ruecat authored Apr 7, 2024
2 parents 4af6b36 + 12f92ce commit 279fac5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ The official image is available at dockerhub: [ruecat/ollama-telegram](https://h
| `USER_IDS` | Telegram user IDs of regular users.<br/>These only can chat with the bot. | Yes | | 1234567890<br/>**OR**<br/>1234567890,0987654321, etc. |
| `INITMODEL` | Default LLM | No | `llama2` | mistral:latest<br/>mistral:7b-instruct |
| `OLLAMA_BASE_URL` | Your OllamaAPI URL | No | | localhost<br/>host.docker.internal |
| `OLLAMA_PORT` | Your OllamaAPI port | No | 11434 | |


## Credits
Expand Down
5 changes: 3 additions & 2 deletions bot/func/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
allowed_ids = list(map(int, os.getenv("USER_IDS", "").split(",")))
admin_ids = list(map(int, os.getenv("ADMIN_IDS", "").split(",")))
ollama_base_url = os.getenv("OLLAMA_BASE_URL")
ollama_port = os.getenv("OLLAMA_PORT", "11434")
log_level_str = os.getenv("LOG_LEVEL", "INFO")

# --- Other
Expand All @@ -32,7 +33,7 @@
# Model List
async def model_list():
async with aiohttp.ClientSession() as session:
url = f"http://{ollama_base_url}:11434/api/tags"
url = f"http://{ollama_base_url}:{ollama_port}/api/tags"
async with session.get(url) as response:
if response.status == 200:
data = await response.json()
Expand All @@ -42,7 +43,7 @@ async def model_list():
async def generate(payload: dict, modelname: str, prompt: str):
# try:
async with aiohttp.ClientSession() as session:
url = f"http://{ollama_base_url}:11434/api/chat"
url = f"http://{ollama_base_url}:{ollama_port}/api/chat"

# Stream from API
async with session.post(url, json=payload) as response:
Expand Down

0 comments on commit 279fac5

Please sign in to comment.