Spaces:
Build error
Build error
Commit ·
10ba265
1
Parent(s): f6fc677
+ merged with gradio for benchmarking
Browse filesFiles changed (3)
- agents.py+11-5
- app.py+5-4
- system_prompt.txtAdded+1
34 unmodified lines353637383940414 unmodified lines464748495051525354555636 unmodified lines9394959697989910010110210310434 unmodified linesload_dotenv("env.local")class AlfredAgent:def __init__(self):# Tool initializations using imported functionsself.tavily_tool = get_tavily_tool()4 unmodified linesself.search_tool = get_search_tool()self.calculator_tool = get_calculator_tool()self.hub_stats_tool = get_hub_stats_tool()# LLM and agent workflowself.llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")self.alfred = AgentWorkflow.from_tools_or_functions([*self.search_tool, *self.calculator_tool, self.wikipedia_tool, self.arxiv_tool, self.hub_stats_tool],llm=self.llm)LANGFUSE_AUTH=base64.b64encode(f"{os.getenv('LANGFUSE_PUBLIC_KEY')}:{os.getenv('LANGFUSE_SECRET_KEY')}".encode()).decode()36 unmodified linesdef main():agent = AlfredAgent()query = "who is the capital of France?"print(f"Running query: {query}")response = asyncio.run(agent.run_query(query))print("\n🎩 Agents's Response:")pprint(response)if __name__ == "__main__":main()34 unmodified lines353637383940414 unmodified lines464748495051525354555657585960616236 unmodified lines9910010110210310410510610710810911034 unmodified linesload_dotenv("env.local")class LlamaIndexAgent:def __init__(self):# Tool initializations using imported functionsself.tavily_tool = get_tavily_tool()4 unmodified linesself.search_tool = get_search_tool()self.calculator_tool = get_calculator_tool()self.hub_stats_tool = get_hub_stats_tool()with open("system_prompt.txt", "r") as f:self.system_prompt = f.read()print(self.system_prompt)# LLM and agent workflowself.llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")self.alfred = AgentWorkflow.from_tools_or_functions([*self.search_tool, *self.calculator_tool, self.wikipedia_tool, self.arxiv_tool, self.hub_stats_tool],llm=self.llm,system_prompt=self.system_prompt# verbose=True)LANGFUSE_AUTH=base64.b64encode(f"{os.getenv('LANGFUSE_PUBLIC_KEY')}:{os.getenv('LANGFUSE_SECRET_KEY')}".encode()).decode()36 unmodified linesdef main():agent = LlamaIndexAgent()query = "what is the capital of maharashtra?"print(f"Running query: {query}")response = asyncio.run(agent.run_query(query))print("\n🎩 Agents's Response:")print(response)if __name__ == "__main__":main()
2 unmodified lines34567892 unmodified lines1213141516171819202122232 unmodified linesimport requestsimport inspectimport pandas as pd# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"2 unmodified lines# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")fixed_answer = "This is a default answer."print(f"Agent returning fixed answer: {fixed_answer}")return fixed_answerdef run_and_submit_all( profile: gr.OAuthProfile | None):"""2 unmodified lines34567892 unmodified lines121314151617181920212223242 unmodified linesimport requestsimport inspectimport pandas as pdfrom agents import LlamaIndexAgent# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"2 unmodified lines# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):self.agent = LlamaIndexAgent()print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")response = self.agent.run_query(question)print(f"Agent returning fixed answer: {response}")return responsedef run_and_submit_all( profile: gr.OAuthProfile | None):"""
1give single word answer and reply.agents.py+11-5
app.py+5-4
system_prompt.txtAdded+1