Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement]: Integrate OLLAMA API Support in AI Handlers #836

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pr_agent/algo/ai_handlers/litellm_ai_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def __init__(self):
if get_settings().get("HUGGINGFACE.API_BASE", None) and 'huggingface' in get_settings().config.model:
litellm.api_base = get_settings().huggingface.api_base
self.api_base = get_settings().huggingface.api_base
if get_settings().get("OLLAMA.API_BASE", None) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling or a default value for OLLAMA.API_BASE to ensure robustness in cases where the configuration might be missing or incorrect. This could prevent runtime errors and improve the application's stability. [important]

litellm.api_base = get_settings().ollama.api_base
self.api_base = get_settings().ollama.api_base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure consistency in accessing settings for different APIs by using a similar pattern or method. This can improve code maintainability and readability. For instance, you might consider abstracting the settings access logic into a method if the pattern becomes more complex with additional APIs. [medium]

if get_settings().get("HUGGINGFACE.REPITITION_PENALTY", None):
self.repetition_penalty = float(get_settings().huggingface.repetition_penalty)
if get_settings().get("VERTEXAI.VERTEX_PROJECT", None):
Expand Down Expand Up @@ -150,4 +153,4 @@ async def chat_completion(self, model: str, system: str, user: str, temperature:
if get_settings().config.verbosity_level >= 2:
get_logger().info(f"\nAI response:\n{resp}")

return resp, finish_reason
return resp, finish_reason