File size: 4,155 Bytes
3f46192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API Documentation - NutriBot</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gray-50 min-h-screen flex flex-col">
    <custom-navbar></custom-navbar>
    
    <main class="flex-grow container mx-auto px-4 py-8">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-lg shadow-lg p-8">
                <h1 class="text-3xl font-bold text-gray-800 mb-6 flex items-center gap-2">
                    <i data-feather="code" class="w-8 h-8 text-green-600"></i>
                    API Documentation
                </h1>
                
                <div class="mb-8">
                    <h2 class="text-2xl font-semibold text-gray-800 mb-4">Chat Endpoint</h2>
                    <div class="bg-gray-900 text-white p-4 rounded-lg mb-4">
                        <code class="text-sm">POST /chat</code>
                    </div>
                    
                    <div class="mb-6">
                        <h3 class="text-lg font-semibold text-gray-800 mb-2">Request Body</h3>
                        <pre class="bg-gray-100 p-4 rounded-lg text-sm overflow-x-auto">
<code>{
  "message": "string",
  "user_id": "string"
}</code></pre>
                    </div>
                    
                    <div class="mb-6">
                        <h3 class="text-lg font-semibold text-gray-800 mb-2">Response</h3>
                        <pre class="bg-gray-100 p-4 rounded-lg text-sm overflow-x-auto">
<code>{
  "response": "string"
}</code></pre>
                    </div>
                    
                    <div class="mb-6">
                        <h3 class="text-lg font-semibold text-gray-800 mb-2">Example</h3>
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <p class="text-sm text-gray-700 mb-2">Using curl:</p>
                            <pre class="bg-gray-900 text-white p-4 rounded-lg text-xs overflow-x-auto">
<code>curl -X POST "http://localhost:8000/chat" \
     -H "Content-Type: application/json" \
     -d '{
       "message": "What should I eat after a workout?",
       "user_id": "user123"
     }'</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="bg-yellow-50 border border-yellow-200 rounded-lg p-4">
                    <h3 class="text-lg font-semibold text-gray-800 mb-2 flex items-center gap-2">
                        <i data-feather="alert-triangle" class="w-5 h-5 text-yellow-600"></i>
                        Important Notes
                    </h3>
                    <ul class="text-sm text-gray-700 space-y-1">
                        <li>• The server must be running on localhost:8000</li>
                        <li>• A valid Hugging Face API key is required in the .env file</li>
                        <li>• Conversation history is stored in memory and resets on server restart</li>
                        <li>• All responses are generated using the Mistral-7B-Instruct model</li>
                    </ul>
                </div>
                
                <div class="mt-8 text-center">
                    <a href="http://localhost:8000/docs" target="_blank" class="inline-flex items-center gap-2 bg-green-600 text-white px-6 py-3 rounded-lg hover:bg-green-700 transition-colors">
                        <i data-feather="external-link" class="w-5 h-5"></i>
                        Interactive API Docs
                    </a>
                </div>
            </div>
        </div>
    </main>
    
    <custom-footer></custom-footer>
    
    <script src="components/navbar.js"></script>
    <script src="components/footer.js"></script>
    <script src="script.js"></script>
    <script>feather.replace();</script>
</body>
</html>