V1.5
This commit is contained in:
1 parent
714366665c
commit
4e62fa83a3
3 files changed
+82
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
--Ruxo made For Evolve Rp V2 ITA https://discord.gg/Cc7fbazCmB
|
||||||
|
|
||||||
|
ESX = exports["es_extended"]:getSharedObject()
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
fx_version 'adamant'
|
||||||
|
|
||||||
|
game 'gta5'
|
||||||
|
name 'ruxo_openai'
|
||||||
|
version '1.5'
|
||||||
|
description 'Ruxo OpenAi'
|
||||||
|
|
||||||
|
|
||||||
|
shared_scripts{
|
||||||
|
"@es_extended/imports.lua",
|
||||||
|
}
|
||||||
|
|
||||||
|
client_scripts {
|
||||||
|
'client/client.lua',
|
||||||
|
}
|
||||||
|
|
||||||
|
server_scripts {
|
||||||
|
'@mysql-async/lib/MySQL.lua',
|
||||||
|
'server/server.lua',
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
'es_extended'
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
GPT = {}
|
||||||
|
-- don't touch, made by Ruxo for Evolve RP
|
||||||
|
|
||||||
|
ESX = exports["es_extended"]:getSharedObject()
|
||||||
|
|
||||||
|
RegisterCommand("chatgpt", function(_src, arg)
|
||||||
|
|
||||||
|
-- API endpoint URL
|
||||||
|
local url = "https://api.openai.com/v1/chat/completions"
|
||||||
|
|
||||||
|
-- API key for authentication
|
||||||
|
local api_key = "YOUR API KEY"
|
||||||
|
|
||||||
|
-- Request data
|
||||||
|
local data = {
|
||||||
|
model = "gpt-3.5-turbo",
|
||||||
|
messages = {
|
||||||
|
{
|
||||||
|
role = "user",
|
||||||
|
content = tostring(arg[1]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role = "system",
|
||||||
|
content = "You are a personal assistant for a FiveM server called Evolve",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Convert data to JSON
|
||||||
|
local request_data = json.encode(data)
|
||||||
|
|
||||||
|
-- Set request headers
|
||||||
|
local headers = {
|
||||||
|
["Content-Type"] = "application/json",
|
||||||
|
["Authorization"] = "Bearer " .. api_key
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Perform the POST request
|
||||||
|
PerformHttpRequest(url, function(statusCode, response)
|
||||||
|
if statusCode == 200 then
|
||||||
|
-- Process the response data
|
||||||
|
local decoded_response = json.decode(response)
|
||||||
|
local completion = decoded_response.choices[1].message.content
|
||||||
|
--print("Response: " ..response)
|
||||||
|
print("Completion:", completion)
|
||||||
|
TriggerClientEvent('chat:addMessage', _src, {color = {255, 0, 0}, args = {"open_ai","" ..completion.. ""}})
|
||||||
|
else
|
||||||
|
print("Error:", statusCode)
|
||||||
|
end
|
||||||
|
end, "POST", request_data, headers)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user