Views
No views yet
pip install -r requirements.txt.env file in the root directory:1# Copy the example file
2cp env_example.txt .env
3
4# Edit .env and add your Hugging Face token (optional)
5HF_TOKEN=your_huggingface_token_here1# Run with uvicorn
2uvicorn main:app --reload --host 0.0.0.0 --port 8000
3
4# Or run directly
5python main.pyhttp://localhost:8000GET /health1POST /chat
2Content-Type: application/json
3
4{
5 "prompt": "What's the best way to cook pasta?",
6 "max_length": 150,
7 "temperature": 0.7
8}1POST /chat/restaurant
2Content-Type: application/json
3
4{
5 "prompt": "How do I make a good pizza dough?",
6 "max_length": 200,
7 "temperature": 0.8
8}1# General chat
2curl -X POST "http://localhost:8000/chat" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "prompt": "What are some popular Italian dishes?",
6 "max_length": 150,
7 "temperature": 0.7
8 }'
9
10# Restaurant-specific chat
11curl -X POST "http://localhost:8000/chat/restaurant" \
12 -H "Content-Type: application/json" \
13 -d '{
14 "prompt": "How do I make authentic carbonara?",
15 "max_length": 200,
16 "temperature": 0.8
17 }'1import requests
2
3# General chat
4response = requests.post(
5 "http://localhost:8000/chat",
6 json={
7 "prompt": "What's the best way to cook pasta?",
8 "max_length": 150,
9 "temperature": 0.7
10 }
11)
12print(response.json())
13
14# Restaurant-specific chat
15response = requests.post(
16 "http://localhost:8000/chat/restaurant",
17 json={
18 "prompt": "Can you recommend a vegetarian dish?",
19 "max_length": 200,
20 "temperature": 0.8
21 }
22)
23print(response.json())microsoft/DialoGPT-mediumMODEL_ID variable in main.py.MODEL_ID in main.py:1# Some alternative free models:
2MODEL_ID = "microsoft/DialoGPT-small" # Smaller, faster
3MODEL_ID = "microsoft/DialoGPT-large" # Larger, more capable
4MODEL_ID = "EleutherAI/gpt-neo-125M" # Different architecture