Spaces:
Paused
Paused
Jules commited on
Commit ·
0a5eb9b
1
Parent(s): 6a42990
Prepare for Hugging Face deployment: add Dockerfile, FastAPI /health endpoint, and sync workflow
Browse files- .github/workflows/hf_sync.yml +18 -0
- .hfignore +6 -0
- Dockerfile +32 -0
- README.md +2 -3
- __pycache__/app.cpython-312.pyc +0 -0
- app.py +12 -1
- requirements.txt +2 -0
- tinytroupe/__pycache__/__init__.cpython-312.pyc +0 -0
- tinytroupe/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- tinytroupe/utils/__pycache__/config.cpython-312.pyc +0 -0
- tinytroupe/utils/__pycache__/json.cpython-312.pyc +0 -0
- tinytroupe/utils/__pycache__/llm.cpython-312.pyc +0 -0
.github/workflows/hf_sync.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face hub
|
| 2 |
+
on:
|
| 3 |
+
push:
|
| 4 |
+
branches: [main]
|
| 5 |
+
workflow_dispatch:
|
| 6 |
+
|
| 7 |
+
jobs:
|
| 8 |
+
sync-to-hub:
|
| 9 |
+
runs-on: ubuntu-latest
|
| 10 |
+
steps:
|
| 11 |
+
- uses: actions/checkout@v3
|
| 12 |
+
with:
|
| 13 |
+
fetch-depth: 0
|
| 14 |
+
lfs: true
|
| 15 |
+
- name: Push to hub
|
| 16 |
+
env:
|
| 17 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 18 |
+
run: git push --force https://AUXteam:$HF_TOKEN@huggingface.co/spaces/AUXteam/tiny_factory main
|
.hfignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.git
|
| 2 |
+
__pycache__
|
| 3 |
+
.venv
|
| 4 |
+
.env
|
| 5 |
+
*.log
|
| 6 |
+
.pytest_cache
|
Dockerfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
# Install system dependencies
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
build-essential \
|
| 6 |
+
curl \
|
| 7 |
+
software-properties-common \
|
| 8 |
+
git \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
+
|
| 11 |
+
# Install uv
|
| 12 |
+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
| 13 |
+
|
| 14 |
+
# Set up a non-root user
|
| 15 |
+
RUN useradd -m -u 1000 user
|
| 16 |
+
USER user
|
| 17 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 18 |
+
|
| 19 |
+
WORKDIR /app
|
| 20 |
+
|
| 21 |
+
# Copy requirements and install
|
| 22 |
+
COPY --chown=user requirements.txt .
|
| 23 |
+
RUN uv pip install --system -r requirements.txt
|
| 24 |
+
|
| 25 |
+
# Copy the rest of the application
|
| 26 |
+
COPY --chown=user . .
|
| 27 |
+
|
| 28 |
+
# Expose the port
|
| 29 |
+
EXPOSE 7860
|
| 30 |
+
|
| 31 |
+
# Command to run the application
|
| 32 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -3,9 +3,8 @@ title: Tiny Factory
|
|
| 3 |
emoji: 💻
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: gray
|
| 6 |
-
sdk:
|
| 7 |
-
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
|
|
|
| 3 |
emoji: 💻
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: gray
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
|
|
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
__pycache__/app.cpython-312.pyc
ADDED
|
Binary file (4.25 kB). View file
|
|
|
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import os
|
|
| 3 |
import gradio as gr
|
| 4 |
import json
|
| 5 |
from tinytroupe.factory import TinyPersonFactory
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# --- CHANGE 1: The function now accepts an optional API key. ---
|
| 8 |
def generate_personas(business_description, customer_profile, num_personas, blablador_api_key=None):
|
|
@@ -82,5 +84,14 @@ with gr.Blocks() as demo:
|
|
| 82 |
api_name="generate_personas"
|
| 83 |
)
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
if __name__ == "__main__":
|
| 86 |
-
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
import json
|
| 5 |
from tinytroupe.factory import TinyPersonFactory
|
| 6 |
+
from fastapi import FastAPI
|
| 7 |
+
import uvicorn
|
| 8 |
|
| 9 |
# --- CHANGE 1: The function now accepts an optional API key. ---
|
| 10 |
def generate_personas(business_description, customer_profile, num_personas, blablador_api_key=None):
|
|
|
|
| 84 |
api_name="generate_personas"
|
| 85 |
)
|
| 86 |
|
| 87 |
+
app = FastAPI()
|
| 88 |
+
|
| 89 |
+
@app.get("/health")
|
| 90 |
+
def health():
|
| 91 |
+
return {"status": "ok"}
|
| 92 |
+
|
| 93 |
+
# Mount Gradio app to FastAPI
|
| 94 |
+
app = gr.mount_gradio_app(app, demo, path="/")
|
| 95 |
+
|
| 96 |
if __name__ == "__main__":
|
| 97 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
requirements.txt
CHANGED
|
@@ -22,3 +22,5 @@ textdistance
|
|
| 22 |
scipy
|
| 23 |
transformers==4.38.2
|
| 24 |
huggingface-hub==0.22.2
|
|
|
|
|
|
|
|
|
| 22 |
scipy
|
| 23 |
transformers==4.38.2
|
| 24 |
huggingface-hub==0.22.2
|
| 25 |
+
fastapi
|
| 26 |
+
uvicorn
|
tinytroupe/__pycache__/__init__.cpython-312.pyc
CHANGED
|
Binary files a/tinytroupe/__pycache__/__init__.cpython-312.pyc and b/tinytroupe/__pycache__/__init__.cpython-312.pyc differ
|
|
|
tinytroupe/utils/__pycache__/__init__.cpython-312.pyc
CHANGED
|
Binary files a/tinytroupe/utils/__pycache__/__init__.cpython-312.pyc and b/tinytroupe/utils/__pycache__/__init__.cpython-312.pyc differ
|
|
|
tinytroupe/utils/__pycache__/config.cpython-312.pyc
CHANGED
|
Binary files a/tinytroupe/utils/__pycache__/config.cpython-312.pyc and b/tinytroupe/utils/__pycache__/config.cpython-312.pyc differ
|
|
|
tinytroupe/utils/__pycache__/json.cpython-312.pyc
CHANGED
|
Binary files a/tinytroupe/utils/__pycache__/json.cpython-312.pyc and b/tinytroupe/utils/__pycache__/json.cpython-312.pyc differ
|
|
|
tinytroupe/utils/__pycache__/llm.cpython-312.pyc
CHANGED
|
Binary files a/tinytroupe/utils/__pycache__/llm.cpython-312.pyc and b/tinytroupe/utils/__pycache__/llm.cpython-312.pyc differ
|
|
|