代码拉取完成,页面将自动刷新
import os
import json
import config
import requests
class model_chatgpt_3p5_turbo:
def __init__(self) -> None:
super(model_chatgpt_3p5_turbo, self).__init__()
for llm in config.get_config().models.llms:
if llm.name == "AiSkt" and llm.enable == 1:
self._gpt3p5_path = llm.path
def completion(self, prompt_system, prompt_user):
api_url = self._gpt3p5_path + '/chat/completions'
api_key = os.environ.get('CHAT_GPT_APIKEY')
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
payload = {
'model': "gpt-3.5-turbo",
'messages': [{"role": "system", "content": prompt_user}]
}
try:
response = requests.post(api_url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
data = response.json()
return data['choices'][0]['message']['content']
else:
return f'Error: Received status code {response.status_code}'
except Exception as e:
print(e)
return 'An error occurred while sending the request'
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。