Deployment Guide for Research Assistant
Deployment Guide for Research Assistant
This guide explains how to deploy the AI research assistant to Hugging Face Spaces.
Option 1: Simple Version (No API Keys Required)
The simple version uses a rule-based system and doesn’t require any API keys.
Steps:
Create a Hugging Face account at https://huggingface.co/
- Create a new Space:
- Go to https://huggingface.co/spaces
- Click “Create new Space”
- Choose a name (e.g., “david-research-assistant”)
- Select “Gradio” as the SDK
- Choose “Public” visibility
- Click “Create Space”
- Upload files:
- Upload
app_simple.py
asapp.py
- Upload
requirements_simple.txt
asrequirements.txt
- Upload the
README.md
file
- Upload
- Wait for deployment:
- The Space will automatically build and deploy
- Once ready, you’ll get a public URL
- Update your website:
- Replace the placeholder API endpoint in the about.md file with your Hugging Face Space URL
Option 2: Advanced Version (With Document Processing)
The advanced version can read your PDFs and provide more detailed responses.
Prerequisites:
- Hugging Face API token (free from https://huggingface.co/settings/tokens)
Steps:
- Prepare documents:
- Create a
documents
folder in the Space - Upload your PDFs and CV to this folder
- Create a
- Set up secrets:
- In your Space settings, go to “Settings” > “Variables and secrets”
- Add
HUGGINGFACEHUB_API_TOKEN
with your token
- Upload files:
- Upload
app.py
- Upload
requirements.txt
- Upload the
README.md
file - Upload your PDF documents
- Upload
- Update the code:
- Modify the
pdf_dir
path inapp.py
to point to your documents folder
- Modify the
Integrating with Your Website
Once deployed, update the chat interface in your about.md file:
// Replace the placeholder API call with:
const response = await fetch('YOUR_HUGGINGFACE_SPACE_URL/api/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
data: [message, []] // message and history
})
});
const data = await response.json();
const botResponse = data.data[0];
Testing
- Visit your Hugging Face Space URL
- Try asking questions like:
- “What are David’s research interests?”
- “Tell me about his publications”
- “What methods has he developed?”
Customization
You can customize the assistant by:
- Updating the knowledge base in
app_simple.py
- Adding more documents to the advanced version
- Modifying the UI theme and colors
- Adding more example questions
Troubleshooting
- If the Space fails to build, check the logs in the “Logs” tab
- Ensure all file paths are correct
- For the advanced version, verify your API token is set correctly
- Check that gradio version matches in requirements.txt
Next Steps
After deployment:
- Test the assistant thoroughly
- Share the Space URL for feedback
- Monitor usage and improve responses
- Consider adding more advanced features like:
- Multi-language support
- Citation tracking
- Email notifications for interesting questions