From 5577ae8a3915ddba8ee83ff1b41bbfa7f9385a18 Mon Sep 17 00:00:00 2001 From: Orestes Garcia Date: Thu, 4 Sep 2025 14:43:09 -0400 Subject: [PATCH 01/18] feat: Add comprehensive OpenAI base URL configuration support This commit implements comprehensive support for custom OpenAI base URL configuration throughout the entire Archon system, enabling users to route OpenAI API calls through proxies like LiteLLM, Azure OpenAI, or other OpenAI-compatible endpoints. ## Key Changes: ### Backend Services - Enhanced credential_service.py to support OPENAI_BASE_URL setting - Updated llm_provider_service.py to use custom base_url for AsyncOpenAI clients - Modified code_storage_service.py to support base_url for sync OpenAI clients ### PydanticAI Agent Integration - Created new agent_provider_config.py for centralized provider configuration - Updated base_agent.py to support async initialization with custom providers - Modified rag_agent.py and document_agent.py to use configured providers - Updated agent server.py to handle async provider initialization ### Frontend UI - Enhanced RAGSettings.tsx with conditional OpenAI base URL input field - Added OPENAI_BASE_URL to TypeScript interface - Field appears only when OpenAI is selected as provider ## Features: - Optional configuration (backwards compatible) - Consistent behavior across all OpenAI usage points - Secure encrypted storage in database - Comprehensive error handling and fallbacks - Support for LiteLLM, Azure OpenAI, and other compatible endpoints ## Testing: - All Python files compile without syntax errors - Linting issues addressed - No breaking changes to existing functionality Resolves: https://github.com/coleam00/Archon/issues/584 --- .../src/components/settings/RAGSettings.tsx | 15 ++ python/src/agents/agent_provider_config.py | 131 ++++++++++++++++++ python/src/agents/base_agent.py | 39 +++++- python/src/agents/document_agent.py | 7 +- python/src/agents/rag_agent.py | 7 +- python/src/agents/server.py | 3 +- .../src/server/services/credential_service.py | 3 + .../server/services/llm_provider_service.py | 11 +- .../services/storage/code_storage_service.py | 30 ++-- 9 files changed, 224 insertions(+), 22 deletions(-) create mode 100644 python/src/agents/agent_provider_config.py diff --git a/archon-ui-main/src/components/settings/RAGSettings.tsx b/archon-ui-main/src/components/settings/RAGSettings.tsx index 3dfcd220f9..ee4540a3f3 100644 --- a/archon-ui-main/src/components/settings/RAGSettings.tsx +++ b/archon-ui-main/src/components/settings/RAGSettings.tsx @@ -17,6 +17,7 @@ interface RAGSettingsProps { USE_RERANKING: boolean; LLM_PROVIDER?: string; LLM_BASE_URL?: string; + OPENAI_BASE_URL?: string; EMBEDDING_MODEL?: string; // Crawling Performance Settings CRAWL_BATCH_SIZE?: number; @@ -85,6 +86,20 @@ export const RAGSettings = ({ /> )} + {ragSettings.LLM_PROVIDER === 'openai' && ( +
+ setRagSettings({ + ...ragSettings, + OPENAI_BASE_URL: e.target.value + })} + placeholder="https://api.openai.com/v1" + accentColor="green" + /> +
+ )}