parth parekh
commited on
Commit
Β·
3d7c61d
1
Parent(s):
f7807b8
added better docs
Browse files
main.py
CHANGED
@@ -11,41 +11,54 @@ from accelerate import Accelerator
|
|
11 |
load_dotenv()
|
12 |
|
13 |
# HTML for the Buy Me a Coffee badge
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
"""
|
19 |
|
20 |
# FastAPI app with embedded Buy Me a Coffee badge and instructions
|
21 |
app = FastAPI(
|
22 |
title="Llama-3.2-1B-Instruct-API",
|
23 |
-
description=
|
24 |
-
{badge_html}
|
25 |
-
|
26 |
-
## Please Chill Out! π
|
27 |
-
This API takes around **5.62 minutes** to process a single request due to current hardware limitations.
|
28 |
-
|
29 |
-
### Want Faster Responses? Help Me Out! π
|
30 |
-
If you'd like to see this API running faster on high-performance **A100** hardware, please consider buying me a coffee. β Your support will go towards upgrading to **Hugging Face Pro**, which will allow me to run A100-powered spaces for everyone! π
|
31 |
-
|
32 |
-
### Instructions to Clone and Run Locally:
|
33 |
-
|
34 |
-
1. **Clone the Repository:**
|
35 |
-
```bash
|
36 |
-
git clone https://huggingface.co/spaces/xxparthparekhxx/llama-3.2-1B-FastApi
|
37 |
-
cd llama-3.2-1B-FastApi
|
38 |
-
```
|
39 |
-
|
40 |
-
2. **Run the Docker container:**
|
41 |
-
```bash
|
42 |
-
docker build -t llama-api .
|
43 |
-
docker run -p 7860:7860 llama-api
|
44 |
-
```
|
45 |
-
|
46 |
-
3. **Access the API locally:**
|
47 |
-
Open [http://localhost:7860](http://localhost:7860) to access the API docs locally.
|
48 |
-
""",
|
49 |
docs_url="/", # URL for Swagger docs
|
50 |
redoc_url="/doc" # URL for ReDoc docs
|
51 |
)
|
|
|
11 |
load_dotenv()
|
12 |
|
13 |
# HTML for the Buy Me a Coffee badge
|
14 |
+
html_content = """
|
15 |
+
<!DOCTYPE html>
|
16 |
+
<html>
|
17 |
+
<head>
|
18 |
+
<title>Llama-3.2-1B-Instruct-API</title>
|
19 |
+
</head>
|
20 |
+
<body>
|
21 |
+
<div style="text-align: center;">
|
22 |
+
<a href="https://buymeacoffee.com/xxparthparekhxx" target="_blank">
|
23 |
+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png"
|
24 |
+
alt="Buy Me A Coffee"
|
25 |
+
style="height: 40px; width: auto; max-width: 150px; margin-bottom: 20px;">
|
26 |
+
</a>
|
27 |
+
<h2>Please Chill Out! π</h2>
|
28 |
+
<p>This API takes around <strong>5.62 minutes</strong> to process a single request due to current hardware limitations.</p>
|
29 |
+
|
30 |
+
<h3>Want Faster Responses? Help Me Out! π</h3>
|
31 |
+
<p>If you'd like to see this API running faster on high-performance <strong>A100</strong> hardware, please consider buying me a coffee. β Your support will go towards upgrading to <strong>Hugging Face Pro</strong>, which will allow me to run A100-powered spaces for everyone! π</p>
|
32 |
+
|
33 |
+
<h4>Instructions to Clone and Run Locally:</h4>
|
34 |
+
<ol>
|
35 |
+
<li><strong>Clone the Repository:</strong>
|
36 |
+
<pre>
|
37 |
+
git clone https://huggingface.co/spaces/your-username/your-space
|
38 |
+
cd your-space
|
39 |
+
</pre>
|
40 |
+
</li>
|
41 |
+
<li><strong>Run the Docker container:</strong>
|
42 |
+
<pre>
|
43 |
+
docker build -t llama-api .
|
44 |
+
docker run -p 8000:8000 llama-api
|
45 |
+
</pre>
|
46 |
+
</li>
|
47 |
+
<li><strong>Access the API locally:</strong>
|
48 |
+
<p>Open <a href="http://localhost:8000">http://localhost:8000</a> to access the API docs locally.</p>
|
49 |
+
</li>
|
50 |
+
</ol>
|
51 |
+
|
52 |
+
<p>Thanks for your support! π</p>
|
53 |
+
</div>
|
54 |
+
</body>
|
55 |
+
</html>
|
56 |
"""
|
57 |
|
58 |
# FastAPI app with embedded Buy Me a Coffee badge and instructions
|
59 |
app = FastAPI(
|
60 |
title="Llama-3.2-1B-Instruct-API",
|
61 |
+
description= html_content,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
docs_url="/", # URL for Swagger docs
|
63 |
redoc_url="/doc" # URL for ReDoc docs
|
64 |
)
|