Debugging a Function Returning None in Python Code
Hi team I am using below function and I am returning question and answers with value which are coming correctly in trace. Butt when I try queries_df = get_qa_with_reference(px.Client()) I am getting None tracer = trace.get_tracer("langchain") class RequestsChain(RunnableSerializable): endpoint: str = Field(..., description="API endpoint for chatbot requests") @tracer.chain def invoke(self, question) -> Dict[str, Any]: try: input = {"ques_text": question} response = requests.post(self.endpoint, data=json.dumps(input)) response.raise_for_status() data = response.json() answers = [] for item in data["0"]: if item["type"] == "Text": html = item["value"] text = re.sub(r'<[^>]+>', '', html) match = re.search(r'Answer:\s*(.*)', text, re.DOTALL) if match: answer_text = match.group(1).strip() answers.append(answer_text) return { "input": {"value": question}, "output": {"value": answers or "No answer"} } except Exception as e: return {"error": str(e), "input": input}
