๐ Try the demo:
https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/text-generation/conversations/multi_turn_chat_with_chat_history_guidance
Create Multi-Turn Chat with History in .NET
๐ฏ Purpose of the Demo
The Multi-Turn Chat with Chat History Guidance Demo showcases how to use the LM-Kit.NET SDK to create an interactive chatbot that maintains context over multiple interactions by utilizing chat history. This sample demonstrates the integration of large language models (LLMs) into a .NET application to facilitate multi-turn conversations where the chatbot is guided by the entire conversation history.
๐ฅ Industry Target Audience
This sample is particularly beneficial for developers and organizations in the following sectors:
- ๐ Customer Support: Enhance customer service by maintaining context across multiple interactions, improving response relevance and user experience.
- ๐ Education: Develop interactive tutoring systems that remember previous discussions to provide personalized learning experiences.
- ๐ฅ Healthcare: Create virtual assistants that can maintain patient history across conversations, ensuring continuity of care.
- ๐๏ธ E-commerce: Improve customer engagement by creating chatbots that can remember past interactions and provide personalized recommendations.
๐ Problem Solved
Maintaining context over multiple interactions is crucial for creating meaningful and coherent conversations. The Multi-Turn Chat with Chat History Guidance Demo addresses this problem by leveraging chat history to guide the chatbot's responses, ensuring that the conversation remains relevant and contextually aware.
๐ป Sample Application Description
The Multi-Turn Chat with Chat History Guidance Demo is a console application that allows users to interact with a chatbot designed to provide contextually relevant responses using chat history.
โจ Key Features
- ๐ Model Selection: Users can choose from predefined models or provide a custom model URI.
- โณ Progress Tracking: The application displays download and loading progress for the selected model.
- ๐ Chat History Guidance: The chatbot uses the entire conversation history to provide contextually relevant responses.
- ๐ Special Commands: Users can reset the conversation or regenerate responses using special commands.
- ๐ Performance Metrics: Displays generated tokens, stop reasons, quality score, and speed of response for each interaction.
๐ง Supported Models
The sample supports several state-of-the-art models:
- Alibaba Qwen 3.5 9B (~7 GB VRAM)
- Google Gemma 4 E4B (~6 GB VRAM)
- Microsoft Phi-4 14.7B (~11 GB VRAM)
- OpenAI GPT OSS 20B (~16 GB VRAM)
- Z.ai GLM 4.7 Flash 30B (~18 GB VRAM)
- Alibaba Qwen 3.8 27B (~18 GB VRAM)
- Alibaba Qwen 3.6 35B-A3B (~22 GB VRAM)
๐ ๏ธ Special Commands
- /reset: Start a new session and clear the conversation history.
- /regenerate: Get a new completion from the last input.
๐ ๏ธ Getting Started
๐ Prerequisites
- .NET 8.0 or later
๐ฅ Download the Project
โถ๏ธ Running the Application
๐ Clone the repository:
git clone https://github.com/LM-Kit/lm-kit-net-samples๐ Navigate to the project directory:
cd lm-kit-net-samples/console_net/text-generation/conversations/multi_turn_chat_with_chat_history_guidance๐จ Build and run the application:
dotnet build dotnet run๐ Follow the on-screen prompts to select a model and start the multi-turn chat.
๐ก Example Usage
- Select a Model: Choose from the available models or enter a custom model URI.
- Initiate Conversation: Start by entering a prompt, such as "Hello, I'm the user. Please introduce yourself.".
- Receive Contextually Relevant Responses: The chatbot will generate responses based on the entire conversation history.
- Continue Interaction: Enter another prompt or use the special commands to reset the conversation or regenerate responses.
- End the Chat: Submit an empty input to end the program.
By following these steps, developers can explore the functionalities of LM-Kit.NET and integrate advanced conversation history management into their chatbot applications, enhancing the relevance and coherence of automated responses through a multi-turn conversational AI.
๐ Related Content
- How-To: Handle Long Inputs with Overflow Policies: Learn how to manage conversation history when it exceeds the model's context window.
- How-To: Build Conversational Assistant with Memory: Guide to adding persistent memory on top of chat history for richer context.
- Glossary: Context Windows: Understanding how context length and history management affect response quality.
- Glossary: Chat Completion: Core concepts behind multi-turn chat completion with full history guidance.
- Multi-Turn Chat Demo: The foundational multi-turn chat demo without explicit history guidance configuration.