Improve Ollama request timeout settings

This commit is contained in:
Aleksandar Sredojevi
2026-06-05 11:49:33 -04:00
committed by Storm Dragon
parent 2650b5b876
commit 69891ae6fd
2 changed files with 26 additions and 5 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ I38 includes an integrated AI assistant accessible through ratpoison mode with t
The AI assistant stores its configuration in `~/.config/stormux/I38/ai.conf` using XDG directory standards. Settings include: The AI assistant stores its configuration in `~/.config/stormux/I38/ai.conf` using XDG directory standards. Settings include:
- AI provider selection (Claude Code or Ollama) - AI provider selection (Claude Code or Ollama)
- Ollama model selection and host configuration - Ollama model selection, host configuration, and request timeout
- Action confirmation preferences - Action confirmation preferences
- Voice input/output settings - Voice input/output settings
- Wake word customization - Wake word customization
+25 -4
View File
@@ -218,6 +218,7 @@ class AiConfig:
'ollama_model': 'llama2', 'ollama_model': 'llama2',
'ollama_vision_model': 'llava', 'ollama_vision_model': 'llava',
'ollama_host': 'http://localhost:11434', 'ollama_host': 'http://localhost:11434',
'ollama_timeout': '60',
'codex_model': 'gpt-5.1-codex', 'codex_model': 'gpt-5.1-codex',
'codex_profile': '', 'codex_profile': '',
'confirm_actions': 'true', 'confirm_actions': 'true',
@@ -249,8 +250,9 @@ class AiConfig:
class OllamaInterface: class OllamaInterface:
"""Interface for Ollama AI provider""" """Interface for Ollama AI provider"""
def __init__(self, host='http://localhost:11434'): def __init__(self, host='http://localhost:11434', timeout=60):
self.host = host self.host = host
self.timeout = max(1, int(timeout))
self.model_details_cache = {} self.model_details_cache = {}
def get_models(self): def get_models(self):
@@ -382,7 +384,7 @@ class OllamaInterface:
return f"Error reading image: {str(e)}" return f"Error reading image: {str(e)}"
response = requests.post(f'{self.host}/api/generate', response = requests.post(f'{self.host}/api/generate',
json=data, timeout=60) # Longer timeout for image processing json=data, timeout=self.timeout)
if response.status_code == 200: if response.status_code == 200:
return response.json().get('response', 'No response received') return response.json().get('response', 'No response received')
else: else:
@@ -600,7 +602,8 @@ class AiAssistant(Gtk.Window):
self.config = AiConfig() self.config = AiConfig()
self.claudeInterface = ClaudeCodeInterface() self.claudeInterface = ClaudeCodeInterface()
self.codexInterface = CodexCliInterface() self.codexInterface = CodexCliInterface()
self.ollamaInterface = OllamaInterface(self.config.get('ollama_host')) self.ollamaInterface = OllamaInterface(self.config.get('ollama_host'),
self.config.get('ollama_timeout'))
self.windowContext = WindowContext() self.windowContext = WindowContext()
self.launchWindowId = self.windowContext.get_focused_window_id() self.launchWindowId = self.windowContext.get_focused_window_id()
self.voiceRecognition = VoiceRecognition(self.config) self.voiceRecognition = VoiceRecognition(self.config)
@@ -973,6 +976,20 @@ class AiAssistant(Gtk.Window):
hostLabel.set_mnemonic_widget(self.hostEntry) hostLabel.set_mnemonic_widget(self.hostEntry)
ollamaBox.pack_start(self.hostEntry, False, False, 0) ollamaBox.pack_start(self.hostEntry, False, False, 0)
# Ollama request timeout
ollamaTimeoutLabel = Gtk.Label("Ollama _timeout (seconds):")
ollamaTimeoutLabel.set_use_underline(True)
ollamaTimeoutLabel.set_alignment(0, 0.5)
ollamaBox.pack_start(ollamaTimeoutLabel, False, False, 0)
self.ollamaTimeoutSpin = Gtk.SpinButton.new_with_range(1, 3600, 1)
self.ollamaTimeoutSpin.set_value(int(self.config.get('ollama_timeout', '60')))
self.ollamaTimeoutSpin.set_can_focus(True)
self.ollamaTimeoutSpin.get_accessible().set_name("Ollama request timeout")
self.ollamaTimeoutSpin.get_accessible().set_description("How long to wait for Ollama requests in seconds")
ollamaTimeoutLabel.set_mnemonic_widget(self.ollamaTimeoutSpin)
ollamaBox.pack_start(self.ollamaTimeoutSpin, False, False, 0)
self.ollamaFrame.add(ollamaBox) self.ollamaFrame.add(ollamaBox)
vbox.pack_start(self.ollamaFrame, False, False, 0) vbox.pack_start(self.ollamaFrame, False, False, 0)
@@ -1305,7 +1322,8 @@ class AiAssistant(Gtk.Window):
"""Handle refresh models button click""" """Handle refresh models button click"""
# Update host if changed # Update host if changed
new_host = self.hostEntry.get_text() new_host = self.hostEntry.get_text()
self.ollamaInterface = OllamaInterface(new_host) self.ollamaInterface = OllamaInterface(new_host,
int(self.ollamaTimeoutSpin.get_value()))
self.refresh_ollama_models() self.refresh_ollama_models()
def on_save_settings(self, widget): def on_save_settings(self, widget):
@@ -1318,8 +1336,11 @@ class AiAssistant(Gtk.Window):
self.config.set('provider', 'ollama') self.config.set('provider', 'ollama')
self.config.set('ollama_host', self.hostEntry.get_text()) self.config.set('ollama_host', self.hostEntry.get_text())
self.config.set('ollama_timeout', str(int(self.ollamaTimeoutSpin.get_value())))
self.config.set('codex_model', self.codexModelEntry.get_text().strip()) self.config.set('codex_model', self.codexModelEntry.get_text().strip())
self.config.set('codex_profile', self.codexProfileEntry.get_text().strip()) self.config.set('codex_profile', self.codexProfileEntry.get_text().strip())
self.ollamaInterface = OllamaInterface(self.config.get('ollama_host'),
self.config.get('ollama_timeout'))
# Save selected text model # Save selected text model
for radio in self.textModelRadios: for radio in self.textModelRadios: