feat: add .env.sample and update README for USE_MODAL configuration
Browse files- .env.sample +1 -0
- README.md +5 -1
- pyproject.toml +2 -1
- src/unpredictable_lord/chat.py +5 -1
- uv.lock +11 -0
.env.sample
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
USE_MODAL=false
|
README.md
CHANGED
|
@@ -21,17 +21,21 @@ Check out the configuration reference at <https://huggingface.co/docs/hub/spaces
|
|
| 21 |
### Setup
|
| 22 |
|
| 23 |
```sh
|
|
|
|
| 24 |
uv sync --frozen
|
| 25 |
```
|
| 26 |
|
| 27 |
### Modal
|
| 28 |
|
| 29 |
-
If your local GPU is not powerful enough to run
|
| 30 |
|
| 31 |
```sh
|
|
|
|
| 32 |
uv run modal deploy src/unpredictable_lord/llm_modal.py
|
| 33 |
```
|
| 34 |
|
|
|
|
|
|
|
| 35 |
### Run locally
|
| 36 |
|
| 37 |
```sh
|
|
|
|
| 21 |
### Setup
|
| 22 |
|
| 23 |
```sh
|
| 24 |
+
cp .env.sample .env
|
| 25 |
uv sync --frozen
|
| 26 |
```
|
| 27 |
|
| 28 |
### Modal
|
| 29 |
|
| 30 |
+
If your local GPU is not powerful enough to run "gpt-oss-20b", you can deploy it to Modal 🚀
|
| 31 |
|
| 32 |
```sh
|
| 33 |
+
uv run modal setup
|
| 34 |
uv run modal deploy src/unpredictable_lord/llm_modal.py
|
| 35 |
```
|
| 36 |
|
| 37 |
+
and then set `USE_MODAL=true` in your `.env` file.
|
| 38 |
+
|
| 39 |
### Run locally
|
| 40 |
|
| 41 |
```sh
|
pyproject.toml
CHANGED
|
@@ -10,8 +10,9 @@ dependencies = [
|
|
| 10 |
"kernels>=0.11.1",
|
| 11 |
"modal>=1.2.5.dev0",
|
| 12 |
"openai-harmony>=0.0.8",
|
|
|
|
| 13 |
"spaces>=0.42.1",
|
| 14 |
-
"torch==2.8.0",
|
| 15 |
"transformers>=4.57.1",
|
| 16 |
]
|
| 17 |
|
|
|
|
| 10 |
"kernels>=0.11.1",
|
| 11 |
"modal>=1.2.5.dev0",
|
| 12 |
"openai-harmony>=0.0.8",
|
| 13 |
+
"python-dotenv>=1.2.1",
|
| 14 |
"spaces>=0.42.1",
|
| 15 |
+
"torch==2.8.0", # ZeroGPU
|
| 16 |
"transformers>=4.57.1",
|
| 17 |
]
|
| 18 |
|
src/unpredictable_lord/chat.py
CHANGED
|
@@ -5,12 +5,16 @@ Provides chat functionality by calling the LLM endpoint on Modal or using ZeroGP
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import logging
|
|
|
|
| 8 |
|
| 9 |
import openai_harmony as oh
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
logger = logging.getLogger(__name__)
|
| 12 |
|
| 13 |
-
USE_MODAL =
|
| 14 |
|
| 15 |
|
| 16 |
if USE_MODAL:
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import logging
|
| 8 |
+
import os
|
| 9 |
|
| 10 |
import openai_harmony as oh
|
| 11 |
+
from dotenv import load_dotenv
|
| 12 |
+
|
| 13 |
+
load_dotenv()
|
| 14 |
|
| 15 |
logger = logging.getLogger(__name__)
|
| 16 |
|
| 17 |
+
USE_MODAL = os.getenv("USE_MODAL", "false").lower() == "true"
|
| 18 |
|
| 19 |
|
| 20 |
if USE_MODAL:
|
uv.lock
CHANGED
|
@@ -1038,6 +1038,15 @@ wheels = [
|
|
| 1038 |
{ url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload_time = "2024-03-01T18:36:18.57Z" },
|
| 1039 |
]
|
| 1040 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1041 |
[[package]]
|
| 1042 |
name = "python-multipart"
|
| 1043 |
version = "0.0.20"
|
|
@@ -1491,6 +1500,7 @@ dependencies = [
|
|
| 1491 |
{ name = "kernels" },
|
| 1492 |
{ name = "modal" },
|
| 1493 |
{ name = "openai-harmony" },
|
|
|
|
| 1494 |
{ name = "spaces" },
|
| 1495 |
{ name = "torch" },
|
| 1496 |
{ name = "transformers" },
|
|
@@ -1508,6 +1518,7 @@ requires-dist = [
|
|
| 1508 |
{ name = "kernels", specifier = ">=0.11.1" },
|
| 1509 |
{ name = "modal", specifier = ">=1.2.5.dev0" },
|
| 1510 |
{ name = "openai-harmony", specifier = ">=0.0.8" },
|
|
|
|
| 1511 |
{ name = "spaces", specifier = ">=0.42.1" },
|
| 1512 |
{ name = "torch", specifier = "==2.8.0" },
|
| 1513 |
{ name = "transformers", specifier = ">=4.57.1" },
|
|
|
|
| 1038 |
{ url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload_time = "2024-03-01T18:36:18.57Z" },
|
| 1039 |
]
|
| 1040 |
|
| 1041 |
+
[[package]]
|
| 1042 |
+
name = "python-dotenv"
|
| 1043 |
+
version = "1.2.1"
|
| 1044 |
+
source = { registry = "https://pypi.org/simple" }
|
| 1045 |
+
sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload_time = "2025-10-26T15:12:10.434Z" }
|
| 1046 |
+
wheels = [
|
| 1047 |
+
{ url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload_time = "2025-10-26T15:12:09.109Z" },
|
| 1048 |
+
]
|
| 1049 |
+
|
| 1050 |
[[package]]
|
| 1051 |
name = "python-multipart"
|
| 1052 |
version = "0.0.20"
|
|
|
|
| 1500 |
{ name = "kernels" },
|
| 1501 |
{ name = "modal" },
|
| 1502 |
{ name = "openai-harmony" },
|
| 1503 |
+
{ name = "python-dotenv" },
|
| 1504 |
{ name = "spaces" },
|
| 1505 |
{ name = "torch" },
|
| 1506 |
{ name = "transformers" },
|
|
|
|
| 1518 |
{ name = "kernels", specifier = ">=0.11.1" },
|
| 1519 |
{ name = "modal", specifier = ">=1.2.5.dev0" },
|
| 1520 |
{ name = "openai-harmony", specifier = ">=0.0.8" },
|
| 1521 |
+
{ name = "python-dotenv", specifier = ">=1.2.1" },
|
| 1522 |
{ name = "spaces", specifier = ">=0.42.1" },
|
| 1523 |
{ name = "torch", specifier = "==2.8.0" },
|
| 1524 |
{ name = "transformers", specifier = ">=4.57.1" },
|