Skip to content

Devika is the first open-source implementation of an Agentic Software Engineer. Initially started as an open-source alternative to Devin.

Python

Fix: gemini and setting route

[email protected]21dae2b535b9
diff --git a/src/llm/gemini_client.py b/src/llm/gemini_client.py
index ffbed92..dd2b220 100644
--- a/src/llm/gemini_client.py
+++ b/src/llm/gemini_client.py
@@ -1,4 +1,5 @@
import google.generativeai as genai
+from google.generativeai.types import HarmCategory, HarmBlockThreshold
from src.config import Config
@@ -10,5 +11,22 @@ class Gemini:
def inference(self, model_id: str, prompt: str) -> str:
model = genai.GenerativeModel(model_id)
- response = model.generate_content(prompt)
- return response.text
+ # Set safety settings for the request
+ safety_settings = {
+ HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
+ HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
+ # You can adjust other categories as needed
+ }
+ response = model.generate_content(prompt, safety_settings=safety_settings)
+ try:
+ # Check if the response contains text
+ return response.text
+ except ValueError:
+ # If the response doesn't contain text, check if the prompt was blocked
+ print("Prompt feedback:", response.prompt_feedback)
+ # Also check the finish reason to see if the response was blocked
+ print("Finish reason:", response.candidates[0].finish_reason)
+ # If the finish reason was SAFETY, the safety ratings have more details
+ print("Safety ratings:", response.candidates[0].safety_ratings)
+ # Handle the error or return an appropriate message
+ return "Error: Unable to generate content Gemini API"
diff --git a/ui/src/lib/components/Sidebar.svelte b/ui/src/lib/components/Sidebar.svelte
index 10c29af..34d4324 100644
--- a/ui/src/lib/components/Sidebar.svelte
+++ b/ui/src/lib/components/Sidebar.svelte
@@ -28,7 +28,7 @@
{#each navItems as { icon, tooltip, route }, i}
<SidebarButton
icon={icon}
- href={route}
+ href={$page.url.pathname + route}
{tooltip}
isSelected={$page.url.pathname == route}
/>