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": [
|
||||
|
||||
Reference in New Issue
Block a user