| title | Personal Website Backend |
|---|---|
| emoji | 🌐 |
| colorFrom | blue |
| colorTo | indigo |
| sdk | docker |
| pinned | false |
This is the backend service for my personal website, implementing a Retrieval-Augmented Generation (RAG) agent that processes queries about my professional background and experience.
- RAG system for retrieving relevant information from a knowledge base
- Integration with GitHub and LinkedIn for external data
- Groq LLM integration for generating responses
- FastAPI server for handling requests
Send a POST request to /query with a JSON body containing your query:
curl -X POST "https://huggingface.co/spaces/ereinha3/personal-website/query" \
-H "Content-Type: application/json" \
-d '{"text": "Your query here"}'The response will include:
- The original query
- LLM-generated response
- Relevant context from the knowledge base
- A list of relevant documents
The following environment variables need to be set in your Hugging Face Space:
GITHUB_TOKEN: Your GitHub personal access tokenGITHUB_USERNAME: Your GitHub usernameLINKEDIN_EMAIL: Your LinkedIn emailLINKEDIN_PASSWORD: Your LinkedIn passwordGROQ_API_KEY: Your Groq API key
- Install dependencies:
pip install -r requirements.txt-
Set up environment variables in a
.envfile -
Run the server:
python main.pyThe server will start on http://localhost:8000
- Install dependencies:
pip install -r requirements.txt- Create a
.envfile with your API keys:
# GitHub credentials
GITHUB_TOKEN=your_github_personal_access_token
GITHUB_USERNAME=your_github_username
# LinkedIn credentials
LINKEDIN_EMAIL=your_linkedin_email
LINKEDIN_PASSWORD=your_linkedin_password
# Groq API credentials
GROQ_API_KEY=your_groq_api_key
- Create a
knowledgedirectory and add your documents:
knowledge/
├── resume/
│ ├── resume.pdf
│ └── resume.md
├── projects/
│ ├── project1/
│ │ ├── README.md
│ │ └── code/
│ └── project2/
│ ├── README.md
│ └── code/
└── other/
└── additional_info.md
- Run the server:
python main.pyThe server will start on http://localhost:8000.
-
Create a new Space on Hugging Face:
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Choose a name for your space
- Select "Docker" as the SDK
- Choose "Public" or "Private" visibility
-
Add your environment variables:
- Go to your Space settings
- Navigate to the "Repository Secrets" section
- Add the following secrets:
GITHUB_TOKENGITHUB_USERNAMELINKEDIN_EMAILLINKEDIN_PASSWORDGROQ_API_KEY
-
Push your code to the Space:
- The Space will automatically build and deploy your application
- You can monitor the build process in the "Factory" tab
-
Access your deployed application:
- Once deployed, your application will be available at
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
- Once deployed, your application will be available at
If you encounter issues when pushing to Hugging Face Spaces, try these solutions:
-
Check Git Configuration:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
-
Verify Remote URL:
git remote -v
Make sure the URL is correct:
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME -
Try Using Hugging Face CLI:
pip install huggingface_hub huggingface-cli login git push space main
-
Check File Size Limits:
- Hugging Face has file size limits
- If your knowledge base is large, consider hosting it elsewhere
-
Check Docker Build Logs:
- Go to your Space's "Factory" tab
- Look for any error messages in the build logs
-
Simplify Your Dockerfile:
- If the build is failing, try a simpler Dockerfile first
- Once that works, gradually add back the complexity
-
Use Hugging Face's Web Interface:
- Instead of pushing via Git, try uploading files directly through the web interface
- This can help identify if the issue is with Git or with the files themselves
- The agent uses the
sentence-transformers/all-MiniLM-L6-v2model for embeddings - Documents are chunked into 1000-character segments with 200-character overlap
- The agent returns the top 3 most relevant documents for each query
- External data (GitHub and LinkedIn) is updated every 24 hours
- The Groq Mixtral model is used for generating responses