Spaces:
Sleeping
Sleeping
Update app.py
Browse files355 unmodified lines35635735835936036136213 unmodified lines3763773783793803813823833843853863873883896 unmodified lines396397398399400401402403404405406355 unmodified linesif action_input != "none":try:state["search_result"] = await self.search_tool.run(action_input)if "name in state["question"].lower():names = re.findall(r'\b[A-Z][a-z]+(?:\s[A-Z][a-zA-Z]+)?\b', state["search_result"])state["search_result"] += f" Names: {', '.join(names[:5])}"elif "country code" in state["question"].lower():13 unmodified linesdef audio_error_node(state: AgentState) -> AgentState:logging.warning(f"Audio task not supported: {state['task_id']}")state["answer"] = "ERROR: Audio transcription not supported."state["action"] = Nonestate["messages"].append("Audio not supported.")return statedef image_error_node(state: AgentState) -> AgentState:logging.warning(f"Image task not supported: {state['task_id']}")state["answer"] = "ERROR: Image processing not supported."state["action"] = Nonestate["messages"].append("Image not supported.")return state6 unmodified linesif "sales" in state["question"].lower() and "food" in state["question"].lower():try:df = state["file_data"]logging.debug(f"Excel columns: {df.columns.tolist()]}")sales_col = next((col for col in df.columns if any(k in col.lower() for k in ["sale", "sales", "amount", "revenue"])), None)category_col = next((col for col in df.columns if any(k in col.lower() for k in ["category", "type", "item"])), None)if sales_col and category_col:food_sales = df[df["category"].str.lower().str.contains("drink", case=False, na=False) == False][sales_col].sum()state["answer"] = f"${food_sales:.2f}"else:logging.error("Invalid sales data: missing columns")355 unmodified lines35635735835936036136213 unmodified lines3763773783793803813823833843853863873883896 unmodified lines396397398399400401402403404405406355 unmodified linesif action_input != "none":try:state["search_result"] = await self.search_tool.run(action_input)if "name" in state["question"].lower():names = re.findall(r'\b[A-Z][a-z]+(?:\s[A-Z][a-zA-Z]+)?\b', state["search_result"])state["search_result"] += f" Names: {', '.join(names[:5])}"elif "country code" in state["question"].lower():13 unmodified linesdef audio_error_node(state: AgentState) -> AgentState:logging.warning(f"Audio task not supported: {state['task_id']}")state["answer"] = "ERROR: Audio transcription not supported"state["action"] = Nonestate["messages"].append("Audio not supported.")return statedef image_error_node(state: AgentState) -> AgentState:logging.warning(f"Image task not supported: {state['task_id']}")state["answer"] = "ERROR: Image processing not supported"state["action"] = Nonestate["messages"].append("Image not supported.")return state6 unmodified linesif "sales" in state["question"].lower() and "food" in state["question"].lower():try:df = state["file_data"]logging.debug(f"Excel columns: {df.columns.tolist()}")sales_col = next((col for col in df.columns if any(k in col.lower() for k in ["sale", "sales", "amount", "revenue"])), None)category_col = next((col for col in df.columns if any(k in col.lower() for k in ["category", "type", "item"])), None)if sales_col and category_col:food_sales = df[df[category_col].str.lower().str.contains("drink", case=False, na=False) == False][sales_col].sum()state["answer"] = f"${food_sales:.2f}"else:logging.error("Invalid sales data: missing columns")
app.py+5-5