[FREE] [STANDALONE] ChatGpt FiveM Assistant

 _______  _______ _________
(  ___  )(  ____ )\__   __/
| (   ) || (    )|   ) (   
| (___) || (____)|   | |   
|  ___  ||  _____)   | |   
| (   ) || (         | |   
| )   ( || )      ___) (___
|/     \||/       \_______/

OpenAi FiveM Assistant

A lua rest api for FiveM .

Key FeaturesHow To UseCreditsLicense

Key Features

The OpenAI API can be applied to virtually any task that involves understanding or generating natural language or code.

  • Use all models of OpenAi
    • You need to create an accout on OpenAi and get an API key.
  • Get response and print in char or console
  • Code adaptable to every need
    • Content generation
    • Summarization
    • Classification, categorization, and sentiment analysis
    • Data extraction
    • Translation
    • Many more!
  • Integrated with swiftUI
Method Target Description
text-generation prompt Generates text based on a given prompt
sentiment-analysis text Determines the sentiment of a given text
question-answering question Provides an answer to a given question based on a given context
context
summarization text Generates a short summary of a given text
translation text Translates text from one language to another
target
language-detection text Detects the language of a given text
text-classification text Classifies a given text into one or more predefined categories
categories
named-entity-recog. text Identifies named entities in a given text
text-to-speech text Converts text into spoken audio
image-recognition image Identifies objects and scenes in an image
text-to-image prompt Generates an image based on a given prompt
semantic-search query Finds documents related to a given query
documents
chatbot message Generates responses to a given message

How To Use

Copy the folder inside the resouce folder of your server, start the script inside server.cfg. To get the Api key go to your account on https://beta.openai.com/account/api-keys and copy the key.

In this example i’ve used Davinci gpt 3.5 Turbo model, you can change the model and use what you need.

Change the value with your OpenAi Api key

-- API endpoint URL
local url = "https://api.openai.com/v1/chat/completions"

-- API key for authentication
local api_key = "YOUR API KEY"

Use /chatgpt “custom prompt” inside fivem

You can change the command inside the server.lua

RegisterCommand("chatgpt", function(_src, arg)

Please read the official OpenAi API Documentation: https://beta.openai.com/docs if you need more info !

To get response text, you can use:

  if statusCode == 200 then
    -- Process the response data
    local decoded_response = json.decode(response)
    local completion = decoded_response.choices[1].message.content
    print("Completion:", completion)
    TriggerClientEvent('chat:addMessage', _src, {color = {255, 0, 0}, args = {"open_ai","" ..completion.. ""}})

Note

You can found more information on: https://platform.openai.com/docs/api-reference/completions/create

Credits

Ruxo

Evolve Rp V2

License

MIT, please don’t copy paste this code and spam on all FiveM forum as yours but add credits or reference. Thank you.


Ruxo Shop | AI Assistant (tebex.io)

More Scripts

Code is accessible Yes
Subscription-based No
Lines (approximately) 100
Requirements ESX
Support No
8 Likes

For what are you using ESX?

Nothing at the moment, cause i use a standard prompt for github. But you can pass to chatgpt some information, about numer of players inside the game, jobs, etc so it’s nice to have, but you can actually ignore it.

The simple fact is if you wanted to post about it here you should of just said I didn’t plagiarise your script and it shows in the commits why would I it’s a simple call to open ai’s endpoint

If only for the game…The API looks too expensive. Also if someone sent too long text, you will get heavy debt…

The cost is about 0.002 cent for token… and also openai provide a wallet with 5$ for free. It’s not expensive. For the “long text “ problem you can set the limit for the response ed: max 50 token. Of corse you need to create a business model around it or use it for your paid script. The code is here now it’s up to you :slight_smile:

im confused does this write code?

No, with this you can use chatgpt inside fivem, if you ask to write code inside the prompt the AI will write it as output inside fivem, as chatgpt do.

Why need to pay???

PLA violation