fix: add LITELLM_API_KEY support for authenticated LiteLLM calls
This commit is contained in:
@@ -18,6 +18,7 @@ class BaseAgent:
|
||||
self.system_prompt = system_prompt
|
||||
self.config = config
|
||||
self.litellm_url = os.getenv("LITELLM_URL", "http://litellm:4005")
|
||||
self.litellm_api_key = os.getenv("LITELLM_API_KEY", "")
|
||||
|
||||
async def execute(self, task: Dict[str, Any], context: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
@@ -79,9 +80,14 @@ Only propose actions you can actually execute. Be specific and actionable."""
|
||||
temperature = self.config.get("temperature", 0.7)
|
||||
|
||||
try:
|
||||
headers = {}
|
||||
if self.litellm_api_key:
|
||||
headers["Authorization"] = f"Bearer {self.litellm_api_key}"
|
||||
|
||||
async with httpx.AsyncClient(timeout=60.0) as client:
|
||||
response = await client.post(
|
||||
f"{self.litellm_url}/chat/completions",
|
||||
headers=headers,
|
||||
json={
|
||||
"model": model,
|
||||
"messages": [
|
||||
|
||||
@@ -28,6 +28,7 @@ services:
|
||||
- WEBAUTHN_RP_ID=jimmygan.com
|
||||
- WEBAUTHN_ORIGINS=https://dev.nas.jimmygan.com,https://dev.nas.jimmygan.com:8443,https://auth.jimmygan.com:8443
|
||||
- LITELLM_URL=http://litellm:4005
|
||||
- LITELLM_API_KEY=${LITELLM_API_KEY:-}
|
||||
- LITELLM_HEALTH_API_KEY=${LITELLM_HEALTH_API_KEY:-}
|
||||
- GITEA_DB_PASSWORD=${GITEA_DB_PASSWORD}
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user