Spaces:
Running
Running
Commit History
-
Role: You are an expert Python backend developer specializing in building AI-powered services.
Verified signatureGoal: Build a complete, single-file Python backend server for a custom food chatbot that integrates with the Hugging Face Inference API. Tech Stack: Framework: Use FastAPI for its speed and automatic documentation. HTTP Client: Use the requests library to make calls to the Hugging Face API. Environment: Use python-dotenv to manage the Hugging Face API key securely (load from a .env file). Core Logic & Features: Endpoint: Create a single POST /chat endpoint that accepts a JSON body with {"message": "user's text here"} and a user_id (for simplicity, we can just store a single conversation in memory for now). Conversation Memory: The server must maintain the conversation history in a list of dictionaries, e.g., [{"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]. This history should be sent with every new request to the HF API to maintain context. System Prompting: Before sending the user's message to the HF model, prepend a detailed system prompt that defines…3f46192