Spaces:
Build error
Build error
Commit ·
c91fcfb
1
Parent(s): 549edad
check
Browse files24 unmodified lines2526272829282930313233313233343435363738394041424311 unmodified lines55565752585960612 unmodified lines6465666167686970657172737427 unmodified lines1021031049910510610710824 unmodified lines print("BasicAgent initialized.") async def aquery(self, question: str) -> str: messages = [HumanMessage(content=question)] # messages = self.agent.invoke({"messages": messages}, config={"callbacks": [langfuse_handler]}) print(f"Agent received question (first 50 chars): {question[:50]}...") try: response = await self.agent.invoke({"messages": messages}, config={"callbacks": [langfuse_handler]}) print(f"Agent raw response: {response}") if not response or 'messages' not in response or not response['messages']: print("Agent response missing or empty 'messages'. Returning AGENT ERROR.") response = await self.agent.invoke({"messages": messages}, config={"callbacks": [langfuse_handler]}) answer = response['messages'][-1].content print(f"Agent returning fixed answer: {answer}") return answer return "AGENT ERROR: No response from agent." answer = response['messages'][-1].content print(f"Agent returning answer: {answer}") return answer except Exception as e: print(f"Exception in aquery: {e}") return f"AGENT ERROR: {e}"
# Global cache for answers (in-memory)cached_answers = None11 unmodified lines print(f"User logged in: {username}") else: print("User not logged in.") return "Please Login to Hugging Face with the button.", None, gr.update(interactive=False), gr.update(value=0, visible=False) return "Please Login to Hugging Face with the button.", None, gr.update(interactive=False) api_url = DEFAULT_API_URL questions_url = f"{api_url}/questions" try:2 unmodified lines questions_data = response.json() if not questions_data: print("Fetched questions list is empty.") return "Fetched questions list is empty or invalid format.", None, gr.update(interactive=False), gr.update(value=0, visible=False) return "Fetched questions list is empty or invalid format.", None, gr.update(interactive=False) print(f"Fetched {len(questions_data)} questions.") except Exception as e: print(f"Error fetching questions: {e}") return f"Error fetching questions: {e}", None, gr.update(interactive=False), gr.update(value=0, visible=False) return f"Error fetching questions: {e}", None, gr.update(interactive=False) agent = BasicAgent() results_log = [] answers_payload = []27 unmodified lines cached_results_log = results_log progress(100, desc="Done.") results_df = pd.DataFrame(results_log) return "Answer generation complete. Review and submit.", results_df, gr.update(interactive=True), gr.update(value=100, visible=True) return "Answer generation complete. Review and submit.", results_df, gr.update(interactive=True)
def submit_answers(profile: gr.OAuthProfile | None): """app.py+16-10