The problem
Left alone, a chat model answers a small question at length. The constraint work is in the system prompt: a role definition, explicit greeting and closing rules, silent step-by-step reasoning and few-shot examples, together holding the model to brief, actionable replies.
What I built
- Developed a Flask backend exposing a POST /chat endpoint accepting a message plus prior history, returning the reply alongside the raw provider response.
- Engineered a structured system prompt combining role definition, greeting and closing rules, silent step-by-step reasoning and few-shot examples.
- Integrated the Groq API using Llama 3.1 8B Instant with tuned temperature and token limits, plus a mock-response fallback so the frontend stays functional without an API key.
- Implemented multi-turn context by replaying client-held history into each request, with defensive response parsing, structured logging, CORS configuration and error propagation to the UI.
- Built the React chat UI with loading and error states, auto-scroll to the latest message and keyboard send handling.
Stack
PythonFlaskFlask-CORSpython-dotenvRequestsGroq API (Llama 3.1 8B Instant)React 19Node.js
Skills applied
- LLM integration
- Prompt engineering (few-shot and role prompting)
- REST API design
- Conversational state handling
- Error handling and logging
- Environment-based configuration