AIN. - AnythingLLM API Integration

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

AIN. - AnythingLLM API Integration

AIN.GetWorkspaceChats

Previous Top Next


MiniRobotLanguage (MRL)

 

AIN.GetWorkspaceChats
Retrieve Chat History from an AnythingLLM Workspace

 

Intention

 

GetWorkspaceChats Command: Fetching Workspace Chat History
 
The GetWorkspaceChats command retrieves the chat history from a specified AnythingLLM workspace using its slug.

This enables you to review past interactions or analyze conversations within a workspace.

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

 

What is the GetWorkspaceChats Command?

 

This command queries the AnythingLLM API to fetch the chat history of a workspace, returning the raw JSON response and the count of chats.

You can customize the number of chats returned and their order (ascending or descending).

 

Why Do You Need It?

 

Fetching workspace chats is useful for:

Reviewing past interactions within a workspace.

Analyzing conversation data for insights or debugging.

Exporting or archiving chat history with AIN.ExportChats.

 

How to Use the GetWorkspaceChats Command?

 

Specify the workspace slug, and optionally set the limit and order of chats, along with a variable for the response.

The default limit is 50 chats, ordered descending (newest first), unless overridden.

 

Example Usage

 

AIN.GetWorkspaceChats|my-workspace|10|asc|$$RES

DBP.Chat History: $$RES

 

This retrieves the 10 oldest chats from "my-workspace" in ascending order.

 

Illustration

 

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

│ Chat History  │

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

│ JSON Array    │

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

Returns a JSON array of chat messages from the workspace.

 

Syntax

 

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

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

 

Parameter Explanation

 

P1 - The workspace slug identifying the workspace (required).

P2 - (Optional) Number of chats to return (defaults to 50).

P3 - (Optional) Order of chats ("asc" or "desc", defaults to "desc").

P4 - (Optional) Variable to store the raw JSON response.

 

Example

 

AIN.GetWorkspaceChats|my-workspace|5|desc|$$OUT

DBP.Recent Chats: $$OUT

ENR.

 

Remarks

 

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

- The chat count is stored in a separate variable (T03 in the code), accessible via stack operations if needed.

 

Limitations

 

- Returns an empty response if the workspace has no chats or doesn’t exist.

- Limited to 2-4 parameters; exceeding this causes an error.

 

See also:

 

AIN.CreateWorkspace

AIN.ExecuteChat

AIN.ExportChats

Workspace Management