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