Chat Threads

Comprehensive guide to managing chat threads in the View Assistant platform for persistent conversations and context management.

Overview

Chat threads provide comprehensive conversation management capabilities within the View Assistant platform. They enable persistent conversations with context preservation, message history, and thread-based organization for enhanced user experiences and AI-powered interactions.

Chat thread operations are accessible via the View Assistant API at [http|https]://[hostname]:[port]/v1.0/tenants/[tenant-guid]/assistant/threads and support full CRUD operations for thread management.

API Endpoints

  • GET /v1.0/tenants/[tenant-guid]/assistant/threads - Retrieve all chat threads
  • POST /v1.0/tenants/[tenant-guid]/assistant/threads - Create new chat thread
  • GET /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid] - Retrieve specific chat thread
  • PUT /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid] - Update chat thread
  • DELETE /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid] - Delete chat thread
  • HEAD /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid] - Check thread existence

Chat Thread Object Structure

{
    "GUID": "7a359942-62f4-497b-a9af-af7e47d41ce5",
    "Title": "Test Chat Thread",
    "Description": "A test chat thread for development",
    "MessageCount": 1,
    "CreatedUTC": "2025-04-25T09:24:37.587540",
    "LastModifiedUTC": "2025-04-25T09:24:37.587540",
    "AssistantConfigGUID": "12345678-1234-5678-1234-567812345678"
}

Field Descriptions

  • GUID (string): Unique identifier for the chat thread
  • Title (string): Title of the chat thread
  • Description (string): Brief description of the chat thread
  • MessageCount (number): Number of messages in the thread
  • CreatedUTC (datetime): Timestamp when the thread was created, in UTC
  • LastModifiedUTC (datetime): Timestamp of the last modification, in UTC
  • AssistantConfigGUID (string): GUID of the assistant configuration used for this chat thread

Create Chat Thread

Creates a new chat thread using POST /v1.0/tenants/[tenant-guid]/assistant/threads. Establishes a new conversation thread with initial messages and metadata for persistent conversation management.

Request Parameters

Required Parameters

  • Title (string, Body, Required): Title of the chat thread
  • AssistantConfigGUID (string, Body, Required): GUID of the assistant configuration to use for this thread
curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/threads' \
--header 'Content-Type: application/json' \
--data '{
  "Title": "Test Chat Thread",
  "Description": "A test chat thread for development",
  "Messages": [
    {
        "role": "user",
        "content": "What is the capital of France?",
        "metadata": {
            "source": "web interface",
            "client_timestamp": "2024-02-17T10:30:00Z"
        }
    }
  ],
  "AssistantConfigGUID": "12345678-1234-5678-1234-567812345678",
  "Metadata": {
    "tags": ["test", "development"],
    "category": "testing"
  }
}'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "<tenant-guid>", //tenant Id
  "default" //access key
);

const createChatThread = async () => {
  try {
    const response = await api.ChatThread.create({
      Title: "Test Chat Thread [ASHISH]",
      Description: "A test chat thread for development",
      Messages: [
        {
          role: "user",
          content: "What is the capital of France?",
          metadata: {
            source: "web interface",
            client_timestamp: "2024-02-17T10:30:00Z",
          },
        },
      ],
      AssistantConfigGUID: "<config-guid>",
      Metadata: {
        tags: ["test", "development"],
        category: "testing",
      },
    });
    console.log(response);
  } catch (err) {
    console.log("Error creating chat thread:", err);
  }
};

createChatThread();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost", 
    tenant_guid="tenant-guid",
    service_ports={Service.ASSISTANT: 8000},
)

def createChatThread():
    result = assistant.ChatThread.create(
        Title= "Test Chat Thread",
        Description= "A test chat thread for development",
        Messages= [
                    {
                "role": "user",
                "content": "What is the capital of France?",
                "metadata": {
                    "source": "web interface",
                    "client_timestamp": "2024-02-17T10:30:00Z"
                }
            }
        ],
        AssistantConfigGUID= "<config-guid>",
        Metadata= {
            "tags": ["test", "development"],
            "category": "testing"
        }
    )
    print(result)

