Abraham E. Tavarez commited on
Commit ·
342da0c
1
Parent(s): 8d6bd5c
code agent created and added to app
Browse files
agent.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
from smolagents import HfApiModel, CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool
|
| 3 |
from huggingface_hub import login
|
| 4 |
from dotenv import load_dotenv
|
|
|
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
login(os.environ["HF_API_KEY"])
|
|
@@ -11,6 +12,8 @@ tools = [
|
|
| 11 |
DuckDuckGoSearchTool(),
|
| 12 |
]
|
| 13 |
|
|
|
|
|
|
|
| 14 |
# LLM Model
|
| 15 |
model = HfApiModel(
|
| 16 |
"Qwen/Qwen2.5-72B-Instruct",
|
|
@@ -31,6 +34,9 @@ codeAgent = CodeAgent(
|
|
| 31 |
|
| 32 |
codeAgent.logger.console.width=66
|
| 33 |
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# Tool Calling Agent
|
| 36 |
llm = HfApiModel(
|
|
@@ -46,9 +52,5 @@ toolCallingAgent = ToolCallingAgent(
|
|
| 46 |
|
| 47 |
toolCallingAgent.logger.console.width=66
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
"""
|
| 52 |
-
|
| 53 |
-
res = toolCallingAgent.run(question)
|
| 54 |
-
print(res)
|
|
|
|
| 2 |
from smolagents import HfApiModel, CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool
|
| 3 |
from huggingface_hub import login
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
+
from sample_questions import QUESTIONS
|
| 6 |
|
| 7 |
load_dotenv()
|
| 8 |
login(os.environ["HF_API_KEY"])
|
|
|
|
| 12 |
DuckDuckGoSearchTool(),
|
| 13 |
]
|
| 14 |
|
| 15 |
+
question = QUESTIONS[0];
|
| 16 |
+
|
| 17 |
# LLM Model
|
| 18 |
model = HfApiModel(
|
| 19 |
"Qwen/Qwen2.5-72B-Instruct",
|
|
|
|
| 34 |
|
| 35 |
codeAgent.logger.console.width=66
|
| 36 |
|
| 37 |
+
res = codeAgent.run(question)
|
| 38 |
+
print(res)
|
| 39 |
+
|
| 40 |
|
| 41 |
# Tool Calling Agent
|
| 42 |
llm = HfApiModel(
|
|
|
|
| 52 |
|
| 53 |
toolCallingAgent.logger.console.width=66
|
| 54 |
|
| 55 |
+
# res = toolCallingAgent.run(question)
|
| 56 |
+
# print(res)
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
|
@@ -14,10 +15,11 @@ class BasicAgent:
|
|
| 14 |
def __init__(self):
|
| 15 |
print("BasicAgent initialized.")
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from agent import codeAgent
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
|
|
|
| 15 |
def __init__(self):
|
| 16 |
print("BasicAgent initialized.")
|
| 17 |
def __call__(self, question: str) -> str:
|
| 18 |
+
return codeAgent.run(question)
|
| 19 |
+
# print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 20 |
+
# fixed_answer = "This is a default answer."
|
| 21 |
+
# print(f"Agent returning fixed answer: {fixed_answer}")
|
| 22 |
+
# return fixed_answer
|
| 23 |
|
| 24 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 25 |
"""
|