Spaces:
Build error
Build error
Update app.py
Browse files2603 unmodified lines2604260526062607260726082609261026112612261326132614261526162617261826192615261626172618261926202621262247 unmodified lines2670267126722673267326742675267626 unmodified lines2703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292706273127322733273427352736273727382739274027412742274327072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372745274627472748273827392740274127422743274427452746274727482749275027512752275327542755275627572758275027512759275327602761276227632603 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_prompt #self.grid_prompt = self._create_grid_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_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 lines else: print("Evaluation failed!") else: # Create the Gradio interface for user input mode demo = 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 query query = get_user_input(demo.get_component("textbox").value) """Main execution function.""" llm = DynamicLLM() # Initialize components query_handler = QueryHandler.process_query() # Access each value prompt = 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 response boss_agent = BossAgent(llm) #Activate BossAgent llm functions agent_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.ai boss_agent = BossAgent(llm) system = DynamicMultiAgentSystem() # Create Gradio interface with 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 boss agent_specs, _ = boss_agent.process_query(query) # Initialize system with new agents system.initialize_roles(agent_specs)
# Process the task with the defined agents #Need to add this. result = system.process_task({"query": query}) system.initialize_roles(agent_specs) # Process query with dynamic agents result = 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 interface interface.launch()
# Launch the demo demo.launch() # evaluator = ARCEvaluator() Does nothing. if not query: if not query: print("No input provided. Exiting...") return
app.py+59-52