wwwillchen commited on
Commit
8e04495
·
0 Parent(s):
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .DS_Store +0 -0
  2. BUILD +21 -0
  3. Dockerfile +32 -0
  4. Procfile +1 -0
  5. README.md +76 -0
  6. __pycache__/audio.cpython-310.pyc +0 -0
  7. __pycache__/autocomplete.cpython-310.pyc +0 -0
  8. __pycache__/badge.cpython-310.pyc +0 -0
  9. __pycache__/basic_animation.cpython-310.pyc +0 -0
  10. __pycache__/box.cpython-310.pyc +0 -0
  11. __pycache__/button.cpython-310.pyc +0 -0
  12. __pycache__/chat.cpython-310.pyc +0 -0
  13. __pycache__/chat_inputs.cpython-310.pyc +0 -0
  14. __pycache__/checkbox.cpython-310.pyc +0 -0
  15. __pycache__/code_demo.cpython-310.pyc +0 -0
  16. __pycache__/density.cpython-310.pyc +0 -0
  17. __pycache__/dialog.cpython-310.pyc +0 -0
  18. __pycache__/divider.cpython-310.pyc +0 -0
  19. __pycache__/embed.cpython-310.pyc +0 -0
  20. __pycache__/fancy_chat.cpython-310.pyc +0 -0
  21. __pycache__/feedback.cpython-310.pyc +0 -0
  22. __pycache__/form_billing.cpython-310.pyc +0 -0
  23. __pycache__/form_profile.cpython-310.pyc +0 -0
  24. __pycache__/github_widget.cpython-310.pyc +0 -0
  25. __pycache__/grid_table.cpython-310.pyc +0 -0
  26. __pycache__/headers.cpython-310.pyc +0 -0
  27. __pycache__/html_demo.cpython-310.pyc +0 -0
  28. __pycache__/icon.cpython-310.pyc +0 -0
  29. __pycache__/image.cpython-310.pyc +0 -0
  30. __pycache__/input.cpython-310.pyc +0 -0
  31. __pycache__/link.cpython-310.pyc +0 -0
  32. __pycache__/llm_playground.cpython-310.pyc +0 -0
  33. __pycache__/llm_rewriter.cpython-310.pyc +0 -0
  34. __pycache__/main.cpython-310.pyc +0 -0
  35. __pycache__/markdown_demo.cpython-310.pyc +0 -0
  36. __pycache__/markdown_editor.cpython-310.pyc +0 -0
  37. __pycache__/plot.cpython-310.pyc +0 -0
  38. __pycache__/progress_bar.cpython-310.pyc +0 -0
  39. __pycache__/progress_spinner.cpython-310.pyc +0 -0
  40. __pycache__/radio.cpython-310.pyc +0 -0
  41. __pycache__/select_demo.cpython-310.pyc +0 -0
  42. __pycache__/sidenav.cpython-310.pyc +0 -0
  43. __pycache__/slide_toggle.cpython-310.pyc +0 -0
  44. __pycache__/slider.cpython-310.pyc +0 -0
  45. __pycache__/snackbar.cpython-310.pyc +0 -0
  46. __pycache__/table.cpython-310.pyc +0 -0
  47. __pycache__/text.cpython-310.pyc +0 -0
  48. __pycache__/text_to_image.cpython-310.pyc +0 -0
  49. __pycache__/text_to_text.cpython-310.pyc +0 -0
  50. __pycache__/textarea.cpython-310.pyc +0 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
