From 95d6ce16ac178be7d2ac5ee3f8649c8e465a425b Mon Sep 17 00:00:00 2001 From: 6447d2fa31ba9538b48779c3 <6447d2fa31ba9538b48779c3@devide> Date: Wed, 26 Apr 2023 13:53:00 +0000 Subject: [PATCH] Wed Apr 26 13:53:00 UTC 2023 inscode --- main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 4c0c135..babae01 100644 --- a/main.py +++ b/main.py @@ -1 +1,15 @@ -print('欢迎来到 InsCode') \ No newline at end of file +import openai +import json + +def get_api_key(): + # 可以自己根据自己实际情况实现 + # 以我为例子,我是存在一个 openai_key 文件里,json 格式 + ''' + {"api": "你的 api keys"} + ''' + openai_key_file = '../envs/openai_key' + with open(openai_key_file, 'r', encoding='utf-8') as f: + openai_key = json.loads(f.read()) + return openai_key['api'] + +print(get_api_key()) \ No newline at end of file -- GitLab