An advanced AI-powered chatbot system. that provides real-time energy grid analysis, weather information etc through an intuitive conversational interface.
- Real-time Energy Grid Analysis - Monitor power demand, voltage readings, and grid status
- Weather Information - Get current weather data for any location worldwide
- Tool-Aware AI - Intelligent tool selection based on user queries
- Streaming Responses - Real-time token streaming for enhanced user experience
- Memory Management - Contextual conversations with session-based memory
taskjs/
├── client/ # Next.js React frontend
├── server/ # Node.js Express backend
└── api_server/ # Data source API server
- Modern React 18 with Next.js 14
- Tailwind CSS for responsive design
- Real-time chat interface with streaming support
- TypeScript for type safety
- Node.js Backend: Express.js with LangChain integration
- Data API: Separate data service for grid information
- LangChain Framework for AI orchestration
- Ollama Integration for local LLM deployment
- Tool Calling with function-based capabilities
- Memory Management for contextual conversations
- Node.js 18+ and npm
- Python 3.10+ (for Python backend as chromadb is used by pip)
- Ollama installed and running
- OpenWeather API key (optional, for weather features)
- Install Ollama from ollama.ai
- Pull the required model:
ollama pull llama3-groq-tool-use:8b # or ollama pull llama3.1:latest - Ensure Ollama is running on port 11434
git clone https://github.com/nafeu-khan/AgentBot.git
cd agentbotCreate .env files in the server/ directory:
cd client
npm installcd server
npm install# Terminal 1: Start the frontend
cd client
npm run dev
# Terminal 2: Start the Node.js backend
cd server
npm run dev
# Terminal 3: Start the data API (optional)
cd api_server
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:5001
- Data API: http://localhost:3001
The AI assistant has access to several specialized tools:
- Retrieves real-time energy grid metrics
- Power demand, voltage readings, grid status
- Usage: "What's the current power demand?"
- Fetches current weather for specified locations
- Requires specific location in the query
- Usage: "What's the weather in London?"
- Provides information
- Company details, services, contact information
- Usage: "Tell me about your company"
The system supports various Ollama models:
llama3-groq-tool-use:8b(recommended for tool calling)llama3.1:latest- Any Ollama-compatible model with tool calling support
POST /api/chat/- Send chat message (streaming response)GET /health- Health check endpoint
GET /api/observability/memory/:sessionId- Get conversation memoryGET /api/observability/system- System metrics
User: "What's the current power demand?"
AI: [Calls getGridData tool and provides real-time metrics]
User: "Show me the latest voltage readings"
AI: [Retrieves and displays voltage data from grid]
User: "What's the weather in Tokyo?"
AI: [Calls getWeather tool with location "Tokyo"]
User: "How's the weather?"
AI: "I need to know which city or location you'd like the weather for."
User: "Tell me about your company"
AI: [Calls getCompanyInfo tool and provides company details]
-
CORS Errors
- Ensure
FRONTEND_URLmatches your client URL - Check that both frontend and backend are running
- Ensure
-
Ollama Connection Issues
- Verify Ollama is running:
ollama serve - Check the
OLLAMA_BASE_URLconfiguration
- Verify Ollama is running:
-
Tool Calling Issues
- Ensure the model supports tool calling
- Check that all required environment variables are set( see env.example)
-
Streaming Not Working
- Check browser network tab for SSE connections