BUILD ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ load("//build_defs:defaults.bzl", "py_library")
2
+
3
+ package(
4
+ default_visibility = ["//build_defs:mesop_examples"],
5
+ )
6
+
7
+ py_library(
8
+ name = "demo",
9
+ srcs = glob(["*.py"]),
10
+ data = [":screenshots"],
11
+ deps = [
12
+ "//mesop",
13
+ "//mesop/labs",
14
+ ],
15
+ )
16
+
17
+ # Make source files available for distribution via pkg_npm
18
+ filegroup(
19
+ name = "screenshots",
20
+ srcs = glob(["screenshots/*"]),
21
+ )
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10.14-bullseye
2
+
3
+ RUN apt-get update && \
4
+ apt-get install -y \
5
+ # General dependencies
6
+ locales \
7
+ locales-all && \
8
+ # Clean local repository of package files since they won't be needed anymore.
9
+ # Make sure this line is called after all apt-get update/install commands have
10
+ # run.
11
+ apt-get clean && \
12
+ # Also delete the index files which we also don't need anymore.
13
+ rm -rf /var/lib/apt/lists/*
14
+
15
+ ENV LC_ALL en_US.UTF-8
16
+ ENV LANG en_US.UTF-8
17
+ ENV LANGUAGE en_US.UTF-8
18
+
19
+ # Install dependencies
20
+ COPY requirements.txt .
21
+ RUN pip install -r requirements.txt
22
+
23
+ # Create non-root user
24
+ RUN groupadd -g 900 mesop && useradd -u 900 -s /bin/bash -g mesop mesop
25
+ USER mesop
26
+
27
+ # Add app code here
28
+ COPY . /srv/mesop-app
29
+ WORKDIR /srv/mesop-app
30
+
31
+ # Run Mesop through gunicorn. Should be available at localhost:8080
32
+ CMD ["gunicorn", "--bind", "0.0.0.0:8080", "main:me"]
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: gunicorn --bind :8080 main:me
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Mesop Demo Gallery
3
+ emoji: 👓
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ license: apache-2.0
9
+ app_port: 8080
10
+ ---
11
+
12
+ # Mesop demo app
13
+
14
+ This app demonstrates Mesop's various components and features. Create your own Cloud Run app by following: https://google.github.io/mesop/guides/deployment/
15
+
16
+ ## Development
17
+
18
+ ### Setup
19
+
20
+ From workspace root:
21
+
22
+ ```sh
23
+ rm -rf demo/venv && \
24
+ virtualenv --python python3 demo/venv && \
25
+ source demo/venv/bin/activate && \
26
+ pip install -r demo/requirements.txt
27
+ ```
28
+
29
+ ### Run
30
+
31
+ 1. `cd demo`
32
+ 1. `mesop main.py`
33
+
34
+ ## Generate screenshots
35
+
36
+ If you add more demos and want to re-generate screenshots, do the following steps:
37
+
38
+ 1. in `demo/screenshot.ts` change `test.skip` to `test`
39
+ 1. Run: `yarn playwright test demo/screenshot.ts`
40
+ 1. Install cwebp using `brew install webp` or download from [here](https://developers.google.com/speed/webp/docs/precompiled).
41
+ 1. From the workspace root, run:
42
+
43
+ ```sh
44
+ `for file in demo/screenshots/*; do cwebp -q 50 "$file" -o "${file%.*}.webp"; done`
45
+ ```
46
+
47
+ ## Deployment
48
+
49
+ **Pre-requisites:**
50
+
51
+ - Make sure you [generate screenshots](#generate-screenshots) before deploying!
52
+ - Ensure a recent version of Mesop has been published to pip, otherwise the demos may not work (because they rely on a new API).
53
+
54
+ ### Deploy to Cloud Run
55
+
56
+ This app is deployed to Google Cloud Run.
57
+
58
+ ```sh
59
+ gcloud run deploy mesop --source .
60
+ ```
61
+
62
+ See our Mesop deployment [docs](https://google.github.io/mesop/guides/deployment/#deploy-to-google-cloud-run) for more background.
63
+
64
+ ### Deploy to Hugging Face Spaces
65
+
66
+ > NOTE: You need to update demo/requirements.txt to point to the latest Mesop version because Hugging Face Spaces may use a cached version of Mesop which is too old.
67
+
68
+ Because Hugging Face Spaces has restrictions on not having binary files (e.g. image files), we cannot push the full Mesop Git repo to Hugging Face Spaces. Instead, we copy just the `demo` directory and turn it into a standalone Git repo which we deploy.
69
+
70
+ ```sh
71
+ ./demo/deploy_to_hf.sh ../hf_demo
72
+ ```
73
+
74
+ You can change `../hf_demo` to any dir path outside of your Mesop repo.
75
+
76
+ > Note: if you get an error in Hugging Face Spaces "No app file", then you can create an "app.py" file in the Spaces UI to manually trigger a build. This seems like a bug with Hugging Face.
__pycache__/audio.cpython-310.pyc ADDED
Binary file (1.28 kB). View file
 
__pycache__/autocomplete.cpython-310.pyc ADDED
Binary file (2.68 kB). View file
 
__pycache__/badge.cpython-310.pyc ADDED
Binary file (931 Bytes). View file
 
__pycache__/basic_animation.cpython-310.pyc ADDED
Binary file (6.11 kB). View file
 
__pycache__/box.cpython-310.pyc ADDED
Binary file (1.7 kB). View file
 
__pycache__/button.cpython-310.pyc ADDED
Binary file (1.24 kB). View file
 
__pycache__/chat.cpython-310.pyc ADDED
Binary file (1.9 kB). View file
 
__pycache__/chat_inputs.cpython-310.pyc ADDED
Binary file (2.79 kB). View file
 
__pycache__/checkbox.cpython-310.pyc ADDED
Binary file (1.29 kB). View file
 
__pycache__/code_demo.cpython-310.pyc ADDED
Binary file (1.02 kB). View file
 
__pycache__/density.cpython-310.pyc ADDED
Binary file (1.67 kB). View file
 
__pycache__/dialog.cpython-310.pyc ADDED
Binary file (3.79 kB). View file
 
__pycache__/divider.cpython-310.pyc ADDED
Binary file (769 Bytes). View file
 
__pycache__/embed.cpython-310.pyc ADDED
Binary file (791 Bytes). View file
 
__pycache__/fancy_chat.cpython-310.pyc ADDED
Binary file (16.3 kB). View file
 
__pycache__/feedback.cpython-310.pyc ADDED
Binary file (2.35 kB). View file
 
__pycache__/form_billing.cpython-310.pyc ADDED
Binary file (5.57 kB). View file
 
__pycache__/form_profile.cpython-310.pyc ADDED
Binary file (4.62 kB). View file
 
__pycache__/github_widget.cpython-310.pyc ADDED
Binary file (458 Bytes). View file
 
__pycache__/grid_table.cpython-310.pyc ADDED
Binary file (17.2 kB). View file
 
__pycache__/headers.cpython-310.pyc ADDED
Binary file (5.29 kB). View file
 
__pycache__/html_demo.cpython-310.pyc ADDED
Binary file (1.17 kB). View file
 
__pycache__/icon.cpython-310.pyc ADDED
Binary file (750 Bytes). View file
 
__pycache__/image.cpython-310.pyc ADDED
Binary file (867 Bytes). View file
 
__pycache__/input.cpython-310.pyc ADDED
Binary file (1.08 kB). View file
 
__pycache__/link.cpython-310.pyc ADDED
Binary file (1.09 kB). View file
 
__pycache__/llm_playground.cpython-310.pyc ADDED
Binary file (15.5 kB). View file
 
__pycache__/llm_rewriter.cpython-310.pyc ADDED
Binary file (10.5 kB). View file
 
__pycache__/main.cpython-310.pyc ADDED
Binary file (14 kB). View file
 
__pycache__/markdown_demo.cpython-310.pyc ADDED
Binary file (1.78 kB). View file
 
__pycache__/markdown_editor.cpython-310.pyc ADDED
Binary file (5.4 kB). View file
 
__pycache__/plot.cpython-310.pyc ADDED
Binary file (915 Bytes). View file
 
__pycache__/progress_bar.cpython-310.pyc ADDED
Binary file (792 Bytes). View file
 
__pycache__/progress_spinner.cpython-310.pyc ADDED
Binary file (740 Bytes). View file
 
__pycache__/radio.cpython-310.pyc ADDED
Binary file (1.38 kB). View file
 
__pycache__/select_demo.cpython-310.pyc ADDED
Binary file (1.49 kB). View file
 
__pycache__/sidenav.cpython-310.pyc ADDED
Binary file (1.43 kB). View file
 
__pycache__/slide_toggle.cpython-310.pyc ADDED
Binary file (1.26 kB). View file
 
__pycache__/slider.cpython-310.pyc ADDED
Binary file (1.72 kB). View file
 
__pycache__/snackbar.cpython-310.pyc ADDED
Binary file (5.06 kB). View file
 
__pycache__/table.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
__pycache__/text.cpython-310.pyc ADDED
Binary file (1.34 kB). View file
 
__pycache__/text_to_image.cpython-310.pyc ADDED
Binary file (929 Bytes). View file
 
__pycache__/text_to_text.cpython-310.pyc ADDED
Binary file (852 Bytes). View file
 
__pycache__/textarea.cpython-310.pyc ADDED
Binary file (2.11 kB). View file