~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Use OpenAI package for endpoint model listing
LearningCircuita45da1eaf363
diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.pyindex 1ccb0928c2..d083e07d69 100644--- a/src/local_deep_research/web/routes/settings_routes.py+++ b/src/local_deep_research/web/routes/settings_routes.py@@ -793,37 +793,81 @@ def api_get_available_models():},]- # Try to get Custom OpenAI Endpoint models+ # Try to get Custom OpenAI Endpoint models using the OpenAI packageopenai_endpoint_models = []try:- logger.info("Attempting to connect to Custom OpenAI Endpoint")+ logger.info(+ "Attempting to connect to Custom OpenAI Endpoint using OpenAI package"+ )# Get the endpoint URL and API key from settingsendpoint_url = get_db_setting("llm.openai_endpoint.url", "")api_key = get_db_setting("llm.openai_endpoint.api_key", "")if endpoint_url and api_key:- # Ensure the URL ends with a slash- if not endpoint_url.endswith("/"):- endpoint_url += "/"-- # Make the request to the endpoint's models API- headers = {"Authorization": f"Bearer {api_key}"}- endpoint_response = requests.get(- f"{endpoint_url}models", headers=headers, timeout=5- )+ # Import OpenAI package here to avoid dependency issues if not installed+ import openai+ from openai import OpenAI++ # Create OpenAI client with custom endpoint+ client = OpenAI(api_key=api_key, base_url=endpoint_url)++ try:+ # Fetch models using the client+ logger.debug("Fetching models from OpenAI API")+ models_response = client.models.list()++ # Process models from the response+ for model in models_response.data:+ model_id = model.id+ if model_id:+ # Create a clean display name+ display_name = model_id.replace("-", " ").strip()+ display_name = " ".join(+ word.capitalize() for word in display_name.split()+ )- logger.debug(- f"OpenAI Endpoint API response: Status {endpoint_response.status_code}"- )+ openai_endpoint_models.append(+ {+ "value": model_id,+ "label": f"{display_name} (Custom)",+ "provider": "OPENAI_ENDPOINT",+ }+ )+ logger.debug(+ f"Added Custom OpenAI Endpoint model: {model_id} -> {display_name}"+ )- if endpoint_response.status_code == 200:- try:- endpoint_data = endpoint_response.json()- logger.debug(- f"OpenAI Endpoint API data: {json.dumps(endpoint_data)[:500]}..."- )+ # Sort models alphabetically+ openai_endpoint_models.sort(key=lambda x: x["label"])++ except openai.APIError as api_err:+ logger.error(f"OpenAI API error: {str(api_err)}")+ raise Exception(f"OpenAI API error: {str(api_err)}")++ else:+ logger.info("OpenAI Endpoint URL or API key not configured")+ # Don't raise an exception, just continue with empty models list++ except ImportError:+ logger.warning(+ "OpenAI package not installed. Using manual API request fallback."+ )+ # Fallback to manual API request if OpenAI package is not installed+ try:+ if endpoint_url and api_key:+ # Ensure the URL ends with a slash+ if not endpoint_url.endswith("/"):+ endpoint_url += "/"++ # Make the request to the endpoint's models API+ headers = {"Authorization": f"Bearer {api_key}"}+ endpoint_response = requests.get(+ f"{endpoint_url}models", headers=headers, timeout=5+ )+ if endpoint_response.status_code == 200:+ endpoint_data = endpoint_response.json()# Process models from the responseif "data" in endpoint_data:for model in endpoint_data.get("data", []):@@ -843,37 +887,8 @@ def api_get_available_models():"provider": "OPENAI_ENDPOINT",})- logger.debug(- f"Added Custom OpenAI Endpoint model: {model_id} -> {display_name}"- )-- # Sort models alphabetically- openai_endpoint_models.sort(key=lambda x: x["label"])- else:- logger.warning(- "No 'data' field in OpenAI Endpoint API response"- )- raise Exception(- "Invalid API response format from OpenAI Endpoint"- )-- except json.JSONDecodeError as json_err:- logger.error(- f"Failed to parse OpenAI Endpoint API response as JSON: {json_err}"- )- raise Exception(- f"OpenAI Endpoint API returned invalid JSON: {json_err}"- )- else:- logger.warning(- f"OpenAI Endpoint API returned non-200 status code: {endpoint_response.status_code}"- )- raise Exception(- f"OpenAI Endpoint API returned status code {endpoint_response.status_code}"- )- else:- logger.info("OpenAI Endpoint URL or API key not configured")- # Don't raise an exception, just continue with empty models list+ except Exception as e:+ logger.error(f"Fallback API request failed: {str(e)}")except Exception as e:logger.error(f"Error getting OpenAI Endpoint models: {str(e)}")