mud_server.admin_gradio.tabs.ollama_tab
Ollama Tab for MUD Client.
This module provides the Ollama management interface for controlling AI models. Visible only for admin and superuser roles.
- Migration Notes:
Migrated from old api_client.py to new modular structure
Uses OllamaAPIClient for Ollama command execution and context management
Wrapper functions extract session_id and role from session_state
Returns message string for Gradio display
Parameter order changed: session_id and role now come first
Functions
|
Execute an Ollama command on the specified server (Admin/Superuser only). |
|
Clear Ollama conversation context for the current session (Admin/Superuser only). |
|
Create the Ollama tab with model management interface. |
Module Contents
- mud_server.admin_gradio.tabs.ollama_tab.execute_ollama_command(server_url, command, session_state)[source]
Execute an Ollama command on the specified server (Admin/Superuser only).
Sends request to backend via OllamaAPIClient and returns command output.
This function wraps the new OllamaAPIClient.execute_command() method to maintain compatibility with the Gradio interface while using the new modular API.
Note: Parameter order is maintained from old API (server_url, command, session_state) for compatibility with existing Gradio event handlers.
- Parameters:
- Returns:
Command output string or error message
- Return type:
Examples
>>> session = {"session_id": "admin123", "role": "admin", "logged_in": True} >>> result = execute_ollama_command("http://localhost:11434", "list", session) >>> isinstance(result, str) True
- mud_server.admin_gradio.tabs.ollama_tab.clear_ollama_context(session_state)[source]
Clear Ollama conversation context for the current session (Admin/Superuser only).
Sends request to backend via OllamaAPIClient and returns confirmation message.
This function wraps the new OllamaAPIClient.clear_context() method to maintain compatibility with the Gradio interface while using the new modular API.
- Parameters:
session_state (dict) – User’s session state dictionary containing session_id and role
- Returns:
Confirmation message string or error message
- Return type:
Examples
>>> session = {"session_id": "admin123", "role": "admin", "logged_in": True} >>> result = clear_ollama_context(session) >>> isinstance(result, str) True