Create Multi-Turn Chat with History in .NET
🎯 Purpose of the Sample
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:
- Mistral Nemo 2407 12.2B
- Meta Llama 3.1 8B
- Google Gemma2 9B Medium
- Microsoft Phi-3 3.82B Mini
- Alibaba Qwen-2 7.6B
🛠️ 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 Framework 4.6.2 or .NET 6.0
📥 Download the Project
▶️ Running the Application
📂 Clone the repository:
git clone https://github.com/LM-Kit/lm-kit-net-samples.git
📁 Navigate to the project directory:
cd lm-kit-net-samples/console_framework_4.62/multi_turn_chat_with_chat_history_guidance
or
cd lm-kit-net-samples/console_net6/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.