From 0790e07393e60f736c41d825255df429f67270f5 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Tue, 7 Feb 2023 17:47:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E7=94=A8chatgpt?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "py/chatgpt\350\260\203\347\224\250.py" | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git "a/py/chatgpt\350\260\203\347\224\250.py" "b/py/chatgpt\350\260\203\347\224\250.py" index 873b921..c54b5e0 100644 --- "a/py/chatgpt\350\260\203\347\224\250.py" +++ "b/py/chatgpt\350\260\203\347\224\250.py" @@ -10,7 +10,7 @@ from time import time import requests -API_KEY = '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' +API_KEY = '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' AUTH = f'Bearer {API_KEY}' def ask_chatpgt(word): @@ -34,6 +34,7 @@ def ask_chatpgt(word): try: r = requests.post('https://api.openai.com/v1/completions',data=json.dumps(pdata),headers=headers) ret = r.json() + # print(ret) answer = ret['choices'][0]['text'] except Exception as e: answer = f'发生了错误:{e}' @@ -45,7 +46,8 @@ def ask_chatpgt(word): return [answer,sec] if __name__ == '__main__': - # print(ask_chatpgt('1+1等于几')) + print(ask_chatpgt('1+1等于几')) # http://fastapi.frp.mudery.com/other_request/chatgpt # http://spider.scwinbao.com:8274/other_request/chatgpt - print(ask_chatpgt('假如我处于一个荒岛,现在我来扮演玩家,你来扮演电脑,你给我选项,我们玩一个荒岛求生的游戏')) \ No newline at end of file + # print(ask_chatpgt('假如我处于一个荒岛,现在我来扮演玩家,你来扮演电脑,你给我选项,我们玩一个荒岛求生的游戏')) + # print(ask_chatpgt('以 背影为题,写一篇400字的作文')) \ No newline at end of file -- GitLab