mirror of
https://github.com/Kakune55/PyGetGPT.git
synced 2025-12-16 01:03:55 +08:00
更改项目文件夹结构
This commit is contained in:
31
apiModule/qwenTurbo.py
Normal file
31
apiModule/qwenTurbo.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import requests , json , config
|
||||
|
||||
# 设置请求的目标URL
|
||||
url = config.readConf()["qwenturbo"]["url"] # 替换为你的API端点URL
|
||||
header = {
|
||||
"Content-Type":"application/json",
|
||||
"Authorization":config.readConf()["qwenturbo"]["Authorization"]
|
||||
}
|
||||
|
||||
def service(prompt,history = ""):
|
||||
# 设置请求数据
|
||||
if history == "":
|
||||
data = {
|
||||
"model": "qwen-turbo",
|
||||
"input":{
|
||||
"prompt":f"{prompt}"
|
||||
}
|
||||
}
|
||||
else:
|
||||
data = {
|
||||
"model": "qwen-turbo",
|
||||
"input":{
|
||||
"prompt":f"{prompt}",
|
||||
"history":history
|
||||
}
|
||||
}
|
||||
# 发送POST请求
|
||||
response = json.loads(requests.post(url, json=data ,headers=header).text)
|
||||
if 'code' in response:
|
||||
return 50,response['code']+response['message'],0
|
||||
return 200,response['output']['text'],response["usage"]["total_tokens"]
|
||||
Reference in New Issue
Block a user