AI: when it comes to morph api key:

- default we use morph api, with morph endpoint.
- If morph api key is not set, fall back to open router
This commit is contained in:
LE Quoc Dat 2025-07-24 12:58:55 +02:00
parent fadbf63a2f
commit 430c11ae8b
1 changed files with 11 additions and 3 deletions

View File

@ -373,9 +373,17 @@ class SandboxFilesTool(SandboxToolsBase):
morph_api_key = getattr(config, 'MORPH_API_KEY', None) or os.getenv('MORPH_API_KEY')
openrouter_key = getattr(config, 'OPENROUTER_API_KEY', None) or os.getenv('OPENROUTER_API_KEY')
# Use OpenRouter/Morph for users, direct Morph API for internal use
api_key = openrouter_key if openrouter_key else morph_api_key
base_url = "https://openrouter.ai/api/v1" if openrouter_key else "https://api.morph.so/v1"
api_key = None
base_url = None
if morph_api_key:
api_key = morph_api_key
base_url = "https://api.morph.so/v1"
logger.debug("Using Morph API for file editing.")
elif openrouter_key:
api_key = openrouter_key
base_url = "https://openrouter.ai/api/v1"
logger.debug("Morph API key not set, falling back to OpenRouter for file editing.")
if not api_key:
logger.warning("No Morph or OpenRouter API key found, falling back to traditional editing")