Skip to content

AI Agent application with React UI, Node.js services, and integrated tools for currency conversion, weather data, news retrieval, and JavaScript execution.

Notifications You must be signed in to change notification settings

ammar1zahid/AI-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

AI Agent Project

A full-stack AI agent application with a React frontend and Node.js backend services. The project includes an intelligent agent with various tools (currency conversion, weather, news) and a separate code execution service.

🏗️ Project Structure

AIAgent/
├── client/                 # React frontend application
│   ├── src/
│   ├── public/
│   ├── package.json
│   └── vite.config.ts
└── server/
    ├── agent/             # AI agent service with tools
    │   ├── agent.js
    │   ├── demo/          # Demo scripts
    │   ├── tools/         # Agent tools (currency, weather, news)
    │   └── package.json
    └── executor/          # Code execution service
        ├── index.js
        └── package.json

🚀 Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd AIAgent
  2. Install dependencies for all services

    Client (React app):

    cd client
    npm install

    Agent service:

    cd server/agent
    npm install

    Executor service:

    cd server/executor
    npm install
  3. Environment Setup

    Create a .env file in the server/agent directory with your required environment variables:

    cd server/agent
    touch .env

    Add your API keys and configuration variables to the .env file.

🏃‍♂️ Running the Application

1. Start the Executor Service

cd server/executor
node index.js

✅ Server will be running on port 3000

2. Start the Agent Service

cd server/agent
node --env-file=.env index.js

✅ Server will be running on port 3001

3. Start the Client Application

cd client
npm run dev

✅ Frontend will be available at the URL shown in terminal (typically http://localhost:5173)

🧪 Testing the Backend

You can test the AI agent service using curl:

curl -X POST http://localhost:3001/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt":"convert 5 USD to PKR","thread_id":123}'

Example API Calls

Currency Conversion:

curl -X POST http://localhost:3001/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt":"convert 100 EUR to USD","thread_id":456}'

Weather Information:

curl -X POST http://localhost:3001/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt":"What is the weather like in New York?","thread_id":789}'

🛠️ Available Tools

The AI agent comes with several built-in tools:

  • 🔄 Currency Tool (currencyTool.js) - Real-time currency conversion
  • 🌤️ Weather Tool (weatherTool.js) - Weather information and forecasts
  • 📰 News Tool (newsTool.js) - Latest news and updates
  • ⚡ JavaScript Executor (jsExecutor.js) - Execute JavaScript code safely

📁 Key Components

  • server/agent/agent.js - Main AI agent logic and tool integration
  • server/agent/index.js - Agent service server and API endpoints
  • server/executor/index.js - Code execution service
  • client/src/App.tsx - Main React application component

🔧 Development

Demo Scripts

The project includes demo scripts in server/agent/demo/:

  • basicLLM.js - Basic language model interaction
  • addingTools.js - Tool integration examples
  • addingMemory.js - Memory management examples

Run demos:

cd server/agent
node demo/basicLLM.js

API Endpoints

Agent Service (Port 3001):

  • POST /generate - Generate AI responses with tool usage

Executor Service (Port 3000):

  • Available for code execution requests

🚨 Troubleshooting

  1. Port conflicts: Make sure ports 3000, 3001, and 5173 are available
  2. Environment variables: Ensure all required API keys are set in .env
  3. Dependencies: Run npm install in each service directory if modules are missing
  4. CORS issues: Check that the frontend URL is allowed in backend CORS settings

📝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy coding! 🎉

About

AI Agent application with React UI, Node.js services, and integrated tools for currency conversion, weather data, news retrieval, and JavaScript execution.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published