createChatThread()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");
ChatThread thread = new ChatThread
{
    Title = "Test Chat Thread",
    Description = "A test chat thread for development",
    AssistantConfigGUID = Guid.Parse("12345678-1234-5678-1234-567812345678"),
    Messages = new List<ChatMessage>
    {
        new ChatMessage
        {
            Role = "user",
            Content = "What is the capital of France?",
            Metadata = new Dictionary<string, object>
            {
                ["source"] = "web interface",
                ["client_timestamp"] = "2024-02-17T10:30:00Z"
            }
        }
    },
    Metadata = new Dictionary<string, object>
    {
        ["tags"] = new List<string> { "test", "development" },
        ["category"] = "testing"
    }
};
ChatThread response = await sdk.Thread.Create(thread);

Read

To read chat thread by GUID, call GET /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid]

ccurl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/threads/f62f8117-d0ec-45d0-af7a-db6a62898ecd'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "<tenant-guid>", //tenant Id
  "default" //access key
);

const readChatThread = async () => {
  try {
    const response = await api.ChatThread.read(
      "<thread-guid>"
    );
    console.log(response);
  } catch (err) {
    console.log("Error reading chat thread:", err);
  }
};
readChatThread();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost", 
    tenant_guid="tenant-guid",
    service_ports={Service.ASSISTANT: 8000},
)

def readChatThread():
    result = assistant.ChatThread.retrieve("<thread-guid>")
    print(result)

readChatThread()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");

ChatThread response = await sdk.Thread.Create(Guid.Parse("<thread-guid>"));

Read all

To read al threads, call GET /v1.0/tenants/[tenant-guid]/assistant/threads

curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/threads'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "<tenant-guid>", //tenant Id
  "default" //access key
);

const readAllChatThreads = async () => {
  try {
    const response = await api.ChatThread.readAll();
    console.log(response);
  } catch (err) {
    console.log("Error reading all chat threads:", err);
  }
};

readAllChatThreads();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost", 
    tenant_guid="tenant-guid",
    service_ports={Service.ASSISTANT: 8000},
)

def readAllChatThreads():
    result = assistant.ChatThread.retrieve_all()
    print(result)

readAllChatThreads()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");

ChatThread response = await sdk.Thread.RetrieveMany();

Response

{
    "ChatThreads": [
        {
            "GUID": "4a421edb-a439-4ca2-a6de-08d14dc89d12",
            "Title": "Test Chat Thread [ASHISH]",
            "Description": "A test chat thread for development",
            "MessageCount": 1,
            "CreatedUTC": "2025-04-25T09:28:01.811483Z",
            "LastModifiedUTC": "2025-04-25T09:28:01.811483Z",
            "AssistantConfigGUID": "12345678-1234-5678-1234-567812345678"
        },
        {
            "GUID": "7a359942-62f4-497b-a9af-af7e47d41ce5",
            "Title": "Test Chat Thread",
            "Description": "A test chat thread for development",
            "MessageCount": 1,
            "CreatedUTC": "2025-04-25T09:24:37.657950Z",
            "LastModifiedUTC": "2025-04-25T09:24:37.657950Z",
            "AssistantConfigGUID": "12345678-1234-5678-1234-567812345678"
        }
    ]
}

Append chat threaad

To append a thread by GUID, call PUT /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid]

curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/threads/00000000-0000-0000-0000-000000000000/messages' \
--header 'Content-Type: application/json' \
--data '{
  "role": "assistant",
  "content": "The capital of France is Paris.",
  "metadata": {
    "source_documents": [
      {
        "content": "Paris is the capital and largest city of France.",
        "similarity": 0.89
      }
    ],
    "generation_metrics": {
      "tokens": 8,
      "generation_time": 0.5
    }
  }
}'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "<tenant-guid>", //tenant Id
  "default" //access key
);

const appendChatThread = async () => {
  try {
    const response = await api.ChatThread.append(
      "<thread-guid>",
      {
        role: "assistant",
        content: "The capital of France is Paris.",
        metadata: {
          source_documents: [
            {
              content: "Paris is the capital and largest city of France.",
              similarity: 0.89,
            },
          ],
          generation_metrics: {
            tokens: 8,
            generation_time: 0.5,
          },
        },
      }
    );
    console.log(response);
  } catch (err) {
    console.log("Error updating chat thread:", err);
  }
};

