Update agent/gemini_agent.py
Browse files- agent/gemini_agent.py +6 -16
agent/gemini_agent.py
CHANGED
|
@@ -1,20 +1,10 @@
|
|
| 1 |
-
import os
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
return os.getenv("GEMINI_API_KEY")
|
| 6 |
|
| 7 |
-
def
|
| 8 |
-
api_key = get_gemini_api_key()
|
| 9 |
-
if not api_key:
|
| 10 |
-
return "Error: Gemini API key not set. Please add it to your environment variables."
|
| 11 |
-
genai.configure(api_key=api_key)
|
| 12 |
model = genai.GenerativeModel("gemini-pro")
|
| 13 |
chat = model.start_chat()
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
try:
|
| 17 |
-
response = chat.send_message(prompt)
|
| 18 |
-
return response.text
|
| 19 |
-
except Exception as e:
|
| 20 |
-
return f"Gemini Error: {e}"
|
|
|
|
| 1 |
+
import os, google.generativeai as genai
|
| 2 |
+
from config.settings import settings
|
| 3 |
|
| 4 |
+
genai.configure(api_key=settings.gemini_api_key)
|
|
|
|
| 5 |
|
| 6 |
+
def chat_with_gemini(user, prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
model = genai.GenerativeModel("gemini-pro")
|
| 8 |
chat = model.start_chat()
|
| 9 |
+
resp = chat.send_message(prompt)
|
| 10 |
+
return resp.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|