A customizable AI chatbot assistant built with Next.js, featuring web search capabilities, vector database integration, and content moderation. This repository provides a complete foundation for deploying your own AI assistant with minimal technical knowledge required.
MyAI3 is an AI-powered chatbot that can:
- Answer questions using advanced language models
- Search the web for up-to-date information
- Search a vector database (Pinecone) for stored knowledge
- Moderate content to ensure safe interactions
- Provide citations and sources for its responses
The application is designed to be easily customizable without deep technical expertise. Most changes you'll want to make can be done in just two files: config.ts and prompts.ts.
This application is deployed on Vercel. After making changes to config.ts or prompts.ts, commit and push your changes to trigger a new deployment.
This is the primary file you'll edit to customize your AI assistant. Located in the root directory, it contains:
- AI Identity:
AI_NAMEandOWNER_NAME- Change these to personalize your assistant - Welcome Message:
WELCOME_MESSAGE- The greeting users see when they first open the chat - UI Text:
CLEAR_CHAT_TEXT- The label for the "New Chat" button - Moderation Messages: Custom messages shown when content is flagged (sexual content, harassment, hate speech, violence, self-harm, illegal activities)
- Model Configuration:
MODEL- The AI model being used (currently set to OpenAI's GPT-5-mini) - Vector Database Settings:
PINECONE_TOP_KandPINECONE_INDEX_NAME- Settings for your knowledge base search
Example customization:
export const AI_NAME = "Your Assistant Name";
export const OWNER_NAME = "Your Name";
export const WELCOME_MESSAGE = `Hello! I'm ${AI_NAME}, ready to help you.`;This file controls how your AI assistant behaves and responds. Located in the root directory, it contains:
- Identity Prompt: Who the AI is and who created it
- Tool Calling Prompt: Instructions for when to search the web or database
- Tone & Style: How the AI should communicate (friendly, helpful, educational)
- Guardrails: What the AI should refuse to discuss
- Citation Rules: How to cite sources in responses
- Course Context: Domain-specific instructions (currently mentions course syllabus)
The prompts are modular, so you can edit individual sections without affecting others. The SYSTEM_PROMPT combines all these sections.
Example customization:
export const TONE_STYLE_PROMPT = `
- Maintain a professional, business-focused tone.
- Use clear, concise language suitable for executives.
- Provide actionable insights and recommendations.
`;myAI3/
├── app/ # Next.js application files
│ ├── api/chat/ # Chat API endpoint
│ │ ├── route.ts # Main chat handler
│ │ └── tools/ # AI tools (web search, vector search)
│ ├── page.tsx # Main chat interface (UI)
│ ├── parts/ # UI components
│ └── terms/ # Terms of Use page
├── components/ # React components
│ ├── ai-elements/ # AI-specific UI components
│ ├── messages/ # Message display components
│ └── ui/ # Reusable UI components
├── lib/ # Utility libraries
│ ├── moderation.ts # Content moderation logic
│ ├── pinecone.ts # Vector database integration
│ ├── sources.ts # Source/citation handling
│ └── utils.ts # General utilities
├── types/ # TypeScript type definitions
├── config.ts # ⭐ MAIN CONFIGURATION FILE
├── prompts.ts # ⭐ AI BEHAVIOR CONFIGURATION
└── package.json # Dependencies and scripts
-
app/api/chat/route.ts: The main API endpoint that handles chat requests. It processes messages, checks moderation, and calls the AI model with tools. -
app/page.tsx: The main user interface. This is what users see and interact with. It handles the chat interface, message display, and user input. -
app/api/chat/tools/web-search.ts: Enables the AI to search the web using Exa API. You can modify search parameters here (currently returns 3 results). -
app/api/chat/tools/search-vector-database.ts: Enables the AI to search your Pinecone vector database for stored knowledge.
components/messages/message-wall.tsx: Displays the conversation historycomponents/messages/assistant-message.tsx: Renders AI responses, including tool calls and reasoningcomponents/messages/tool-call.tsx: Shows when the AI is using tools (searching web, etc.)components/ai-elements/response.tsx: Formats and displays AI text responses with markdown support
-
lib/moderation.ts: Handles content moderation using OpenAI's moderation API. Checks user messages for inappropriate content before processing. -
lib/pinecone.ts: Manages connections to Pinecone vector database. Handles searching your knowledge base. -
lib/sources.ts: Processes search results and formats them for the AI, including citation handling.
-
env.template: Template for environment variables. These need to be configured in your Vercel project settings. -
app/terms/page.tsx: Terms of Use page. UsesOWNER_NAMEfromconfig.ts. Update this file if you need to modify legal terms.
Configure environment variables in your Vercel project settings (Settings → Environment Variables). Add the following:
OPENAI_API_KEY- Required for AI model and moderationEXA_API_KEY- Optional, for web search functionalityPINECONE_API_KEY- Optional, for vector database search
Where to get API keys:
- OpenAI: https://platform.openai.com/api-keys (required)
- Exa: https://dashboard.exa.ai/ (optional)
- Pinecone: https://app.pinecone.io/ (optional)
Note: Only OPENAI_API_KEY is strictly required. The others enable additional features.
- Open
config.ts - Modify
AI_NAMEandOWNER_NAME - Update
WELCOME_MESSAGEif desired - Commit and push changes to trigger a new Vercel deployment
- Open
prompts.ts - Edit the relevant prompt section:
TONE_STYLE_PROMPT- Change communication styleGUARDRAILS_PROMPT- Modify safety rulesTOOL_CALLING_PROMPT- Adjust when tools are usedCITATIONS_PROMPT- Change citation format
- Commit and push changes to trigger a new Vercel deployment
- Open
config.ts - Find the
MODERATION_DENIAL_MESSAGE_*constants - Update the messages to match your brand voice
- These messages appear when content is flagged
- Open
config.ts - Modify the
MODELexport (line 4) - Available models depend on your AI SDK provider
- Update API keys in
.env.localif switching providers
Tools are located in app/api/chat/tools/. To add a new tool:
- Create a new file in
app/api/chat/tools/ - Import and add it to
app/api/chat/route.tsin thetoolsobject - Add UI display logic in
components/messages/tool-call.tsx - See
AGENTS.mdfor more technical details
The application follows a simple request-response flow:
- User sends message →
app/page.tsx(UI) - Message sent to API →
app/api/chat/route.ts - Content moderation check →
lib/moderation.ts - AI processes with tools → Model uses web search and/or vector search as needed
- Response streamed back → UI displays response in real-time
The AI can autonomously decide to:
- Answer directly
- Search the web for current information
- Search your vector database for stored knowledge
- Combine multiple sources
All responses include citations when sources are used.
- Verify
OPENAI_API_KEYis set correctly in Vercel environment variables - Check browser console for error messages
- Ensure the API key has sufficient credits/quota
- Check Vercel deployment logs for errors
- Verify
EXA_API_KEYis set in Vercel environment variables - Check Exa API dashboard for usage limits
- Tool will gracefully fail if API key is missing
- Verify
PINECONE_API_KEYis set in Vercel environment variables - Check that
PINECONE_INDEX_NAMEinconfig.tsmatches your Pinecone index - Ensure your Pinecone index exists and has data
- Check Vercel deployment logs for build errors
- Verify all environment variables are set in Vercel project settings
- Ensure your Vercel project is connected to the correct Git repository
-
Customize branding: Update
config.tswith your name and AI assistant name -
Adjust prompts: Modify
prompts.tsto match your use case and tone -
Set up knowledge base: Configure Pinecone and upload your documents
-
Test moderation: Verify moderation messages match your needs
-
Deploy: Build and deploy to your hosting platform (Vercel, AWS, etc.)
For technical questions about tool integration, see AGENTS.md.
For deployment issues, check the Vercel deployment logs and browser console for error messages.
Remember: Most customization happens in config.ts and prompts.ts. Start there!