Update app.py
Browse filesUpdated basic agent definition
app.py
CHANGED
|
@@ -17,27 +17,21 @@ GEMINI_API_KEY = os.getenv("Gemini_API_key")
|
|
| 17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 18 |
|
| 19 |
class BasicAgent:
|
| 20 |
-
llm_model = LiteLLMModel(
|
| 21 |
-
model_id="gemini/gemini-2.0-flash", # you can see other model names here: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models. It is important to prefix the name with "gemini/"
|
| 22 |
-
api_key=GEMINI_API_KEY,
|
| 23 |
-
max_tokens=8192
|
| 24 |
-
)
|
| 25 |
-
@tool
|
| 26 |
-
google_search_tool = Tool(
|
| 27 |
-
google_search = GoogleSearch()
|
| 28 |
-
)
|
| 29 |
-
agent = CodeAgent(
|
| 30 |
-
model = llm_model,
|
| 31 |
-
tools = [google_search_tool]
|
| 32 |
-
)
|
| 33 |
def __init__(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
print("BasicAgent initialized.")
|
| 35 |
def __call__(self, question: str) -> str:
|
| 36 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 37 |
fixed_answer = "This is a default answer."
|
| 38 |
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 39 |
# return fixed_answer
|
| 40 |
-
return agent.run(question)
|
| 41 |
|
| 42 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 43 |
"""
|
|
|
|
| 17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 18 |
|
| 19 |
class BasicAgent:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def __init__(self):
|
| 21 |
+
self.llm_model = LiteLLMModel(
|
| 22 |
+
model_id="gemini/gemini-2.0-flash", # you can see other model names here: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models. It is important to prefix the name with "gemini/"
|
| 23 |
+
api_key=GEMINI_API_KEY,
|
| 24 |
+
max_tokens=8192
|
| 25 |
+
)
|
| 26 |
+
self.google_search_tool = Tool(google_search = GoogleSearch())
|
| 27 |
+
self.agent = CodeAgent(model = self.llm_model, tools = [self.google_search_tool])
|
| 28 |
print("BasicAgent initialized.")
|
| 29 |
def __call__(self, question: str) -> str:
|
| 30 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 31 |
fixed_answer = "This is a default answer."
|
| 32 |
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 33 |
# return fixed_answer
|
| 34 |
+
return self.agent.run(question)
|
| 35 |
|
| 36 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 37 |
"""
|