Spaces:
Sleeping
Sleeping
metadata
title: Portfolio Chatbot
emoji: π€
colorFrom: green
colorTo: purple
sdk: docker
pinned: false
Portfolio Chatbot Agent
AI-powered chatbot for the portfolio using OpenAI Agents SDK with Gemini LLM.
Features
- FastAPI backend with async support
- OpenAI Agents SDK for conversational AI
- Gemini 2.0 Flash as the LLM provider
- UV package manager for fast dependency installation
- Docker support for HuggingFace Spaces deployment
- CORS enabled for frontend integration
Setup (Local Development)
1. Install UV Package Manager
# Linux/macOS
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
2. Create Virtual Environment & Install Dependencies
# Create virtual environment
uv venv .venv
# Activate virtual environment
# Linux/macOS:
source .venv/bin/activate
# Windows:
.venv\Scripts\activate
# Install dependencies with UV
uv pip install -r requirements.txt
3. Configure Environment
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY
Get your Gemini API key from: https://aistudio.google.com/app/apikey
4. Run Locally
uvicorn main:app --reload --port 7860
Or:
python main.py
API Endpoints
GET /- Health checkGET /health- Health check for monitoringPOST /chat- Chat endpointGET /info- Get portfolio owner info
Chat Request Example
POST /chat
{
"message": "Tell me about your projects",
"history": []
}
Chat Response
{
"response": "I have worked on several exciting projects...",
"success": true
}
Deploy to HuggingFace Spaces
- Create a new Space on HuggingFace (Docker type)
- Upload all files from this directory
- Add
GEMINI_API_KEYas a secret in Space settings - The Space will automatically build and deploy
HuggingFace Spaces Settings
- Space hardware: CPU Basic (free tier works)
- Space type: Docker
- Secrets: Add
GEMINI_API_KEY
Frontend Integration
Update your frontend .env file:
NEXT_PUBLIC_CHATBOT_API_URL=https://your-username-your-space.hf.space/chat
File Structure
chatbot-agent/
βββ main.py # FastAPI application
βββ agent.py # Portfolio chatbot agent
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration (uses UV)
βββ .env.example # Environment template
βββ .gitignore # Git ignore rules
βββ README.md # This file
Tech Stack
- Framework: FastAPI
- AI SDK: OpenAI Agents SDK
- LLM: Google Gemini 2.0 Flash
- Package Manager: UV (fast Python package installer)
- Deployment: Docker / HuggingFace Spaces