AIN. - AnythingLLM AI

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

AIN. - AnythingLLM AI

AIN.ExecuteChat

Previous Top Next


MiniRobotLanguage (MRL)

 

AIN.ExecuteChat
Execute a Chat in a Workspace

 

Intention

 

ExecuteChat Command: Initiating a Chat Session
 
The ExecuteChat command allows you to send a message to a specific workspace in the AnythingLLM system and receive a response, effectively initiating or continuing a chat session.

This enables interactive communication within a workspace, making it ideal for conversational AI tasks or querying data.

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

 

What is the ExecuteChat Command?

 

The ExecuteChat command sends a user-defined message to a specified workspace slug, using the AnythingLLM API, and returns both a chat ID and the response text.

It supports two modes—"query" for one-off questions and "chat" for ongoing conversations—and stores the response for further analysis or display.

 

Why Do You Need It?

 

This command is essential for:

Interactive Dialogues: Engage in real-time conversations within a workspace.

Data Queries: Ask specific questions and retrieve answers from the AnythingLLM system.

Automation: Integrate chat functionality into automated workflows.

 

How to Use the ExecuteChat Command?

 

Use this command by specifying the workspace slug, the message, and optionally the mode. The response and chat ID are stored in variables or on the stack.

Ensure the API key is set with AIN.SetKey beforehand.

 

Example Usage

 

AIN.SetKey|your_api_key_here

AIN.ExecuteChat|my-workspace|What is AnythingLLM?|query|$$RES

DBP.Chat Response: $$RES

 

This sends a query to "my-workspace" and displays the response stored in $$RES.

 

Illustration

 

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

│ Chat Request            │

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

│ Workspace: my-workspace │

│ Message: "What is AI?"  │

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

Sending a chat message to a workspace and receiving a response.

 

Syntax

 

AIN.ExecuteChat|P1|P2[|P3[|P4]]

 

Parameter Explanation

 

P1 - Workspace slug (required). Identifies the workspace where the chat occurs.

P2 - Message (required). The text to send to the workspace.

P3 - Mode (optional). "query" (default) for a single question, or "chat" for a conversation. If omitted, defaults to "query".

P4 - Response variable (optional). Stores the chat response; if omitted, it’s placed on the stack.

 

Example

 

AIN.SetKey|your_api_key_here

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

DBP.Chat ID: $$CID

DBP.Response: $$RES

ENR.

 

Remarks

 

- Requires 3 to 4 parameters; fewer or more will trigger an error.

- The chat ID is always stored in $$CID, and the response is available via P4 or the stack.

 

Limitations

 

- Requires a valid workspace slug and a pre-set API key.

- Limited to text-based chats; for vision, use AIN.AskV.

 

See also:

 

AIN.CreateWorkspace

AIN.GetWorkspaceChats

AIN.ExportChats

Operations