jpwsutton commited on
Commit
b376f12
·
0 Parent(s):

Initial commit

Browse files
Files changed (13) hide show
  1. .gitattributes +35 -0
  2. .gitignore +173 -0
  3. .gitlint +143 -0
  4. .pre-commit-config.yaml +51 -0
  5. DEVELOPMENT.md +154 -0
  6. README.md +12 -0
  7. poetry.lock +0 -0
  8. pyproject.toml +57 -0
  9. requirements.txt +77 -0
  10. src/app.css +3 -0
  11. src/app.py +102 -0
  12. src/app_head.html +12 -0
  13. src/themes/carbon.py +117 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+
171
+ # Boilerplate specific ignores
172
+ .gradio/
173
+ .ruff_cache/
.gitlint ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Edit this file as you like.
2
+ #
3
+ # All these sections are optional. Each section with the exception of [general] represents
4
+ # one rule and each key in it is an option for that specific rule.
5
+ #
6
+ # Rules and sections can be referenced by their full name or by id. For example
7
+ # section "[body-max-line-length]" could also be written as "[B1]". Full section names are
8
+ # used in here for clarity.
9
+ #
10
+ # [general]
11
+ # Ignore certain rules, this example uses both full name and id
12
+ # ignore=title-trailing-punctuation, T3
13
+
14
+ [general]
15
+ # You HAVE to add the rule here to enable it, only configuring (such as below)
16
+ # does NOT enable it.
17
+ contrib=contrib-title-conventional-commits
18
+
19
+ [contrib-title-conventional-commits]
20
+ # Specify allowed commit types. For details see: https://www.conventionalcommits.org/
21
+ types = build,chore,ci,docs,feat,fix,perf,refactor,revert,style,test
22
+
23
+ # verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this
24
+ # verbosity = 2
25
+
26
+ # By default gitlint will ignore merge, revert, fixup and squash commits.
27
+ # ignore-merge-commits=true
28
+ # ignore-revert-commits=true
29
+ # ignore-fixup-commits=true
30
+ # ignore-squash-commits=true
31
+
32
+ # Ignore any data send to gitlint via stdin
33
+ # ignore-stdin=true
34
+
35
+ # Fetch additional meta-data from the local repository when manually passing a
36
+ # commit message to gitlint via stdin or --commit-msg. Disabled by default.
37
+ # staged=true
38
+
39
+ # Hard fail when the target commit range is empty. Note that gitlint will
40
+ # already fail by default on invalid commit ranges. This option is specifically
41
+ # to tell gitlint to fail on *valid but empty* commit ranges.
42
+ # Disabled by default.
43
+ # fail-without-commits=true
44
+
45
+ # Enable debug mode (prints more output). Disabled by default.
46
+ # debug=true
47
+
48
+ # Enable community contributed rules
49
+ # See http://jorisroovers.github.io/gitlint/contrib_rules for details
50
+ # contrib=contrib-title-conventional-commits,CC1
51
+
52
+ # Set the extra-path where gitlint will search for user defined rules
53
+ # See http://jorisroovers.github.io/gitlint/user_defined_rules for details
54
+ # extra-path=examples/
55
+
56
+ # This is an example of how to configure the "title-max-length" rule and
57
+ # set the line-length it enforces to 50
58
+ # [title-max-length]
59
+ # line-length=50
60
+
61
+ # Conversely, you can also enforce minimal length of a title with the
62
+ # "title-min-length" rule:
63
+ # [title-min-length]
64
+ # min-length=5
65
+
66
+ # [title-must-not-contain-word]
67
+ # Comma-separated list of words that should not occur in the title. Matching is case
68
+ # insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
69
+ # will not cause a violation, but "WIP: my title" will.
70
+ # words=wip
71
+
72
+ # [title-match-regex]
73
+ # python-style regex that the commit-msg title must match
74
+ # Note that the regex can contradict with other rules if not used correctly
75
+ # (e.g. title-must-not-contain-word).
76
+ # regex=^US[0-9]*
77
+
78
+ # [body-max-line-length]
79
+ # line-length=72
80
+
81
+ # [body-min-length]
82
+ # min-length=5
83
+
84
+ # [body-is-missing]
85
+ # Whether to ignore this rule on merge commits (which typically only have a title)
86
+ # default = True
87
+ # ignore-merge-commits=false
88
+
89
+ # [body-changed-file-mention]
90
+ # List of files that need to be explicitly mentioned in the body when they are changed
91
+ # This is useful for when developers often erroneously edit certain files or git submodules.
92
+ # By specifying this rule, developers can only change the file when they explicitly reference
93
+ # it in the commit message.
94
+ # files=gitlint-core/gitlint/rules.py,README.md
95
+
96
+ # [body-match-regex]
97
+ # python-style regex that the commit-msg body must match.
98
+ # E.g. body must end in My-Commit-Tag: foo
99
+ # regex=My-Commit-Tag: foo$
100
+
101
+ # [author-valid-email]
102
+ # python-style regex that the commit author email address must match.
103
+ # For example, use the following regex if you only want to allow email addresses from foo.com
104
+ # regex=[^@][email protected]
105
+
106
+ # [ignore-by-title]
107
+ # Ignore certain rules for commits of which the title matches a regex
108
+ # E.g. Match commit titles that start with "Release"
109
+ # regex=^Release(.*)
110
+
111
+ # Ignore certain rules, you can reference them by their id or by their full name
112
+ # Use 'all' to ignore all rules
113
+ # ignore=T1,body-min-length
114
+
115
+ # [ignore-by-body]
116
+ # Ignore certain rules for commits of which the body has a line that matches a regex
117
+ # E.g. Match bodies that have a line that that contain "release"
118
+ # regex=(.*)release(.*)
119
+ #
120
+ # Ignore certain rules, you can reference them by their id or by their full name
121
+ # Use 'all' to ignore all rules
122
+ # ignore=T1,body-min-length
123
+
124
+ # [ignore-body-lines]
125
+ # Ignore certain lines in a commit body that match a regex.
126
+ # E.g. Ignore all lines that start with 'Co-Authored-By'
127
+ # regex=^Co-Authored-By
128
+
129
+ # [ignore-by-author-name]
130
+ # Ignore certain rules for commits of which the author name matches a regex
131
+ # E.g. Match commits made by dependabot
132
+ # regex=(.*)dependabot(.*)
133
+ #
134
+ # Ignore certain rules, you can reference them by their id or by their full name
135
+ # Use 'all' to ignore all rules
136
+ # ignore=T1,body-min-length
137
+
138
+ # This is a contrib rule - a community contributed rule. These are disabled by default.
139
+ # You need to explicitly enable them one-by-one by adding them to the "contrib" option
140
+ # under [general] section above.
141
+ # [contrib-title-conventional-commits]
142
+ # Specify allowed commit types. For details see: https://www.conventionalcommits.org/
143
+ # types = bugfix,user-story,epic
.pre-commit-config.yaml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-added-large-files
6
+ - id: check-ast
7
+ - id: check-case-conflict
8
+ - id: check-json
9
+ - id: check-merge-conflict
10
+ - id: check-toml
11
+ - id: end-of-file-fixer
12
+ - repo: https://github.com/astral-sh/ruff-pre-commit
13
+ # Ruff version.
14
+ rev: v0.8.6
15
+ hooks:
16
+ - id: ruff
17
+ - repo: https://github.com/pycqa/isort
18
+ rev: 5.13.2
19
+ hooks:
20
+ - id: isort
21
+ args: ["--profile", "black"]
22
+ - repo: https://github.com/asottile/pyupgrade
23
+ rev: v3.19.1
24
+ hooks:
25
+ - id: pyupgrade
26
+ args: ["--py310-plus"]
27
+ - repo: https://github.com/psf/black
28
+ rev: 24.10.0
29
+ hooks:
30
+ - id: black
31
+ args:
32
+ - --line-length=120
33
+ - repo: https://github.com/jorisroovers/gitlint
34
+ rev: v0.19.1
35
+ hooks:
36
+ - id: gitlint
37
+ name: gitlint
38
+ language: python
39
+ entry: gitlint
40
+ args: [--staged, --msg-filename]
41
+ stages: [commit-msg]
42
+ - repo: https://github.com/python-poetry/poetry
43
+ rev: '1.8.0'
44
+ hooks:
45
+ - id: poetry-check
46
+ - id: poetry-lock
47
+ args: [--no-update]
48
+ language_version: "3.10"
49
+ - id: poetry-export
50
+ name: poetry export for base requirements
51
+ args: [-f, requirements.txt, -o, requirements.txt, -n, --only=main, --without-hashes]
DEVELOPMENT.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # IBM Research Hugging Face Spaces gradio template
2
+
3
+ This template repository lets you quickly build a gradio Hugging Face spaces demo for the [ibm-granite org](https://huggingface.co/ibm-granite). It is set up with the requirements and theming for the ibm-granite org as well as pre-commit hooks and linting configuration to maintain a consistent code standard across all demos.
4
+
5
+ ## 👩‍💻 Introduction
6
+
7
+ To deploy demos to the ibm-granite org on Hugging Face, you will be working with the Research Design Technical Experiences (RDTE) team via this GitHub org. You will not gain write access to Hugging Face org as there are limited seats available for those who are able to contribute. Hence, with read-only access you will work via the RDTE team (who have write access) to create and deploy demos to Hugging Face.
8
+
9
+ ## 🛠️ Getting started
10
+
11
+ This is the place to start when building gradio demos for IBM Granite. Complete the following steps to get a repository set up and configured for your demo as well as the deployment pipeline to validate and push it to Hugging Face spaces.
12
+
13
+ 1. [Raise an onboarding request](https://github.ibm.com/ibm-huggingface-space-demos/deployment/issues/new?assignees=james-sutton,gwhite&labels=onboarding%2Ctriage&projects=&template=onboarding.yaml&title=%5BOnboarding%5D%3A+). Please fill out the linked template to request a new repository be set up for you in this org and to give access to anything else required. You can always add more contributors later if needed.
14
+ 2. Once your repository has been created, please either update it with your existing demo if you have one, or have a play with the example and modify it to create your new demo. You'll be working in the `main` branch whilst developing your demo.
15
+ 3. Make sure that you follow the [development guide](#development-guide) and use the pre-configured pre-commit hooks before every commit and push. The validation pipeline will independently gate demos based on these hooks, so to avoid any deployment delays, it's best to run the checks with every commit.
16
+ 4. Once you are happy with your demo and want to get it deployed to Hugging Face spaces in the ibm-granite org, open a pull request to merge the `main` branch into the `stable` branch. This will trigger a build and stage a deployment so that you and the RDTE team can validate the demo works well both from a technical and UX standpoint. If your demo needs any custom environment variables or secrets, let the RDTE team know and we will contact you directly to get them added to the Space configuration on Hugging Face.
17
+ 5. Once the Pull request has been approved, you can merge it into the `stable` branch. A deployment will then push your changes into the Hugging Face spaces git repository and your demo will then be available.
18
+
19
+ ## 🛠️ Development guide
20
+
21
+ Further information on developing the code in this repository is provided below.
22
+
23
+ ### Create a code repository
24
+
25
+ [Use this template](https://github.ibm.com/new?template_name=gradio-template&template_owner=ibm-huggingface-space-demos) to create a new code repository for your demo. This could initially live somewhere else on GitHub if you wish but the RDTE team can also create a repository for you within this [ibm-hugging-face-space-demos](https://github.ibm.com/ibm-huggingface-space-demos) org.
26
+
27
+ Once your code repo has been created on GitHub (from this template), clone the repository to your local machine.
28
+
29
+ ### Prerequisites
30
+
31
+ Some things you will need to do on your machine before developing.
32
+
33
+ #### Precommit
34
+
35
+ [Precommit](https://pre-commit.com) is a tool that adds git commit hooks. You will need to [install](https://pre-commit.com/#install) it on your machine and then run within your code repository:
36
+
37
+ ```shell
38
+ pre-commit install
39
+ ```
40
+
41
+ You can manually run pre-commit using the following command:
42
+
43
+ ```shell
44
+ # To run against staged files:
45
+ pre-commit run
46
+
47
+ # If you want to run against staged and unstaged files:
48
+ pre-commit run --all-files
49
+ ```
50
+
51
+ It is important to run the pre-commit hooks and fix any files that fail before you commit and push to the repository as the pull request build will fail any PR that does not adhere to them i.e. the RDTE team will only accept your code for deployment to Hugging Face once it has passed all of the pre-commit checks.
52
+
53
+ #### Poetry
54
+
55
+ [Poetry](https://python-poetry.org/) is a tool for Python packaging, dependency and virtual environment management that is used to manage the development of this project. You will need to install Poetry locally. There are several ways to install it including through the package manager of your operating system, however, the easiest way to install is likely using their installer, as follows:
56
+
57
+ ```shell
58
+ curl -sSL https://install.python-poetry.org | python3 -
59
+ ```
60
+
61
+ You can also use `pip` and `pipx` to install poetry, the details of which are at https://python-poetry.org/docs/
62
+
63
+ Once installed, the project is configured and controlled via the `pyproject.toml` file with the current dependency tree stored in `poetry.lock`. You may also [configure poetry](https://python-poetry.org/docs/configuration/) further if you wish but there is no need to do so as the default options are sufficient. You may, however, wish to change some of the options set in this template:
64
+ | Setting | Notes |
65
+ | ------- | ----- |
66
+ | name | **Update this**, to reflect the name of your demo |
67
+ | version | **Update this**, to reflect the current version of your demo |
68
+ | description | **Update this**, to a short description of your demo |
69
+ | authors | **Update this**, to the list of authors of your demo |
70
+
71
+ ## Install and run locally
72
+
73
+ To get set up ready to run the code in development mode:
74
+
75
+ ```shell
76
+ # create and activate a python virtual environment
77
+ poetry shell
78
+ poetry install
79
+
80
+ # run the demo locally
81
+ python src/app.py
82
+ ```
83
+
84
+ ## Testing
85
+
86
+ Each demo should have unit tests to validate that the generate functions work correctly, these can be stubbed out so that a GPU is not required. The UX elements will be tested manually in the staging environment.
87
+
88
+ 1. Fork this template
89
+ 2. Update the `.spaces-conf.yaml` with the correct metadata for your project. If you don't know what the fields should be, contact the Research Design Technical Experiences Team.
90
+ 3. Create a virtual environment and install dependencies using poetry
91
+ 4. Run some updates to make sure everything is up-to-date
92
+ 5. Run the example code locally.
93
+
94
+ ## Documenting your demo
95
+
96
+ If you would like to write some information/documentation about your demo that is intended for developers or other people that might want to run the demo from scratch, please use the [README.md](README.md) file, leaving the Hugging Face Spaces configuration header in place at the top of the file.
97
+
98
+ ### Hugging face spaces configuration settings
99
+
100
+ Hugging Face allow the configuration of spaces demonstrations via the [README.md](README.md) file in the root of the project. There is a [Spaces Configuration Reference](https://huggingface.co/docs/hub/en/spaces-config-reference) guide that you can use to gain an understanding of the configuration options that can be specified here.
101
+
102
+ The template has a set of initial defaults, similar to these:
103
+
104
+ ```
105
+ ---
106
+ title: Granite 3.0 Chat
107
+ colorFrom: blue
108
+ colorTo: indigo
109
+ sdk: gradio
110
+ sdk_version: 5.9.1
111
+ app_file: src/app.py
112
+ pinned: false
113
+ license: apache-2.0
114
+ short_description: Chat with IBM Granite 3.0
115
+ ---
116
+ ```
117
+
118
+ #### Options
119
+
120
+ The default options specified above:
121
+ | Setting | Notes |
122
+ | ------- | ----- |
123
+ | title | **Update this**, keep this short (recommend max 24 chars), this information is displayed in the centre of the demo description card |
124
+ | emoji | Do not update this, our demos will use a consistent emoji character |
125
+ | colorFrom | Do not update this, used in combination with colorTo to colourize the demo description card |
126
+ | colorTo | see colorFrom |
127
+ | sdk | Do not update this, our Gradio demos will always use the "gradio" setting |
128
+ | sdk_version | Update this if necessary for your demo to function, ideally should be set to the latest gradio version |
129
+ | app_file | Update this if necessary for your demo to function, should be set to the path of the main entry point to the demo |
130
+ | license | Do not update this, our demos are to always be apache-2.0 licensed |
131
+ | short_description | **Update this**, should be set to a few words that describe the demo in a little more detail than the title, this information is displayed in the bottom-right of the demo description card |
132
+
133
+ Other available options:
134
+ | Setting | Notes |
135
+ | ------- | ----- |
136
+ | python_version | You may optionally set this, best advice is to use the default Python version if possible (current default is Python 3.10) |
137
+ | suggested_hardware | Do not use this, unlikely to be required as demos run on ZeroGPU |
138
+ | suggested_storage | Do not use this, our demos do not require storage |
139
+ | app_port | Do not use this, not relevant for gradio demos |
140
+ | base_path | Do not use this, use the app_file setting |
141
+ | fullWidth | Do not use this, our demos will use a consistent default width |
142
+ | header | Do not use this, our demos will use a consistent header |
143
+ | models | Do not use this, let their parsing discover these from our code |
144
+ | datasets | Do not use this, let their parsing discover these from our code |
145
+ | tags | Do not use this, we are not tagging our demos |
146
+ | thumbnail | Do not use this, provides a thumbnail for social sharing of demos |
147
+ | pinned | Do not use this, the RDTE team will change this setting if it's deemed necessary |
148
+ | hf_oauth | Do not use this, we are not using OAuth |
149
+ | hf_oauth_scopes | Do not use this, we are not using OAuth |
150
+ | hf_oauth_expiration_minutes | Do not use this, we are not using OAuth |
151
+ | disable_embedding | Do not use this, leave at the default that allows embedding to take place |
152
+ | startup_duration_timeout | Do not use this, leave at the default 30 minutes |
153
+ | custom_headers | Do not use this, we do not need to add any custom HTTP headers |
154
+ | preload_from_hub | Do not use this, specifying this builds the models and data sets into the container image with the goal of making start up times faster due to not needing to download them each time. However, RDTE testing indicates this setting significantly increases the start up time for our relatively small Granite models |
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Granite 3.0 Chat template example.
3
+ emoji: 📝
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 5.9.1
8
+ app_file: src/app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ short_description: Chat with IBM Granite 3.0
12
+ ---
poetry.lock ADDED
The diff for this file is too large to render. See raw diff
 
pyproject.toml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "huggingface-gradio-template"
3
+ version = "0.1.0"
4
+ description = "A boilerplate template for an IBM Granite Huggingface Spaces Gradio Demo"
5
+ authors = ["James Sutton <[email protected]>"]
6
+ license = "Apache-2.0"
7
+ readme = "README.md"
8
+ package-mode = false
9
+
10
+ [tool.poetry.dependencies]
11
+ python = ">=3.10,<3.11"
12
+ gradio = "5.9.1"
13
+ torch = "2.4.0"
14
+ spaces = "0.30.4"
15
+ transformers = "^4.47.1"
16
+ accelerate = "^1.2.1"
17
+
18
+
19
+ [tool.poetry.group.dev.dependencies]
20
+ pre-commit = "^4.0.1"
21
+ git-lint = "^0.1.2"
22
+ ruff = "^0.8.3"
23
+ pytest = "^8.3.4"
24
+
25
+
26
+ [build-system]
27
+ requires = ["poetry-core"]
28
+ build-backend = "poetry.core.masonry.api"
29
+
30
+
31
+ [tool.ruff]
32
+ select = [
33
+ "E", # pycodestyle
34
+ "F", # pyflakes
35
+ "UP", # pyupgrade
36
+ "D", # pydocstyle
37
+ "I", # isort
38
+ "B", # bugbear
39
+ "ANN", # annotations
40
+ "N", # pep8-naming
41
+ "C4", # Comprehensions
42
+ "DTZ", # DatetimeZ
43
+ "Q", # Quotes
44
+ "SIM", # Simplify
45
+ "RUF", # Ruff
46
+ ]
47
+ ignore = ["D203", "D213"]
48
+ fixable = ["ALL"]
49
+ unfixable = []
50
+ line-length = 120
51
+
52
+
53
+ [tool.black]
54
+ line-length = 120
55
+
56
+ [tool.ruff.lint.pydocstyle]
57
+ convention = "google"
requirements.txt ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate==1.2.1 ; python_version >= "3.10" and python_version < "3.11"
2
+ aiofiles==23.2.1 ; python_version >= "3.10" and python_version < "3.11"
3
+ annotated-types==0.7.0 ; python_version >= "3.10" and python_version < "3.11"
4
+ anyio==4.8.0 ; python_version >= "3.10" and python_version < "3.11"
5
+ certifi==2024.12.14 ; python_version >= "3.10" and python_version < "3.11"
6
+ charset-normalizer==3.4.1 ; python_version >= "3.10" and python_version < "3.11"
7
+ click==8.1.8 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
8
+ colorama==0.4.6 ; python_version >= "3.10" and python_version < "3.11" and platform_system == "Windows"
9
+ exceptiongroup==1.2.2 ; python_version >= "3.10" and python_version < "3.11"
10
+ fastapi==0.115.6 ; python_version >= "3.10" and python_version < "3.11"
11
+ ffmpy==0.5.0 ; python_version >= "3.10" and python_version < "3.11"
12
+ filelock==3.16.1 ; python_version >= "3.10" and python_version < "3.11"
13
+ fsspec==2024.12.0 ; python_version >= "3.10" and python_version < "3.11"
14
+ gradio-client==1.5.2 ; python_version >= "3.10" and python_version < "3.11"
15
+ gradio==5.9.1 ; python_version >= "3.10" and python_version < "3.11"
16
+ h11==0.14.0 ; python_version >= "3.10" and python_version < "3.11"
17
+ httpcore==1.0.7 ; python_version >= "3.10" and python_version < "3.11"
18
+ httpx==0.28.1 ; python_version >= "3.10" and python_version < "3.11"
19
+ huggingface-hub==0.27.1 ; python_version >= "3.10" and python_version < "3.11"
20
+ idna==3.10 ; python_version >= "3.10" and python_version < "3.11"
21
+ jinja2==3.1.5 ; python_version >= "3.10" and python_version < "3.11"
22
+ markdown-it-py==3.0.0 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
23
+ markupsafe==2.1.5 ; python_version >= "3.10" and python_version < "3.11"
24
+ mdurl==0.1.2 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
25
+ mpmath==1.3.0 ; python_version >= "3.10" and python_version < "3.11"
26
+ networkx==3.4.2 ; python_version >= "3.10" and python_version < "3.11"
27
+ numpy==2.2.1 ; python_version >= "3.10" and python_version < "3.11"
28
+ nvidia-cublas-cu12==12.1.3.1 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
29
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
30
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
31
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
32
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
33
+ nvidia-cufft-cu12==11.0.2.54 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
34
+ nvidia-curand-cu12==10.3.2.106 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
35
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
36
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
37
+ nvidia-nccl-cu12==2.20.5 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
38
+ nvidia-nvjitlink-cu12==12.6.85 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
39
+ nvidia-nvtx-cu12==12.1.105 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version >= "3.10" and python_version < "3.11"
40
+ orjson==3.10.13 ; python_version >= "3.10" and python_version < "3.11"
41
+ packaging==24.2 ; python_version >= "3.10" and python_version < "3.11"
42
+ pandas==2.2.3 ; python_version >= "3.10" and python_version < "3.11"
43
+ pillow==11.1.0 ; python_version >= "3.10" and python_version < "3.11"
44
+ psutil==5.9.8 ; python_version >= "3.10" and python_version < "3.11"
45
+ pydantic-core==2.27.2 ; python_version >= "3.10" and python_version < "3.11"
46
+ pydantic==2.10.4 ; python_version >= "3.10" and python_version < "3.11"
47
+ pydub==0.25.1 ; python_version >= "3.10" and python_version < "3.11"
48
+ pygments==2.19.1 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
49
+ python-dateutil==2.9.0.post0 ; python_version >= "3.10" and python_version < "3.11"
50
+ python-multipart==0.0.20 ; python_version >= "3.10" and python_version < "3.11"
51
+ pytz==2024.2 ; python_version >= "3.10" and python_version < "3.11"
52
+ pyyaml==6.0.2 ; python_version >= "3.10" and python_version < "3.11"
53
+ regex==2024.11.6 ; python_version >= "3.10" and python_version < "3.11"
54
+ requests==2.32.3 ; python_version >= "3.10" and python_version < "3.11"
55
+ rich==13.9.4 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
56
+ ruff==0.8.6 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
57
+ safehttpx==0.1.6 ; python_version >= "3.10" and python_version < "3.11"
58
+ safetensors==0.5.1 ; python_version >= "3.10" and python_version < "3.11"
59
+ semantic-version==2.10.0 ; python_version >= "3.10" and python_version < "3.11"
60
+ shellingham==1.5.4 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
61
+ six==1.17.0 ; python_version >= "3.10" and python_version < "3.11"
62
+ sniffio==1.3.1 ; python_version >= "3.10" and python_version < "3.11"
63
+ spaces==0.30.4 ; python_version >= "3.10" and python_version < "3.11"
64
+ starlette==0.41.3 ; python_version >= "3.10" and python_version < "3.11"
65
+ sympy==1.13.3 ; python_version >= "3.10" and python_version < "3.11"
66
+ tokenizers==0.21.0 ; python_version >= "3.10" and python_version < "3.11"
67
+ tomlkit==0.13.2 ; python_version >= "3.10" and python_version < "3.11"
68
+ torch==2.4.0 ; python_version >= "3.10" and python_version < "3.11"
69
+ tqdm==4.67.1 ; python_version >= "3.10" and python_version < "3.11"
70
+ transformers==4.47.1 ; python_version >= "3.10" and python_version < "3.11"
71
+ triton==3.0.0 ; platform_system == "Linux" and platform_machine == "x86_64" and python_version < "3.11" and python_version >= "3.10"
72
+ typer==0.15.1 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
73
+ typing-extensions==4.12.2 ; python_version >= "3.10" and python_version < "3.11"
74
+ tzdata==2024.2 ; python_version >= "3.10" and python_version < "3.11"
75
+ urllib3==2.3.0 ; python_version >= "3.10" and python_version < "3.11"
76
+ uvicorn==0.34.0 ; python_version >= "3.10" and python_version < "3.11" and sys_platform != "emscripten"
77
+ websockets==14.1 ; python_version >= "3.10" and python_version < "3.11"
src/app.css ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ footer {
2
+ display: none !important;
3
+ }
src/app.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Template Demo for IBM Granite Hugging Face spaces."""
2
+
3
+ from collections.abc import Iterator
4
+ from datetime import datetime
5
+ from pathlib import Path
6
+ from threading import Thread
7
+
8
+ import gradio as gr
9
+ import spaces
10
+ import torch
11
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
12
+
13
+ from themes.carbon import carbon_theme
14
+
15
+ today_date = datetime.today().strftime("%B %-d, %Y") # noqa: DTZ002
16
+
17
+ MODEL_ID = "ibm-granite/granite-3.1-8b-instruct"
18
+ SYS_PROMPT = f"""Knowledge Cutoff Date: April 2024.
19
+ Today's Date: {today_date}.
20
+ You are Granite, developed by IBM. You are a helpful AI assistant"""
21
+ TITLE = "IBM Granite 3.1 8b Instruct"
22
+ DESCRIPTION = "Try one of the sample prompts below or write your own. Remember, just like developers, \
23
+ AI models can make mistakes."
24
+ MAX_INPUT_TOKEN_LENGTH = 4096
25
+ MAX_NEW_TOKENS = 1024
26
+ TEMPERATURE = 0.7
27
+ TOP_P = 0.85
28
+ TOP_K = 50
29
+ REPETITION_PENALTY = 1.05
30
+
31
+ if not torch.cuda.is_available():
32
+ DESCRIPTION += "\nThis demo does not work on CPU."
33
+
34
+ model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.float16, device_map="auto")
35
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
36
+ tokenizer.use_default_system_prompt = False
37
+
38
+
39
+ @spaces.GPU
40
+ def generate(message: str, chat_history: list[dict]) -> Iterator[str]:
41
+ """Generate function for chat demo."""
42
+ # Build messages
43
+ conversation = []
44
+ conversation.append({"role": "system", "content": SYS_PROMPT})
45
+ conversation += chat_history
46
+ conversation.append({"role": "user", "content": message})
47
+
48
+ # Convert messages to prompt format
49
+ input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True)
50
+
51
+ if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
52
+ input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
53
+ gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
54
+
55
+ input_ids = input_ids.to(model.device)
56
+ streamer = TextIteratorStreamer(tokenizer, timeout=30.0, skip_prompt=True, skip_special_tokens=True)
57
+ generate_kwargs = dict(
58
+ {"input_ids": input_ids},
59
+ streamer=streamer,
60
+ max_new_tokens=MAX_NEW_TOKENS,
61
+ do_sample=True,
62
+ top_p=TOP_P,
63
+ top_k=TOP_K,
64
+ temperature=TEMPERATURE,
65
+ num_beams=1,
66
+ repetition_penalty=REPETITION_PENALTY,
67
+ )
68
+
69
+ t = Thread(target=model.generate, kwargs=generate_kwargs)
70
+ t.start()
71
+
72
+ outputs = []
73
+ for text in streamer:
74
+ outputs.append(text)
75
+ yield "".join(outputs)
76
+
77
+
78
+ chat_interface = gr.ChatInterface(
79
+ fn=generate,
80
+ stop_btn=None,
81
+ examples=[
82
+ ["Explain quantum computing"],
83
+ ["What is OpenShift?"],
84
+ ["Importance of low latency inference"],
85
+ ["Boosting productivity habits"],
86
+ ],
87
+ cache_examples=False,
88
+ type="messages",
89
+ )
90
+
91
+ css_file_path = Path(Path(__file__).parent / "app.css")
92
+ head_file_path = Path(Path(__file__).parent / "app_head.html")
93
+
94
+ with gr.Blocks(
95
+ fill_height=True, css_paths=css_file_path, head_paths=head_file_path, theme=carbon_theme, title=TITLE
96
+ ) as demo:
97
+ gr.Markdown(f"# {TITLE}")
98
+ gr.Markdown(DESCRIPTION)
99
+ chat_interface.render()
100
+
101
+ if __name__ == "__main__":
102
+ demo.queue(max_size=20).launch()
src/app_head.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script
2
+ async
3
+ src="https://www.googletagmanager.com/gtag/js?id=G-C6LFT227RC"
4
+ ></script>
5
+ <script>
6
+ window.dataLayer = window.dataLayer || [];
7
+ function gtag() {
8
+ dataLayer.push(arguments);
9
+ }
10
+ gtag("js", new Date());
11
+ gtag("config", "G-C6LFT227RC");
12
+ </script>
src/themes/carbon.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """IBM Carbon theme for gradio demos.
2
+
3
+ This version builds on top of the Carbon theme to make it more playful with rounded corners, a larger font family to
4
+ enhance readability, and the IBM Cool Gray color palette for better consistency with other IBM Research demos, such as
5
+ Bee.
6
+ """
7
+
8
+ import gradio as gr
9
+
10
+ carbon_theme = gr.themes.Base(
11
+ primary_hue=gr.themes.Color(
12
+ c100="#EDF5FF",
13
+ c200="#D0E2FF",
14
+ c300="#A6C8FF",
15
+ c400="#78A9FF",
16
+ c50="#F9F9FB",
17
+ c500="#4589FF",
18
+ c600="#0F62FE",
19
+ c700="#0043CE",
20
+ c800="#002D9C",
21
+ c900="#001D6C",
22
+ c950="#001141",
23
+ ),
24
+ secondary_hue=gr.themes.Color(
25
+ c100="#EDF5FF",
26
+ c200="#D0E2FF",
27
+ c300="#A6C8FF",
28
+ c400="#78A9FF",
29
+ c50="#F9F9FB",
30
+ c500="#4589FF",
31
+ c600="#0F62FE",
32
+ c700="#0043CE",
33
+ c800="#002D9C",
34
+ c900="#001D6C",
35
+ c950="#001141",
36
+ ),
37
+ neutral_hue=gr.themes.Color(
38
+ c100="#F2F4F8",
39
+ c200="#DDE1E6",
40
+ c300="#C1C7CD",
41
+ c400="#A2A9B0",
42
+ c50="#F9F9FB",
43
+ c500="#878D96",
44
+ c600="#697077",
45
+ c700="#4D5358",
46
+ c800="#393939",
47
+ c900="#21272A",
48
+ c950="#121619",
49
+ ),
50
+ text_size=gr.themes.Size(lg="28px", md="20px", sm="16px", xl="36px", xs="14px", xxl="42px", xxs="12px"),
51
+ spacing_size=gr.themes.Size(lg="8px", md="6px", sm="4px", xl="10px", xs="2px", xxl="16px", xxs="1px"),
52
+ radius_size=gr.themes.Size(lg="8px", md="6px", sm="4px", xl="10px", xs="2px", xxl="16px", xxs="1px"),
53
+ font=["IBM Plex Sans", "ui-sans-serif", "system-ui", "sans-serif"],
54
+ font_mono=["IBM Plex Mono", "ui-monospace", "Consolas", "monospace"],
55
+ ).set(
56
+ body_text_color="*neutral_800", # Carbon primary text color #161616
57
+ body_text_color_dark="*neutral_50",
58
+ body_text_size="*text_sm",
59
+ body_text_color_subdued="*neutral_300",
60
+ body_text_color_subdued_dark="*neutral_500",
61
+ body_text_weight="300",
62
+ # Attributes to create cool gray 10 background color and white block background color
63
+ embed_radius="*radius_md",
64
+ background_fill_primary="*neutral_100", # Coolgray10 background
65
+ block_background_fill="white",
66
+ block_border_color="*neutral_200", # The border color around an block
67
+ block_label_background_fill="white", # The background color for the block label
68
+ block_label_border_color="*neutral_100", # The border color for the block label
69
+ background_fill_secondary="*background_fill_primary",
70
+ background_fill_secondary_dark="*neutral_950",
71
+ border_color_accent="*neutral_100",
72
+ border_color_accent_dark="*neutral_800",
73
+ border_color_primary="*neutral_300",
74
+ border_color_primary_dark="*neutral_800",
75
+ # Chatbubble related colors
76
+ # light
77
+ # color_accent = "*secondary_400",
78
+ border_color_accent_subdued="*color_accent_soft", # chatbubble human border color, use Blue 20 as an accent color
79
+ color_accent_soft="*secondary_200", # chatbubble human color
80
+ # darkmode
81
+ # chatbubble human border color in darkmode, use Blue 20 as an accent color
82
+ border_color_accent_subdued_dark="*secondary_500",
83
+ color_accent_soft_dark="*secondary_500", # chatbubble human color in dark mode
84
+ shadow_drop="*block_label_shadow",
85
+ shadow_drop_lg="0px 1px 2px 0px rgba(0, 0, 0, 0.07)",
86
+ shadow_inset="0px 2px 4px 0px rgba(0, 0, 0, 0.07) inset, 0px 0px 3px 0px rgba(0, 0, 0, 0.00) inset",
87
+ shadow_spread="1px",
88
+ chatbot_text_size="*text_sm", # make it larger
89
+ checkbox_background_color_hover="*neutral_50",
90
+ checkbox_background_color_hover_dark="*neutral_50",
91
+ checkbox_background_color_selected="*neutral_800",
92
+ checkbox_background_color_selected_dark="*neutral_800",
93
+ checkbox_border_color_selected="*neutral_950",
94
+ checkbox_border_color_selected_dark="*neutral_950",
95
+ checkbox_label_border_width="1px",
96
+ checkbox_label_border_width_dark="1px",
97
+ checkbox_label_padding="*spacing_xs",
98
+ checkbox_label_text_size="*text_xs",
99
+ input_background_fill="white",
100
+ input_background_fill_dark="*neutral_800",
101
+ input_border_color_focus="*primary_500",
102
+ input_border_width="1px",
103
+ input_border_width_dark="1px",
104
+ input_padding="*spacing_lg",
105
+ input_text_size="*text_sm", # text size for the input filed
106
+ button_large_padding="*spacing_sm",
107
+ button_small_padding="*spacing_xxs",
108
+ button_primary_border_color_dark="*primary_600",
109
+ button_primary_border_color_hover_dark="*primary_700",
110
+ button_primary_shadow="*shadow_drop",
111
+ button_primary_shadow_hover="*shadow_drop_lg",
112
+ button_secondary_background_fill="white",
113
+ button_secondary_background_fill_hover="*neutral_600",
114
+ button_secondary_border_color="*neutral_800",
115
+ button_secondary_border_color_hover_dark="*neutral_700",
116
+ button_secondary_shadow_hover="*shadow_drop_lg",
117
+ )