Spaces:
Sleeping
Sleeping
add gemini llm and api key
Browse files
app.py
CHANGED
|
@@ -4,6 +4,10 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
from tools import ReverseTextTool, RunPythonFileTool, download_server
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
|
@@ -35,6 +39,13 @@ Tool Use Guidelines:
|
|
| 35 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 36 |
class BasicAgent:
|
| 37 |
def __init__(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
print("BasicAgent initialized.")
|
| 39 |
def __call__(self, question: str) -> str:
|
| 40 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
from tools import ReverseTextTool, RunPythonFileTool, download_server
|
| 7 |
+
from llama_index.llms.gemini import Gemini
|
| 8 |
+
import os
|
| 9 |
+
from dotenv import load_dotenv
|
| 10 |
+
|
| 11 |
|
| 12 |
|
| 13 |
# (Keep Constants as is)
|
|
|
|
| 39 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 40 |
class BasicAgent:
|
| 41 |
def __init__(self):
|
| 42 |
+
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 43 |
+
if not gemini_api_key:
|
| 44 |
+
raise ValueError("GEMINI_API_KEY not set in environment variables.")
|
| 45 |
+
llm = Gemini(
|
| 46 |
+
model="models/gemini-2.0-flash",
|
| 47 |
+
api_key=gemini_api_key,
|
| 48 |
+
)
|
| 49 |
print("BasicAgent initialized.")
|
| 50 |
def __call__(self, question: str) -> str:
|
| 51 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|