AIN. - AnythingLLM AI

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

AIN. - AnythingLLM AI

AIN.GetThreadChats

Previous Top Next


MiniRobotLanguage (MRL)

 

AIN.GetThreadChats
Retrieve Chat History from a Thread in AnythingLLM

 

Intention

 

GetThreadChats Command: Accessing Thread Conversation History
 
The AIN.GetThreadChats command retrieves the chat history from a specific thread within a workspace using the AnythingLLM API. It’s designed to fetch all messages in a thread for review or analysis.

This command is part of the AIN - AnythingLLM AI suite, supporting threaded conversation management within AnythingLLM workspaces.

 

What is the GetThreadChats Command?

 

This command queries the AnythingLLM API to fetch all chat messages associated with a specified thread in a workspace. It returns the chat count and raw response data, which can be stored or retrieved from the stack.

It’s useful for tracking conversation history or integrating thread data into broader workflows.

 

Why Do You Need It?

 

Use AIN.GetThreadChats for:

History Review: Access past messages in a thread for auditing or context.

Automation: Extract thread data for processing or logging in scripts.

Analysis: Analyze conversation patterns within specific threads.

 

How to Use the GetThreadChats Command?

 

Specify the workspace and thread slugs, and optionally provide a variable to store the raw response. The chat count is returned via the stack. Ensure API key and endpoint are set using AIN.SetKey and AIN.SetChatEndpoint beforehand.

 

Illustration

 

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

│ Thread Chats                    │

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

│ Workspace > Thread > [Chats]    │

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

Retrieving all chats from a thread in a workspace.

 

Syntax

 

AIN.GetThreadChats|P1|P2[|P3]

AIN.GTC|P1|P2[|P3]

 

Parameter Explanation

 

P1 - (String) The workspace slug identifying the workspace containing the thread.

P2 - (String) The thread slug identifying the specific thread within the workspace.

P3 - (String, Optional) Variable to store the raw JSON response containing the chat history.

 

Example

 

' Set up API key and endpoint

AIN.SetKey|your_api_key_here

AIN.SetChatEndpoint|http://localhost:3001

' Retrieve chats from a thread

AIN.GetThreadChats|my-workspace|thread-123|$$RES

DBP.Raw Response: $$RES

POP.$$CNT

DBP.Chat Count: $$CNT

ENR.

 

Remarks

 

- Requires a valid API key and endpoint configuration prior to use.

- The chat count is pushed to the stack and can be retrieved with POP.

- Thread must exist; use AIN.CreateThread to create one if needed.

 

Limitations

 

- Parameter count must be 2 or 3; otherwise, an error is set.

- Dependent on the AnythingLLM API’s availability and correct thread/workspace setup.

 

See also:

 

AIN.CreateThread

AIN.ExecuteThreadChat

AIN.DeleteThread

AIN.ExecuteChat

Operations