-- 客户端注册 接收消息
local function networkCB(msgID, p1, p2, p3, msgData)
local function httpCB(success, response)
SL:print(success, response)
if success then
local content = SL:JsonDecode(response)
SL:print(content.choices[1].message.content)
local mdata = {
Msg = string.format("Ai小66:%s", content.choices[1].message.content),
FColor = 255,
BColor = 249,
}
SL:SendSystemMsgToChat(mdata)
end
end
local url = "https://api.deepseek.com/chat/completions"
local apiKey = "sk-fbd276e2a49848298bb99a2f0d57c4f2"
local jsonData =string.format([[
{
"model": "deepseek-chat",
"messages": [
{ "role": "system","content": "回复不要超过30个字,不要带表情符号!,回答别人称呼:大侠,你是一名专业的游戏客服!帮助玩家解决各种问题!你的名字叫小6,非常熟悉传奇的游戏玩法!"},
{"role": "user", "content": "%s"}
],
"stream": false
}
]],msgData)
SL:print(msgData)
local headers = {
["Authorization"] = "Bearer " .. apiKey,
["Content-Type"] = "application/json",
}
SL:HTTPRequestPost(url, httpCB, jsonData, headers)
end
SL:RegisterLuaNetMsg(1000, networkCB)
SL:print(MainProperty._ui.Layout_1)