Closed Chenchenxxx closed 8 months ago
I just ran the code you sent and didn't get an error message. I assume this error is happening because the API is rate-limited. You could wait a bit before trying to continue running the script, or you could set some artificial waiting times in your script.
Hello, while reproducing the model, I tried to get some predictions from Delphi in the following way as you suggested:
import requests import json question_prefix = “[moral_single]: ” for question in questions: question_input = question_prefix + question r = requests.post(“https://mosaic-api-morality-delta.apps.allenai.org/api/answer”, headers={“Content-Type”: “application/json”}, data=json.dumps({“question”: question_input})) r_json = r.json() # This will get you the response as a JSON object class_label = r_json[“output_raw_list”][0].split(“/class> text>“)[0].split(“class>“)[-1] text_label = r_json[“output_raw_list”][0].split(“/class> text>“)[-1] print(class_label, text_label)
I can't get all feedbacks of the questions from delphi and get this error "requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" caused by this line "r_json = r.json()", and get this response "503 Service Temporarily Unavailable". Could you please give me any suggestion on how to solve the problem? Thanks in advance for your help!