This server implements an LLM-powered agentic chatbot with tool calls, context, and Discord/MongoDB integration. It uses Flask for the API, Celery for background tasks, Redis as the broker, and MongoDB for storage.
- Flask: REST API backend
- Celery: Async tool calls
- Redis: Celery broker/result backend
- MongoDB: Candidate profile and tool call storage
- Discord: Send/receive messages via bot
- LLM Tool Calls: Agent can trigger tools in background
cd pythonserver
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtIf requirements.txt is missing, install at least:
pip install flask celery redis pymongo openai discord.py-
Redis:
- Install via Homebrew:
brew install redis - Start:
redis-server
- Install via Homebrew:
-
MongoDB:
- Install via Homebrew:
brew tap mongodb/brew && brew install mongodb-community - Start:
brew services start mongodb-community
- Install via Homebrew:
Create a .env file or export these variables:
OPENAI_API_KEY=your-openai-key
DISCORD_TOKEN=your-discord-bot-token
DISCORD_CHANNEL_ID=your-discord-channel-id
MONGO_URI=mongodb://localhost:27017/
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0
python app.pycelery -A celery_worker.celery_app worker --loglevel=info/chat: Main chat endpoint for agentic conversation and tool calls./health: Health check.
- Celery not connecting? Make sure Redis is running and env vars are correct.
- MongoDB errors? Ensure MongoDB is running and accessible.
- Discord issues? Make sure your bot token is correct and the bot is invited to the right server/channel.
- Async errors? All tool calls are now sync-compatible.
- Edit
mongo_tool.pyfor MongoDB logic. - Edit
discord_tool.pyfor Discord bot logic. - Edit
app.pyfor API and agent orchestration.
<!-- Datadog RUM Initialization -->
<script>
(function(h,o,u,n,d){
h=h[d]=h[d]||{q:[],onReady:function(c){h.q.push(c)}};
d=o.createElement(u);d.async=1;d.src='https://www.datadoghq-browser-agent.com/us5/v6/datadog-rum.js';
n=o.getElementsByTagName(u)[0];n.parentNode.insertBefore(d,n);
})(window,document,'script','https://www.datadoghq-browser-agent.com/us5/v6/datadog-rum.js','DD_RUM');
window.DD_RUM.onReady(function(){
window.DD_RUM.init({
clientToken: 'YOUR_CLIENT_TOKEN',
applicationId: 'YOUR_APPLICATION_ID',
site: 'us5.datadoghq.com',
service: 'mygithubsite',
env: 'prod',
sessionSampleRate: 100,
sessionReplaySampleRate: 20,
defaultPrivacyLevel: 'mask-user-input',
});
});
</script>