Spaces:
Build error
Build error
Update app.py
Browse files2603 unmodified lines260426052606260726082609261026112612261326142615261626172618261926202621262247 unmodified lines267026712672267326742675267626 unmodified lines2703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562603 unmodified lines], 3'''#Function below allows the Boss LLM to handle both grid (evaluation for Arc only) and user queries. Only the generic user query is used but the grid can be easily added in the main def function.class QueryHandler:"""Handles different types of queries and generates appropriate prompts."""def __init__(self):self.default_prompt = self._create_default_prompt#self.grid_prompt = self._create_grid_prompt# def create_prompt(self, query: str, is_grid_query: bool = True) -> str:# """Create appropriate prompt based on query type."""# if not is_grid_query:# return self._create_custom_prompt(query) #This is in case the user wants to use a dataset as this can be turned on by removing the comments to allow the user to use a dataset.# return self._create_grid_prompt(query)def _create_default_prompt(self, query: str) -> str:"""Create a standard prompt for non-grid queries."""47 unmodified lines'is_grid_query': is_grid_query,'query_type': 'grid' if is_grid_query else 'standard','timestamp': time.time()}def main():try:26 unmodified lineselse:print("Evaluation failed!")else:# Create the Gradio interface for user input modedemo = gr.Interface(fn=get_user_input,inputs=gr.Textbox(label="Enter your task",placeholder="Describe the task you want to process...",lines=3),outputs=gr.Textbox(label="System Response",lines=5),title="Dynamic Agent System",description="Enter a task and the system will process it using dynamic agents.",examples=[["Analyze the sentiment of this text"],["Generate a summary of the following document"],],cache_examples=True)# Get user input for queryquery = get_user_input(demo.get_component("textbox").value)"""Main execution function."""llm = DynamicLLM()# Initialize componentsquery_handler = QueryHandler.process_query()# Access each valueprompt = query_handler['prompt']is_grid_query = query_handler['is_grid_query']query_type = query_handler['query_type']timestamp = query_handler['timestamp']# For string-based responses# Get boss agent responseboss_agent = BossAgent(llm) #Activate BossAgent llm functionsagent_specs, rounds = boss_agent.process_query(prompt) #boss_response variable in claude.ai refers to this prompt here.Retrieve agent roles and rounds for dynamic agent system.# Initialize the dynamic multi-agent system - Need to change this function from claude.aisystem = DynamicMultiAgentSystem()system.initialize_roles(agent_specs)# Process the task with the defined agents #Need to add this.result = system.process_task({"query": query})# Launch the demodemo.launch()# evaluator = ARCEvaluator() Does nothing.if not query:print("No input provided. Exiting...")return2603 unmodified lines260426052606260726082609261026112612261326142615261626172618261926202621262247 unmodified lines267026712672267326742675267626 unmodified lines27032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632603 unmodified lines], 3'''#Function below allows the Boss LLM to handle both grid (evaluation for Arc only) and user queries. Only the generic user query is used but the grid can be easily added in the main def function.''' #The query handler function does nothing and was replaced with the query processing in the main function.class QueryHandler:"""Handles different types of queries and generates appropriate prompts."""def __init__(self):self.default_prompt = self._create_default_promptself.grid_prompt = self._create_grid_promptdef create_prompt(self, query: str, is_grid_query: bool = True) -> str:"""Create appropriate prompt based on query type."""if not is_grid_query:return self._create_custom_prompt(query) #This is in case the user wants to use a dataset as this can be turned on by removing the comments to allow the user to use a dataset.return self._create_grid_prompt(query)def _create_default_prompt(self, query: str) -> str:"""Create a standard prompt for non-grid queries."""47 unmodified lines'is_grid_query': is_grid_query,'query_type': 'grid' if is_grid_query else 'standard','timestamp': time.time()}'''def main():try:26 unmodified lineselse:print("Evaluation failed!")else:llm = DynamicLLM()boss_agent = BossAgent(llm)system = DynamicMultiAgentSystem()# Create Gradio interfacewith gr.Blocks() as interface:gr.Markdown("# Dynamic Agent System")with gr.Row():query = gr.Textbox(label="Enter your query",placeholder="What would you like the agents to help you with?",lines=3)with gr.Row():submit_btn = gr.Button("Process Query")with gr.Row():output = gr.Textbox(label="System Response",lines=10)def process_query(query):if not query.strip():return "Please enter a query"try:# Get agent specifications from bossagent_specs, _ = boss_agent.process_query(query)# Initialize system with new agentssystem.initialize_roles(agent_specs)# Process query with dynamic agentsresult = system.process_task({"query": query})return result.get('response', 'No response generated')except Exception as e:return f"Error processing query: {str(e)}"submit_btn.click(fn=process_query,inputs=query,outputs=output)# Launch interfaceinterface.launch()# evaluator = ARCEvaluator() Does nothing.if not query:print("No input provided. Exiting...")return
app.py+59-52