appendChatThread();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost", 
    tenant_guid="tenant-guid",
    service_ports={Service.ASSISTANT: 8000},
)

def appendChatThread():
    result = assistant.ChatThread.append("<thread-guid>",
       role= "assistant",
       content= "The capital of France is Paris.",
       metadata= {
        "source_documents": [
        {
            "content": "Paris is the capital and largest city of France.",
            "similarity": 0.89
        }
        ],
        "generation_metrics": {
        "tokens": 8,
        "generation_time": 0.5
        }
    }
    )
    print(result)

appendChatThread()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");

ChatMessage message = new ChatMessage
{
    Role = "assistant",
    Content = "The capital of France is Paris.",
    Metadata = new Dictionary<string, object>
    {
        ["source_documents"] = new List<Dictionary<string, object>>
        {
            new Dictionary<string, object>
            {
                ["content"] = "Paris is the capital and largest city of France.",
                ["similarity"] = 0.89 // double
            }
        },
        ["generation_metrics"] = new Dictionary<string, object>
        {
            ["tokens"] = 8,
            ["generation_time"] = 0.5 // seconds
        }
    }
};

ChatThread response = await sdk.Thread.Append(Guid.Parse("<thread-guid>"), message);

Delete

To read thread by GUID, call DELETE /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid]

curl --location --request DELETE 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/threads/00000000-0000-0000-0000-000000000000'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "<tenant-guid>", //tenant Id
  "default" //access key
);

const deleteChatThread = async () => {
  try {
    const response = await api.ChatThread.delete(
      "<thread-guid>"
    );
    console.log(response);
  } catch (err) {
    console.log("Error deleting chat thread:", err);
  }
};
deleteChatThread();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost", 
    tenant_guid="tenant-guid",
    service_ports={Service.ASSISTANT: 8000},
)

def deleteChatThread():
    result = assistant.ChatThread.delete("<thread-guid>")
    print(result)

deleteChatThread()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");

bool deleted = await sdk.Thread.Delete(Guid.Parse("<thread-guid>"));

Check existence

To check existence of a thread by GUID, call HEAD /v1.0/tenants/[tenant-guid]/assistant/threads/[thread-guid]

curl --location --head 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/threads/f62f8117-d0ec-45d0-af7a-db6a62898ecd'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "<tenant-guid>", //tenant Id
  "default" //access key
);

const existingChatThread = async () => {
  try {
    const response = await api.ChatThread.exists("<thread-guid>");
    console.log(response);
  } catch (err) {
    console.log("Error retrieving chat thread:", err);
  }
};
existingChatThread();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost", 
    tenant_guid="tenant-guid",
    service_ports={Service.ASSISTANT: 8000},
)

def existsChatThread():
    result = assistant.ChatThread.exists("<thread-guid>")
    print(result)

existsChatThread()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");

bool exists = await sdk.Thread.Exists(Guid.Parse("<thread-guid>"));

Best Practices

When managing chat threads in the View Assistant platform, consider the following recommendations for optimal conversation management, context preservation, and thread organization:

  • Thread Organization: Implement effective thread organization strategies using titles, descriptions, and metadata for easy conversation management
  • Context Preservation: Leverage chat threads for persistent context preservation across conversation sessions
  • Message Management: Implement appropriate message management strategies for thread performance and storage optimization
  • Assistant Configuration: Use appropriate assistant configurations for different thread types and conversation scenarios
  • Thread Lifecycle: Implement proper thread lifecycle management including creation, updates, and cleanup

Next Steps

After successfully managing chat threads, you can:

  • Assistant Configuration: Create and manage assistant configurations for specialized chat behaviors and conversation settings
  • Chat Integration: Integrate chat thread functionality with your applications for enhanced user experiences and persistent conversations
  • Context Management: Implement advanced context management strategies using thread-based conversation organization
  • Message Processing: Implement message processing and analysis capabilities for enhanced conversation insights
  • Thread Analytics: Develop thread analytics and conversation insights for improved user experiences and assistant performance