AI
The official AI module for BoxLang
Welcome to the BoxLang AI Module. This module is a BoxLang module that provides AI capabilities to your BoxLang applications.
Providers
The following AI providers are supported:
More coming soon.
Settings
Here are the settings you can place in your boxlang.json
file:
Usage
This module exposes the following BoxLang functions:
aiChat( messages, model, struct data={}, boolean verbose=false )
: This function will allow you to chat with the AI provider and get responses back.aiChatAsync( messages, model, struct data={}, boolean verbose=false )
: This function will allow you to chat with the AI provider asynchronously and give you back a BoxLang Completable Future.
Arguments
messages
: The messages to chat with the AI. This is provider dependent. Please see each section for more information.model
: The model to use for the AI provider. This is provider dependent. Please see each section for more information.data
: The data to pass to the AI provider. This is provider dependent. Please see each section for more information.verbose
: A flag to output verbose information about the AI chat or just the response message.
OpenAI
The OpenAI provider will allow you to interact with the following APIs:
Chat API - https://platform.openai.com/docs/api-reference/chat
Image API
Embedding API
Please see OpenAI API for more information.
aiChat() / aiChatAsync()
You can use the aiChat()
function to chat with the OpenAI API. Here is more docs on this: https://platform.openai.com/docs/guides/text-generation
Messages
This can be any of the following
A string : A message with a default
role
ofuser
will be usedA struct : A single message that must have a
role
and acontent
keyAn array of structs : An array of messages that must have a
role
and acontent
keys
Model
The supported models for OpenAI are:
gpt-4o
: The large modelgpt-4o-mini
: The more affordable but slower modelgpt-4o-turbo
: The turbo modelMuch more, look at the docs.
You can find more information here: https://platform.openai.com/docs/models
Data
This is an arbitrary structure that will be passed to the OpenAI API alongsside the top level body.
Examples
Here are some examples of chatting with the AI:
Tools
OpenAI tools are designed to enhance capabilities by providing access to real-time information, advanced computations, external integrations, and interactive features. This allows you to bind a function that will process the AI information for you in realtime.
Last updated
Was this helpful?