Skip to content

A clean, simple AI assistant built with TypeScript that supports conversation memory and tool calling.

Notifications You must be signed in to change notification settings

floroz/build-agent-openai

Repository files navigation

🤖 AI Assistant - Simple & Functional

A clean, simple AI assistant built with TypeScript that supports conversation memory and tool calling.

✨ Features

  • 🧠 Conversation Memory - Remembers your chat history across sessions
  • 🛠️ Tool Calling - Can perform calculations, get time, generate UUIDs
  • 🎨 Multiple Assistant Types - General, Coding, or Creative focused
  • 🔒 Secure System Prompts - Built-in protection against prompt injection
  • 💬 Beautiful CLI - Powered by @clack/prompts

🚀 Quick Start

  1. Set up your OpenAI API key:

    Create a .env file in the root directory and add your OpenAI API key:

    OPENAI_API_KEY=your_openai_api_key_here
  2. Install and run:

    npm install
    npm start

📁 Simple Architecture

src/
├── agent.ts         # Core agent logic (simple functions)
├── llm.ts          # OpenAI integration (async/await)
├── memory.ts       # Conversation persistence
├── systemPrompt.ts # Security & personality
├── tools.ts        # Built-in tools (time, math, uuid)
└── ai.ts           # OpenAI client

types.ts            # Basic type definitions
index.ts            # CLI interface

🛠️ Built-in Tools

  • get_current_time - Get current time in any timezone
  • calculate - Perform mathematical calculations
  • generate_uuid - Generate random UUIDs

🧪 Example Usage

🤖 AI Assistant - Chat Mode

What type of assistant would you like?
❯ 🤖 General Assistant

What would you like to talk about?
❯ What time is it in Tokyo?

🧠 AI is thinking...

💬 AI Response:

🔧 Using tools...

✅ get_current_time: Current time in Asia/Tokyo: Wednesday, August 11, 2025 at 6:30:45 PM Japan Standard Time

💬 AI Follow-up:

The current time in Tokyo is Wednesday, August 11, 2025 at 6:30:45 PM Japan Standard Time.

🔧 Adding Custom Tools

Simply add your tool to the tools array in src/tools.ts:

{
  type: 'function' as const,
  function: {
    name: 'your_tool',
    description: 'What your tool does',
    parameters: {
      type: 'object',
      properties: {
        // Your parameters here
      },
    },
  },
}

Then add the execution logic in the executeToolCall function.

About

A clean, simple AI assistant built with TypeScript that supports conversation memory and tool calling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published