Skip to content

Commit d64347d

Browse files
shine911shine
authored andcommitted
fix: ensure API key is set before making requests in LiteLLMAIHandler
- It make gemini model was failed when call api Refs: The-PR-Agent#2278
1 parent 0b0c175 commit d64347d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

pr_agent/algo/ai_handlers/litellm_ai_handler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ async def chat_completion(self, model: str, system: str, user: str, temperature:
406406
get_logger().info(f"\nSystem prompt:\n{system}")
407407
get_logger().info(f"\nUser prompt:\n{user}")
408408

409-
kwargs["api_key"] = litellm.api_key
409+
api_key = getattr(litellm, "api_key", None)
410+
if api_key:
411+
kwargs["api_key"] = api_key
410412

411413
# Get completion with automatic streaming detection
412414
resp, finish_reason, response_obj = await self._get_completion(**kwargs)

0 commit comments

Comments
 (0)