合并代码。临时上传
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import requests
|
||||
from Entity.Variables import prologueList
|
||||
from Entity.Variables import prologueList, API_KEY
|
||||
from Utils.IOSAIStorage import IOSAIStorage
|
||||
from Utils.JsonUtils import JsonUtils
|
||||
from Utils.LogManager import LogManager
|
||||
@@ -84,31 +84,63 @@ class Requester():
|
||||
# ai聊天
|
||||
@classmethod
|
||||
def chatToAi(cls, param):
|
||||
aiConfig = JsonUtils.read_json("aiConfig")
|
||||
|
||||
|
||||
|
||||
|
||||
# aiConfig = JsonUtils.read_json("aiConfig")
|
||||
aiConfig = IOSAIStorage.load("aiConfig.json")
|
||||
|
||||
|
||||
|
||||
|
||||
agentName = aiConfig.get("agentName")
|
||||
guildName = aiConfig.get("guildName")
|
||||
contactTool = aiConfig.get("contactTool", "")
|
||||
contact = aiConfig.get("contact", "")
|
||||
|
||||
age = aiConfig.get("age", 20)
|
||||
sex = aiConfig.get("sex", "女")
|
||||
height = aiConfig.get("height", 160)
|
||||
weight = aiConfig.get("weight", 55)
|
||||
body_features = aiConfig.get("body_features", "")
|
||||
nationality = aiConfig.get("nationality", "中国")
|
||||
personality = aiConfig.get("personality", "")
|
||||
strengths = aiConfig.get("strengths", "")
|
||||
|
||||
|
||||
|
||||
|
||||
inputs = {
|
||||
"name": agentName,
|
||||
"Trade_union": guildName,
|
||||
"contcat_method": contactTool,
|
||||
"contcat_info": contact
|
||||
"contcat_info": contact,
|
||||
"age": age,
|
||||
"sex": sex,
|
||||
"height": height,
|
||||
"weight": weight,
|
||||
"body_features": body_features,
|
||||
"nationality": nationality,
|
||||
"personality": personality,
|
||||
"strengths": strengths,
|
||||
}
|
||||
|
||||
param["inputs"] = inputs
|
||||
|
||||
try:
|
||||
url = "https://ai.yolozs.com/chat"
|
||||
result = requests.post(url=url, json=param, verify=False)
|
||||
|
||||
# url = "https://ai.yolozs.com/chat"
|
||||
url = "https://ai.yolozs.com/customchat"
|
||||
|
||||
result = requests.post(url=url, json=param, verify=False)
|
||||
|
||||
LogManager.method_info(f"ai聊天的参数:{param}", "ai聊天")
|
||||
print(f"ai聊天的参数:{param}")
|
||||
|
||||
json = result.json()
|
||||
data = json.get("answer", {})
|
||||
session_id = json.get("conversation_id", {})
|
||||
data = json.get("answer", "")
|
||||
session_id = json.get("conversation_id", "")
|
||||
LogManager.method_info(f"ai聊天返回的内容:{result.json()}", "ai聊天")
|
||||
|
||||
return data, session_id
|
||||
|
||||
Reference in New Issue
Block a user