已复制到自己空间,请问如何在配置文件中写入key以达到前端不需要输入key即可使用的目的

#5
by linbo0 - opened

如题,在config中写了key然而前端还是要输入key才行
怎么配置才可以前端免key使用呢?

Add文件中,把第57行的placeholder=“”改为value=“”

[Local Message] Incorrect API key provided.

我改的是54行,请问对么: api = gr.Textbox(show_label=False, value="").style(container=False)

Add文件中,把第57行的placeholder=“”改为value=“”

我改的是54行,请问对么: api = gr.Textbox(show_label=False, value="").style(container=False)

改完后前端仍是有api输入框,且对话保api kye provided

说错了,是53行,哈哈,不好意思

改完了,重新启动一下,然后就会出现了

改完了,重新启动一下,然后就会出现了

改了app.py的第53行为:api_key = gr.Textbox(show_label=False, value="").style(container=False)
改了config.py的第2:API_KEY =我自己的api

测试对话报异常:
[Local Message] 异常

Traceback (most recent call last):
File "/home/user/app/predict.py", line 169, in predict
if len(json.loads(chunk.decode()[6:])['choices'][0]["delta"]) == 0:
File "/usr/local/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
"error": { "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.", "type": "invalid_request_error", "param": null, "code": null }}

请教应如何处理

要把你的key也放在value里啊

要把你的key也放在value里啊

搞定,感谢

在第53行中加入visible=False可以直接隐藏key的输入框,效果会更好一点

请问app.py文件在哪里

linbo0 changed discussion status to closed

Sign up or log in to comment