使用魔搭社区的创空间建立了一个APP后,想通过API访问该APP,点击下方“通过API使用”,按里面给出的示例代码,运行后报错。代码如下:
from gradio_client import Client
client = Client("https://nkhk1988-creditriskassessmentassistantv0-1.ms.show/")
result = client.predict(
chatbot=[[None,{"id":None,"elem_id":None,"elem_classes":None,"name":None,"text":"尝试问我一点什么吧~","flushing":None,"avatar":"","files":None}]],
input={"files":[],"text":""},
_user_token="Hello!!",
api_name="CreditRiskAssessmentAssistantV0.1"
)
print(result)
报错:Traceback (most recent call last):
File "D:\AI\mlp-concise.py", line 3, in
client = Client("https://nkhk1988-creditriskassessmentassistantv0-1.ms.show/")
File "D:\Anaconda\envs\conda39\lib\site-packages\gradio_client\client.py", line 171, in init
self._info = self._get_api_info()
File "D:\Anaconda\envs\conda39\lib\site-packages\gradio_client\client.py", line 566, in _get_api_info
raise ValueError(f"Could not fetch api info for {self.src}: {r.text}")
ValueError: Could not fetch api info for https://nkhk1988-creditriskassessmentassistantv0-1.ms.show/: {"Code":10011402001,"Message":"Please login first!","RequestId":"307bf8b2-e616-43eb-b7af-e85c83251855","Success":false}
是不是应该把代码中的某些字段替换为登录信息,我曾经试过把API_KEY填在user-token,还是不行。需要替换哪些内容呢?
好像是第一步登录就卡住了,还请各位高手指教,可以如何修改呢?