AIN. - AnythingLLM AI

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

AIN. - AnythingLLM AI

AIN.ExecuteOpenAIChat

Previous Top Next


MiniRobotLanguage (MRL)

 

AIN.ExecuteOpenAIChat
Execute a Chat Using OpenAI Compatibility

 

Intention

 

ExecuteOpenAIChat Command: Perform Chat Operations
 
The ExecuteOpenAIChat command enables you to send a chat message to an AnythingLLM workspace using an OpenAI-compatible API format.

This allows seamless integration with OpenAI-style chat requests, leveraging AnythingLLM’s capabilities for conversational tasks.

It’s part of the AIN - AnythingLLM AI suite.

 

What is the ExecuteOpenAIChat Command?

 

This command sends a chat request to a specified workspace, formatted as an OpenAI-compatible JSON payload, and returns the response.

The response can be stored in a variable or on the stack, typically containing the AI’s reply in a structured format.

 

Why Do You Need It?

 

Executing a chat is essential for:

Conversational AI: Interact with a workspace’s AI model using natural language.

Integration: Use OpenAI-compatible tools or scripts with AnythingLLM.

Automation: Automate responses or queries within a workspace.

 

How to Use the ExecuteOpenAIChat Command?

 

Provide the workspace slug, chat message, and optionally a variable to store the response.

It uses the chat endpoint set by AIN.SetChatEndpoint (default: http://localhost:3001/api/workspace/{slug}/chat).

 

Example Usage

 

AIN.ExecuteOpenAIChat|my-workspace|Hello, how are you?|$$RES

DBP.AI Response: $$RES

 

This sends "Hello, how are you?" to "my-workspace" and stores the response in $$RES.

 

Illustration

 

┌───────────────┐

│ Chat Input    │

├───────────────┤

│ "Hello"       │

└──────┬────────┘

       │

┌──────▼────────┐

│ AI Response   │

├───────────────┤

│ "Hi there!"   │

└───────────────┘

A simple chat request and response flow.

 

Syntax

 

AIN.ExecuteOpenAIChat|P1|P2[|P3]

AIN.EOC|P1|P2[|P3]

 

Parameter Explanation

 

P1 - (Required) The slug of the workspace to send the chat request to.

P2 - (Required) The chat message or JSON payload to send (e.g., a simple string or OpenAI-style request).

P3 - (Optional) Variable to store the chat response; if omitted, the response is stored on the stack.

 

Example

 

AIN.EOC|my-workspace|What’s the weather like?|$$ANS

DBP.AI Says: $$ANS

ENR.

 

Remarks

 

- Requires a valid API key set via AIN.SetKey.

- The response format depends on the workspace’s AI model and settings.

- Supports OpenAI-compatible JSON payloads for advanced chat configurations.

 

Limitations

 

- Limited to 3 parameters; excess parameters trigger an error.

- Requires an existing workspace slug; invalid slugs return an error.

 

See also:

 

AIN.CreateWorkspace

AIN.GetWorkspaceBySlug

AIN.ListWorkspaces

AIN.SetKey