Skip to content

saaragh/agent-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Assistant UI

A modern React-based chat interface for interacting with an AI assistant. This application provides a clean, responsive UI for chatting with an AI assistant that supports both streaming and non-streaming responses, interactive charts, and a professional dark theme.

✨ Features

  • 🎯 Real-time Streaming Chat: Experience live responses as the AI generates them
  • πŸ“Š Interactive Charts: Automatically renders charts and graphs from AI responses
  • πŸ’¬ Multi-line Input: Auto-resizing textarea with support for multiple lines
  • πŸ”„ Auto-focus Input: Automatically focuses input after AI responses for seamless conversation flow
  • πŸ“± Responsive Design: Works seamlessly on desktop and mobile devices
  • πŸŒ™ Dark Theme: Professional dark theme with dark grey accents
  • πŸ“‹ Left Navigation: Dashboard and Assistant sections with clean navigation
  • πŸ’Ύ Conversation History: View and maintain chat history across sessions
  • πŸ”— Connection Status: Visual indicator showing server connection status
  • ⚠️ Error Handling: Graceful error handling with user-friendly messages
  • 🎨 Modern UI: Clean, accessible interface with smooth animations

πŸš€ Quick Start

Prerequisites

  • Node.js (version 14 or higher)
  • The AI Assistant API server running on localhost:5000

Installation

  1. Clone the repository (if not already done)

  2. Install dependencies:

    npm install

    This will install all required dependencies including:

    • React and React DOM
    • Chart.js and react-chartjs-2 for interactive charts
    • React Scripts for development
  3. Start the development server:

    npm start
  4. Open your browser at http://localhost:3000

πŸ”Œ API Integration

This UI connects to the AI Assistant API running on localhost:5000. The following endpoints are used:

Endpoint Method Description
/health GET Health check
/api/chat/stream POST Streaming chat responses
/api/chat POST Non-streaming chat responses
/api/history GET Get conversation history
/api/clear POST Clear conversation history

πŸ“– Usage Guide

Basic Chat

  1. Navigate to Assistant: Click "Assistant" in the left menu
  2. Type your message: Use the multi-line input field
  3. Send message: Press Enter or click the send button
  4. View responses: AI responses appear in real-time with typing indicators

Interactive Charts

The application automatically detects and renders charts when the AI includes chart data in its responses.

Supported Chart Types:

  • Line Charts: For trends and time series data
  • Bar Charts: For comparisons and categorical data
  • Doughnut Charts: For proportions and percentages

Chart Data Format: The AI should return data in this format:

{
  "type": "chart",
  "chartType": "line",
  "chartData": {
    "title": "Sales Performance",
    "labels": ["Jan", "Feb", "Mar", "Apr", "May"],
    "datasets": [{
      "label": "Sales",
      "data": [12, 19, 3, 5, 2],
      "borderColor": "rgb(75, 192, 192)",
      "backgroundColor": "rgba(75, 192, 192, 0.2)"
    }]
  }
}

Navigation

  • Dashboard: Overview page with quick actions and recent activity
  • Assistant: Main chat interface for AI conversations

πŸ› οΈ Development

Project Structure

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ LeftMenu.js              # Navigation sidebar
β”‚   β”œβ”€β”€ LeftMenu.css             # Sidebar styles
β”‚   β”œβ”€β”€ Dashboard.js             # Dashboard component
β”‚   β”œβ”€β”€ Dashboard.css            # Dashboard styles
β”‚   β”œβ”€β”€ ChatInterface.js         # Main chat component
β”‚   β”œβ”€β”€ ChatInterface.css        # Chat interface styles
β”‚   β”œβ”€β”€ MessageList.js           # Message display component
β”‚   β”œβ”€β”€ MessageList.css          # Message list styles
β”‚   β”œβ”€β”€ MessageInput.js          # Input component
β”‚   β”œβ”€β”€ MessageInput.css         # Input styles
β”‚   β”œβ”€β”€ ChartMessage.js          # Chart rendering component
β”‚   └── ChartMessage.css         # Chart styles
β”œβ”€β”€ services/
β”‚   └── apiService.js            # API integration service
β”œβ”€β”€ utils/
β”‚   └── chartUtils.js            # Chart data processing utilities
β”œβ”€β”€ App.js                       # Main app component
β”œβ”€β”€ App.css                      # Global styles
└── index.js                     # Application entry point

Available Scripts

  • npm start - Runs the app in development mode
  • npm build - Builds the app for production
  • npm test - Launches the test runner
  • npm eject - Ejects from Create React App (one-way operation)

🎨 Design System

Color Scheme

  • Background: #1a1a1a (dark gray/black)
  • Secondary Background: #2a2a2a (lighter dark gray)
  • Accent Color: #4b5563 (dark grey)
  • Text: #e5e5e5 (light gray/white)
  • Borders: #404040 (medium gray)

Typography

  • Font Family: System fonts (San Francisco, Segoe UI, etc.)
  • Font Weights: 400 (normal), 500 (medium), 600 (semibold)

Components

  • Left Menu: Fixed sidebar with navigation items
  • Message Bubbles: User messages (dark grey), Assistant messages (dark background)
  • Charts: Dark theme compatible with professional styling
  • Input Field: Auto-resizing textarea with send button

πŸ”§ Key Features Explained

Streaming Responses

  • Uses Server-Sent Events (SSE) for real-time communication
  • Shows typing indicators and streaming cursor
  • Automatically scrolls to new messages

Auto-focus Input

  • Automatically focuses the input field after AI responses
  • Enables seamless conversation flow without clicking
  • 100ms delay ensures UI stability

Multi-line Input

  • Auto-resizing textarea that grows with content
  • Enter to send, Shift+Enter for new lines
  • Maximum height with scrolling for very long messages

Error Handling

  • Comprehensive error logging to browser console
  • User-friendly error messages in the UI
  • Connection status indicators
  • Graceful fallbacks for API failures

🌐 Browser Support

This application works in all modern browsers including:

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

πŸ“± Responsive Design

  • Desktop: Full sidebar with 250px width
  • Tablet: Reduced sidebar to 200px width
  • Mobile: Sidebar becomes horizontal at top
  • Charts: Responsive and touch-friendly

🚨 Troubleshooting

Common Issues

  1. Connection Error: Ensure the API server is running on localhost:5000
  2. Charts Not Rendering: Check that chart data follows the correct JSON format
  3. Styling Issues: Clear browser cache and restart the development server

Debug Mode

  • Open browser Developer Tools (F12)
  • Check the Console tab for detailed error logs
  • Network tab shows API request/response details

πŸ“„ License

This project is open source and available under the MIT License.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“ž Support

For issues and questions:

  1. Check the troubleshooting section
  2. Review the browser console for errors
  3. Ensure the API server is running and accessible
  4. Verify all dependencies are installed correctly

About

This is an UI application for Agents and AI Assistants.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors