将密钥文件放置于配置文件中保存

This commit is contained in:
Kakune55 2023-11-14 12:23:19 +08:00
parent 5a9eb250ae
commit 1a4ea051e3
3 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import zhipuai
import zhipuai , config
zhipuai.api_key = "83f977afedc7f414dea579a2551298c2.sydItr1sZT8UPXWb"
zhipuai.api_key = config.readConf()["chatglmturbo"]["Authorization"]
def service(prompt,history = ""):
if history == "":

5
src/Server/config.py Normal file
View File

@ -0,0 +1,5 @@
import json
def readConf():
with open('config.json') as f:
return json.load(f)

View File

@ -1,11 +1,10 @@
import requests , json
import requests , json , config
# 设置请求的目标URL
url = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" # 替换为你的API端点URL
url = config.readConf()["qwenturbo"]["url"] # 替换为你的API端点URL
header = {
"Content-Type":"application/json",
"Authorization":"Bearer sk-69129a5d7fc6468a9f6f30d6935254c6"
"Authorization":config.readConf()["qwenturbo"]["Authorization"]
}
def service(prompt,history = ""):