Spaces:
Build error
Build error
Commit ·
c91fcfb
1
Parent(s): 549edad
check
Browse files24 unmodified lines2526272829303132333435363711 unmodified lines495051525354552 unmodified lines585960616263646566676827 unmodified lines9697989910010110224 unmodified linesprint("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]}...")response = await self.agent.invoke({"messages": messages}, config={"callbacks": [langfuse_handler]})answer = response['messages'][-1].contentprint(f"Agent returning fixed answer: {answer}")return answer# Global cache for answers (in-memory)cached_answers = None11 unmodified linesprint(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)api_url = DEFAULT_API_URLquestions_url = f"{api_url}/questions"try:2 unmodified linesquestions_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)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)agent = BasicAgent()results_log = []answers_payload = []27 unmodified linescached_results_log = results_logprogress(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)def submit_answers(profile: gr.OAuthProfile | None):"""24 unmodified lines2526272829303132333435363738394041424311 unmodified lines555657585960612 unmodified lines646566676869707172737427 unmodified lines10210310410510610710824 unmodified linesprint("BasicAgent initialized.")async def aquery(self, question: str) -> str:messages = [HumanMessage(content=question)]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.")return "AGENT ERROR: No response from agent."answer = response['messages'][-1].contentprint(f"Agent returning answer: {answer}")return answerexcept Exception as e:print(f"Exception in aquery: {e}")return f"AGENT ERROR: {e}"# Global cache for answers (in-memory)cached_answers = None11 unmodified linesprint(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)api_url = DEFAULT_API_URLquestions_url = f"{api_url}/questions"try:2 unmodified linesquestions_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)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)agent = BasicAgent()results_log = []answers_payload = []27 unmodified linescached_results_log = results_logprogress(100, desc="Done.")results_df = pd.DataFrame(results_log)return "Answer generation complete. Review and submit.", results_df, gr.update(interactive=True)def submit_answers(profile: gr.OAuthProfile | None):"""
app.py+16-10