- Chat interface with AI Paul Graham
- Trained on PG's essays for authentic responses
- Real-time streaming responses
- Modern, responsive UI built with Next.js and Tailwind CSS
- Vector-based semantic search through PG's essays
- Server-sent events for smooth chat experience
- Node.js (v18 or higher)
- npm or yarn
- A Vercel KV database instance
- An OpenAI API key
- Clone the repository:
git clone https://github.com/yourusername/ask-pg.git
cd ask-pg
- Install dependencies:
npm install
# or
yarn install
- Set up environment variables by creating a
.env
file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
KV_URL=your_vercel_kv_url_here
KV_REST_API_READ_ONLY_TOKEN=your_kv_readonly_token_here
KV_REST_API_URL=your_kv_rest_api_url_here
-
Set up the vector store by going to OpenAI's vector store page and creating a new vector store, and uploading the essays in /public/essays. Then, get the vector store ID and update the
vectorStoreId
inconfig/ai.ts
. -
Run the development server:
npm run dev
# or
yarn dev
- Open http://localhost:3000 in your browser to start chatting!
The config/ai.ts
file contains important settings for the AI chat functionality:
model
: Specifies the OpenAI model to use (default: "gpt-4o-mini")defaultSystemPrompt
: The system prompt that defines PG's personality and behaviorfileSearch
: Configuration for the vector store searchvectorStoreId
: ID for the vector store containing PG's essaysmaxResults
: Maximum number of essay results to return per search
storeResponse
: Whether to store generated responses for later retrieval
OPENAI_API_KEY
: Your OpenAI API key for accessing the GPT modelsKV_URL
: Vercel KV database URL for storing chat dataKV_REST_API_READ_ONLY_TOKEN
: Read-only token for KV REST API accessKV_REST_API_URL
: URL for the KV REST API endpoint
Before the application can function properly, you'll need to:
- Upload Paul Graham's essays to OpenAI's vector storage
- Get your vector store ID from OpenAI
- Update the
vectorStoreId
inconfig/ai.ts
with your vector store ID
Without this setup, the semantic search functionality that helps the AI reference PG's essays will not work.
- Next.js - React framework
- Tailwind CSS - Utility-first CSS
- OpenAI API - AI model integration
- Vercel KV - Key-value storage
- Radix UI - Headless UI components
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
If you find this project helpful, please consider giving it a star on GitHub!