Spaces:
Sleeping
Sleeping
Jac-Zac commited on
Commit ·
4c8079c
1
Parent(s): 7f3a4a6
Update to later versions
Browse filesEnviroment variables simplification
- Dockerfile +9 -3
- README.md +2 -4
- app.py +0 -23
- pyproject.toml +1 -2
- uv.lock +0 -0
Dockerfile
CHANGED
|
@@ -1,8 +1,12 @@
|
|
| 1 |
-
FROM
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
COPY pyproject.toml uv.lock ./
|
| 8 |
RUN uv sync --frozen --no-dev
|
|
@@ -14,4 +18,6 @@ COPY utils/ ./utils/
|
|
| 14 |
|
| 15 |
EXPOSE 8501
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ghcr.io/astral-sh/uv:0.11.5-python3.12-trixie-slim
|
| 2 |
+
# Using the uv image
|
| 3 |
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
+
# Setting up dependencies and stuff to be sure compilation is also working
|
| 7 |
+
# RUN apt-get update \
|
| 8 |
+
# && apt-get install -y --no-install-recommends build-essential python3-dev \
|
| 9 |
+
# && rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
COPY pyproject.toml uv.lock ./
|
| 12 |
RUN uv sync --frozen --no-dev
|
|
|
|
| 18 |
|
| 19 |
EXPOSE 8501
|
| 20 |
|
| 21 |
+
ENV PATH="/app/.venv/bin:$PATH"
|
| 22 |
+
|
| 23 |
+
CMD ["sh", "-c", "streamlit run app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]
|
README.md
CHANGED
|
@@ -96,7 +96,8 @@ No secrets needed! The dependencies are published on PyPI.
|
|
| 96 |
|
| 97 |
```bash
|
| 98 |
docker build -t persona-ui .
|
| 99 |
-
|
|
|
|
| 100 |
```
|
| 101 |
|
| 102 |
## Configuration
|
|
@@ -111,9 +112,6 @@ ARTIFACTS_DIR=... # Optional: where activations are read from (default: ./a
|
|
| 111 |
|
| 112 |
The app picks up this file automatically via `load_dotenv()` on startup.
|
| 113 |
|
| 114 |
-
You can also override the active NDIF or Hugging Face token from the sidebar
|
| 115 |
-
`API Keys` section. Those inputs only apply for the current session.
|
| 116 |
-
|
| 117 |
## Saved Artifacts
|
| 118 |
|
| 119 |
The Compare and Extract tabs read from / write to:
|
|
|
|
| 96 |
|
| 97 |
```bash
|
| 98 |
docker build -t persona-ui .
|
| 99 |
+
# Specify your local .env to have things working as expectd
|
| 100 |
+
docker run --env-file .env --rm -p 8501:8501 persona-ui
|
| 101 |
```
|
| 102 |
|
| 103 |
## Configuration
|
|
|
|
| 112 |
|
| 113 |
The app picks up this file automatically via `load_dotenv()` on startup.
|
| 114 |
|
|
|
|
|
|
|
|
|
|
| 115 |
## Saved Artifacts
|
| 116 |
|
| 117 |
The Compare and Extract tabs read from / write to:
|
app.py
CHANGED
|
@@ -8,33 +8,12 @@ from utils.helpers import DATASET_SOURCES
|
|
| 8 |
load_dotenv()
|
| 9 |
DEFAULT_MODEL = os.environ.get("DEFAULT_MODEL", "google/gemma-2-2b-it")
|
| 10 |
REMOTE_DEFAULT_MODEL = os.environ.get("REMOTE_DEFAULT_MODEL", "google/gemma-2-9b-it")
|
| 11 |
-
NDIF_API_KEY = os.environ.get("NDIF_API_KEY", "")
|
| 12 |
|
| 13 |
|
| 14 |
_TABS = ["Chat", "Compare", "Extract"]
|
| 15 |
_TAB_ICONS = [":material/chat:", ":material/search:", ":material/tune:"]
|
| 16 |
|
| 17 |
|
| 18 |
-
def _sync_sidebar_api_key(env_var: str, value: str) -> None:
|
| 19 |
-
if value:
|
| 20 |
-
os.environ[env_var] = value
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def _sidebar_api_keys() -> None:
|
| 24 |
-
with st.sidebar:
|
| 25 |
-
st.divider()
|
| 26 |
-
st.caption("API Keys")
|
| 27 |
-
|
| 28 |
-
ndif_api_key = st.text_input(
|
| 29 |
-
"NDIF API key",
|
| 30 |
-
value=NDIF_API_KEY,
|
| 31 |
-
type="password",
|
| 32 |
-
key="sidebar__ndif_api_key",
|
| 33 |
-
help="Overrides NDIF_API_KEY for this session.",
|
| 34 |
-
)
|
| 35 |
-
_sync_sidebar_api_key("NDIF_API_KEY", ndif_api_key)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
def _sidebar_controls() -> tuple[bool, str, str, str]:
|
| 39 |
from utils.runtime import list_remote_models
|
| 40 |
|
|
@@ -96,8 +75,6 @@ def _sidebar_controls() -> tuple[bool, str, str, str]:
|
|
| 96 |
help="Dataset for Chat and Extract.",
|
| 97 |
)
|
| 98 |
|
| 99 |
-
_sidebar_api_keys()
|
| 100 |
-
|
| 101 |
return remote, model_name, dataset_source, active_tab
|
| 102 |
|
| 103 |
|
|
|
|
| 8 |
load_dotenv()
|
| 9 |
DEFAULT_MODEL = os.environ.get("DEFAULT_MODEL", "google/gemma-2-2b-it")
|
| 10 |
REMOTE_DEFAULT_MODEL = os.environ.get("REMOTE_DEFAULT_MODEL", "google/gemma-2-9b-it")
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
_TABS = ["Chat", "Compare", "Extract"]
|
| 14 |
_TAB_ICONS = [":material/chat:", ":material/search:", ":material/tune:"]
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def _sidebar_controls() -> tuple[bool, str, str, str]:
|
| 18 |
from utils.runtime import list_remote_models
|
| 19 |
|
|
|
|
| 75 |
help="Dataset for Chat and Extract.",
|
| 76 |
)
|
| 77 |
|
|
|
|
|
|
|
| 78 |
return remote, model_name, dataset_source, active_tab
|
| 79 |
|
| 80 |
|
pyproject.toml
CHANGED
|
@@ -3,7 +3,7 @@ name = "persona-ui"
|
|
| 3 |
version = "0.1.0"
|
| 4 |
description = "Streamlit UI for persona-vectors"
|
| 5 |
readme = "README.md"
|
| 6 |
-
requires-python = ">=3.
|
| 7 |
dependencies = [
|
| 8 |
"persona-vectors>=0.1.0",
|
| 9 |
"persona-data>=0.1.0",
|
|
@@ -13,7 +13,6 @@ dependencies = [
|
|
| 13 |
"transformers>=5.5.0",
|
| 14 |
]
|
| 15 |
|
| 16 |
-
|
| 17 |
[tool.uv.sources]
|
| 18 |
# Local development:
|
| 19 |
# persona-vectors = { path = "../persona-data", editable = true }
|
|
|
|
| 3 |
version = "0.1.0"
|
| 4 |
description = "Streamlit UI for persona-vectors"
|
| 5 |
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.12"
|
| 7 |
dependencies = [
|
| 8 |
"persona-vectors>=0.1.0",
|
| 9 |
"persona-data>=0.1.0",
|
|
|
|
| 13 |
"transformers>=5.5.0",
|
| 14 |
]
|
| 15 |
|
|
|
|
| 16 |
[tool.uv.sources]
|
| 17 |
# Local development:
|
| 18 |
# persona-vectors = { path = "../persona-data", editable = true }
|
uv.lock
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|