Fix issues
This commit is contained in:
+51
-1
@@ -11,6 +11,7 @@ from typing import List, Optional
|
||||
from ai_service.models.model_service import model_service
|
||||
from ai_service.models.chat_service import chat_service
|
||||
from ai_service.openwebui_api import router as openwebui_router
|
||||
from ai_service.config import config
|
||||
|
||||
# Create FastAPI app
|
||||
app = FastAPI(
|
||||
@@ -107,6 +108,52 @@ async def health_check():
|
||||
"""
|
||||
return {"status": "healthy"}
|
||||
|
||||
@app.get("/test-ollama")
|
||||
async def test_ollama_connection():
|
||||
"""
|
||||
Test the connection to the Ollama API.
|
||||
|
||||
Returns:
|
||||
Connection status and available models from Ollama.
|
||||
"""
|
||||
import requests
|
||||
|
||||
try:
|
||||
# Try to connect to Ollama API
|
||||
response = requests.get(f"{config.OLLAMA_API_URL}/api/tags", timeout=5)
|
||||
response.raise_for_status()
|
||||
|
||||
# Return the models from Ollama
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "Successfully connected to Ollama API",
|
||||
"ollama_url": config.OLLAMA_API_URL,
|
||||
"models": response.json()
|
||||
}
|
||||
except Exception as e:
|
||||
return {
|
||||
"status": "error",
|
||||
"message": f"Failed to connect to Ollama API: {str(e)}",
|
||||
"ollama_url": config.OLLAMA_API_URL
|
||||
}
|
||||
|
||||
@app.get("/config")
|
||||
async def get_config():
|
||||
"""
|
||||
Get the current configuration.
|
||||
|
||||
Returns:
|
||||
Current configuration settings.
|
||||
"""
|
||||
return {
|
||||
"api_host": config.API_HOST,
|
||||
"api_port": config.API_PORT,
|
||||
"openwebui_url": config.OPENWEBUI_URL,
|
||||
"ollama_api_url": config.OLLAMA_API_URL,
|
||||
"default_model": config.DEFAULT_MODEL,
|
||||
"available_models": list(model_service.AVAILABLE_MODELS.keys())
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Model endpoints
|
||||
@@ -118,7 +165,10 @@ async def get_available_models():
|
||||
Returns:
|
||||
List of model information.
|
||||
"""
|
||||
return model_service.get_available_models()
|
||||
models = model_service.get_available_models()
|
||||
# Debug log
|
||||
print(f"API models: {models}")
|
||||
return models
|
||||
|
||||
@app.get("/models/{model_id}", response_model=ModelInfo)
|
||||
async def get_model_info(model_id: str):
|
||||
|
||||
Reference in New Issue
Block a user