Skip to content

nex-agi/NexChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NexChat - AI Chat Assistant

English | 简体中文

A feature-rich AI chat assistant built with Streamlit, supporting multiple AI models, role-playing mode, and conversation management.

Features

  • 🤖 Multiple AI Models: Support for various AI models with customizable API endpoints
  • 👤 User Management: User registration and login system with conversation history
  • 🎭 Role-Playing Mode: Engage in immersive role-playing conversations with predefined or custom characters
  • 💬 Normal Chat Mode: Standard AI conversation mode
  • 📊 Conversation Management: Save and manage chat history in SQLite database
  • 👍👎 Message Feedback: Like/dislike feedback system for AI responses
  • ⚙️ Customizable Settings: Adjustable temperature, max tokens, timeout, and retry settings

Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Setup

  1. Clone the repository:
git clone https://github.com/nex-agi/NexChat.git
cd NexChat
  1. Install required dependencies:
pip install -r requirements.txt
  1. Configure your models in config.yml (see Configuration section)

  2. Run the application:

streamlit run app.py

Configuration

The application uses config.yml for configuration. All model settings, API keys, and application preferences are configured in this file.

Configuration Structure

# Application Configuration
app:
  title: "AI Chat Assistant"
  page_icon: "🤖"
  layout: "wide"
  initial_sidebar_state: "expanded"

# UI Configuration
ui:
  show_model_info: true  # Whether to show model information
  show_token_count: true  # Whether to show token count

# Available Models List
models:
  - name: "model-name"
    display_name: "Model Name"
    description: "Model Description"
    api_key: "your-api-key-here"
    base_url: "https://api.example.com/v1"  # Replace with actual base URL

Adding Models

To add a new model, add an entry to the models list in config.yml:

models:
  - name: "your-model-name"
    display_name: "Your Model Display Name"
    description: "Model description"
    api_key: "your-api-key"
    base_url: "https://your-api-endpoint.com/v1"

Usage

Getting Started

  1. Login/Register: Enter your username in the sidebar and click "Login/Register"
  2. Select Model: Choose an AI model from the model selector
  3. Choose Chat Mode:
    • Normal Chat: Standard AI conversation
    • Role-Playing: Engage with predefined or custom characters
  4. Start Chatting: Type your message in the input box and press Enter

Role-Playing Mode

  1. Select "Role-Playing" from the chat mode options
  2. Choose a character from the dropdown or create a custom character
  3. Custom characters can be added with:
    • Character name
    • Character description (background, personality, speaking style, etc.)
  4. Start conversing with your selected character

Features

  • Message Feedback: Click 👍 or 👎 on AI responses to provide feedback
  • Clear Chat: Use the "Clear Chat History" button to start a new conversation
  • Settings Adjustment: Modify temperature, max tokens, timeout, and retry settings in the sidebar
  • Logout: Click "Logout" to save your current conversation and exit

Project Structure

NexChat/
├── app.py              # Main application file
├── config.yml          # Configuration file
├── prompt.md           # Role-playing prompt template
├── char.jsonl          # Predefined character data (JSONL format)
├── chat_data.db        # SQLite database for conversation storage
├── requirements.txt    # Python dependencies
└── README.md           # This file

Database Schema

The application uses SQLite to store:

  • users: User information (id, username, created_at)
  • conversations: Chat messages (id, user_id, session_id, role, content, timestamp, model)
  • message_feedback: User feedback on messages (id, user_id, session_id, message_index, feedback_type, timestamp)

Notes

  • The application automatically creates the SQLite database on first run
  • Character data should be in JSONL format in char.jsonl
  • Role-playing prompts are loaded from prompt.md
  • API keys should be kept secure and not committed to version control
  • Some models may require proxy configuration (see code for specific model handling)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages