Spaces:
Runtime error
Runtime error
natexcvi
commited on
Commit
•
e51d953
1
Parent(s):
3fc62de
Fix json path parsing
Browse files
main.py
CHANGED
@@ -135,13 +135,13 @@ async def get_patient_issues(patient_id: str) -> list[PatientIssue] | Response:
|
|
135 |
@app.post("/log-message-response")
|
136 |
async def log_message_response(msg: dict = Body(...)):
|
137 |
print(msg)
|
138 |
-
user_id = JSONPath("$..from.id").parse(msg)
|
139 |
if user_id not in db.conversation_state:
|
140 |
return Response(status_code=status.HTTP_404_NOT_FOUND)
|
141 |
state = db.conversation_state[user_id]
|
142 |
patient_id = state["patient_id"]
|
143 |
-
response = JSONPath("$..queryResult.queryText").parse(msg)
|
144 |
-
action = JSONPath("$..queryResult.action").parse(msg)
|
145 |
state["action"] = action
|
146 |
state["current_question"] += 1
|
147 |
if state["action"] == "good-flow.good-flow-no.good-flow-no-no-2":
|
|
|
135 |
@app.post("/log-message-response")
|
136 |
async def log_message_response(msg: dict = Body(...)):
|
137 |
print(msg)
|
138 |
+
user_id = JSONPath("$..from.id").parse(msg)[0]
|
139 |
if user_id not in db.conversation_state:
|
140 |
return Response(status_code=status.HTTP_404_NOT_FOUND)
|
141 |
state = db.conversation_state[user_id]
|
142 |
patient_id = state["patient_id"]
|
143 |
+
response = JSONPath("$..queryResult.queryText").parse(msg)[0]
|
144 |
+
action = JSONPath("$..queryResult.action").parse(msg)[0]
|
145 |
state["action"] = action
|
146 |
state["current_question"] += 1
|
147 |
if state["action"] == "good-flow.good-flow-no.good-flow-no-no-2":
|