Spaces:
Build error
Build error
Update chat.py
Browse files337 unmodified lines338339340341342343344345346341342343344345346347348349350349350351352353354337 unmodified lines # Debugging: Print raw response to check its format print("Raw Response:", response_content) # Try to parse the response as JSON try: # Find the JSON-like section and load it start_index = response_content.find("{") json_part = response_content[start_index:] # Extract starting from the first '{' structured_data = json.loads(json_part) # Parse the JSON part # Step 1: Extract the JSON part from the markdown # Split the response content to isolate the JSON part json_part = response_content.split("```json\n")[1].split("\n```")[0] # Step 2: Parse the JSON content try: structured_data = json.loads(json_part) # Parse the JSON content print("Parsed JSON:", structured_data) except (json.JSONDecodeError, ValueError) as e: print(f"Error: {e}") except json.JSONDecodeError: print("Error: Response content is not valid JSON.")
# Convert the structured data into a DataFramechat.py+9-8