From 298a5a8ad54bfa52b683adee786ba11292789c5d Mon Sep 17 00:00:00 2001 From: Aleksandr Movchan Date: Tue, 30 Jul 2024 13:33:32 +0200 Subject: [PATCH] Initial commit --- .devcontainer/Dockerfile | 2 + .devcontainer/devcontainer.json | 35 ++++ .github/rename_project.sh | 33 ++++ .github/template.yml | 0 .github/workflows/rename_project.yaml | 39 +++++ .gitignore | 162 +++++++++++++++++ .vscode/settings.json | 8 + LICENSE | 201 ++++++++++++++++++++++ README.md | 115 +++++++++++++ aana_app_project/__init__.py | 0 aana_app_project/app.py | 17 ++ aana_app_project/configs/__init__.py | 0 aana_app_project/configs/deployments.py | 25 +++ aana_app_project/configs/endpoints.py | 17 ++ aana_app_project/configs/settings.py | 13 ++ aana_app_project/core/__init__.py | 0 aana_app_project/core/models/__init__.py | 0 aana_app_project/core/prompts/__init__.py | 0 aana_app_project/core/prompts/loader.py | 25 +++ aana_app_project/core/prompts/test.j2 | 1 + aana_app_project/deployments/__init__.py | 0 aana_app_project/endpoints/__init__.py | 0 aana_app_project/exceptions/core.py | 1 + aana_app_project/tests/__init__.py | 0 aana_app_project/utils/__init__.py | 0 aana_app_project/utils/core.py | 0 pyproject.toml | 18 ++ 27 files changed, 712 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100755 .github/rename_project.sh create mode 100644 .github/template.yml create mode 100644 .github/workflows/rename_project.yaml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 LICENSE create mode 100644 README.md create mode 100644 aana_app_project/__init__.py create mode 100644 aana_app_project/app.py create mode 100644 aana_app_project/configs/__init__.py create mode 100644 aana_app_project/configs/deployments.py create mode 100644 aana_app_project/configs/endpoints.py create mode 100644 aana_app_project/configs/settings.py create mode 100644 aana_app_project/core/__init__.py create mode 100644 aana_app_project/core/models/__init__.py create mode 100644 aana_app_project/core/prompts/__init__.py create mode 100644 aana_app_project/core/prompts/loader.py create mode 100644 aana_app_project/core/prompts/test.j2 create mode 100644 aana_app_project/deployments/__init__.py create mode 100644 aana_app_project/endpoints/__init__.py create mode 100644 aana_app_project/exceptions/core.py create mode 100644 aana_app_project/tests/__init__.py create mode 100644 aana_app_project/utils/__init__.py create mode 100644 aana_app_project/utils/core.py create mode 100644 pyproject.toml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1ecd795 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,2 @@ +FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04 +RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 ffmpeg diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..b92df9f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +{ + "name": "Ubuntu", + "build": { + "dockerfile": "Dockerfile" + }, + "capAdd": [ + "SYS_PTRACE" + ], + "features": { + "ghcr.io/devcontainers/features/python:1": { + "installTools": true, + "version": "3.10" + }, + "ghcr.io/devcontainers-contrib/features/poetry:2": { + "version": "latest" + } + }, + "hostRequirements": { + "gpu": "optional" + }, + "securityOpt": [ + "seccomp=unconfined" + ], + "postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}", + "customizations": { + "vscode": { + "extensions": [ + "charliermarsh.ruff", + "ms-python.python", + "ms-python.mypy-type-checker", + "ms-toolsai.jupyter" + ] + } + } +} \ No newline at end of file diff --git a/.github/rename_project.sh b/.github/rename_project.sh new file mode 100755 index 0000000..da30630 --- /dev/null +++ b/.github/rename_project.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +while getopts a:n:d: flag +do + case "${flag}" in + a) author=${OPTARG};; + n) name=${OPTARG};; + d) description=${OPTARG};; + esac +done + +echo "Author: $author"; +echo "Project Name: $name"; +echo "Description: $description"; + +echo "Renaming project..." + +original_author="author_name" +original_name="aana_app_project" +original_description="project_description" +for filename in $(git ls-files) +do + sed -i "s/$original_author/$author/g" $filename + sed -i "s/$original_name/$name/g" $filename + sed -i "s/$original_description/$description/g" $filename + echo "Renamed $filename" +done + +mv $original_name $name + +# This command runs only once on GHA! +rm -rf .github/template.yml +rm -rf .github/workflows/rename_project.yaml +rm -rf .github/rename_project.sh \ No newline at end of file diff --git a/.github/template.yml b/.github/template.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/rename_project.yaml b/.github/workflows/rename_project.yaml new file mode 100644 index 0000000..b51a4ab --- /dev/null +++ b/.github/workflows/rename_project.yaml @@ -0,0 +1,39 @@ +name: Rename the project from template + +on: [push] + +permissions: write-all + +jobs: + rename-project: + if: ${{ !contains (github.repository, '/aana_app_template') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + # by default, it uses a depth of 1 + # this fetches all history so that we can read each commit + fetch-depth: 0 + ref: ${{ github.head_ref }} + + - run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + shell: bash + + - run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV + shell: bash + + - name: Is this still a template + id: is_template + run: echo "::set-output name=is_template::$(ls .github/template.yml &> /dev/null && echo true || echo false)" + + - name: Rename the project + if: steps.is_template.outputs.is_template == 'true' + run: | + echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }}" + .github/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -d "" + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "✅ Ready to clone and code." + # commit_options: '--amend --no-edit' + push_options: --force \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..82f9275 --- /dev/null +++ b/.gitignore @@ -0,0 +1,162 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..560f428 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "python.analysis.packageIndexDepths": [ + { + "name": "aana", + "depth": 10, + } + ], +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3d87d76 --- /dev/null +++ b/README.md @@ -0,0 +1,115 @@ +# Aana Application Template + +[Aana SDK](https://github.com/mobiusml/aana_sdk) is a powerful framework for building multimodal applications. It facilitates the large-scale deployment of machine learning models, including those for vision, audio, and language, and supports Retrieval-Augmented Generation (RAG) systems. This enables the development of advanced applications such as search engines, recommendation systems, and data insights platforms. + +This repository contains a template that you can use to start building your own Aana application. It will help you get started with the Aana SDK and provide you with a basic structure for your application and its dependencies. + +## How to use this template + +1. Click on [Use this template](https://github.com/mobiusml/aana_app_template/generate). +2. Give your repository a name and click on "Create repository". The name of the repository will also be the name of your application and the Python package. +3. Wait for the first workflow to finish. This will rename the package to match the repository name. +4. Clone the repository to your local machine and start building your application. +5. Change the [LICENSE](/LICENSE) file to match your project's license. The default license is the Apache License 2.0. + +## Getting started + +The project template uses [Poetry](https://python-poetry.org/) for dependency management. To install the project, run the following commands: + +```bash +poetry install +``` + +See [Tutorial](https://github.com/mobiusml/aana_sdk/blob/main/docs/tutorial.md) for more information on how to build your application. + +## Project structure + +``` +aana_app_project/ +├── config/ | various configs, including settings, deployments and endpoints +│ ├── endpoints.py | list of endpoints to deploy +│ ├── deployments.py | list of deployments (models) to deploy +│ └── settings.py | app settings +├── core/ | core models and functionality +│ ├── models/ | data models +│ └── prompts/ | prompt templates for LLMs +├── deployments/ | custom deployments +├── endpoints/ | endpoint classes for the app +├── exceptions/ | custom exception classes +├── utils/ | various utility functionality +└── app.py | main application file +``` + + +## Installation + +To install the project, follow these steps: + +1. Clone the repository. + +2. Install the package with Poetry. + +The project is managed with [Poetry](https://python-poetry.org/docs/). See the [Poetry installation instructions](https://python-poetry.org/docs/#installation) on how to install it on your system. + +It will install the package and all dependencies in a virtual environment. + +```bash +poetry install +``` + +3. Install additional libraries. + +For optimal performance, you should also install [PyTorch](https://pytorch.org/get-started/locally/) version >=2.1 appropriate for your system. You can continue directly to the next step, but it will install a default version that may not make optimal use of your system's resources, for example, a GPU or even some SIMD operations. Therefore we recommend choosing your PyTorch package carefully and installing it manually. + +Some models use Flash Attention. Install Flash Attention library for better performance. See [flash attention installation instructions](https://github.com/Dao-AILab/flash-attention?tab=readme-ov-file#installation-and-features) for more details and supported GPUs. + + +4. Activate the Poetry environment. + +To activate the Poetry environment, run the following command: + +```bash +poetry shell +``` + +Alternatively, you can run commands in the Poetry environment by prefixing them with `poetry run`. For example: + +```bash +poetry run aana deploy aana_app_project.app:aana_app +``` + +5. Run the app. + +```bash +aana deploy aana_app_project.app:aana_app +``` + +## Usage + +To use the project, follow these steps: + +1. Run the app as described in the installation section. + +```bash +aana deploy aana_app_project.app:aana_app +``` + +Once the application is running, you will see the message `Deployed successfully.` in the logs. It will also show the URL for the API documentation. + +> **⚠️ Warning** +> +> If the application is using GPU, make sure that the GPU is available and the application can access it. +> +> The applications will detect the available GPU automatically but you need to make sure that `CUDA_VISIBLE_DEVICES` is set correctly. +> +> Sometimes `CUDA_VISIBLE_DEVICES` is set to an empty string and the application will not be able to detect the GPU. Use `unset CUDA_VISIBLE_DEVICES` to unset the variable. +> +> You can also set the `CUDA_VISIBLE_DEVICES` environment variable to the GPU index you want to use: `export CUDA_VISIBLE_DEVICES=0`. + +2. Send a POST request to the app. + +For example, if your application has `/summary` endpoint that accepts videos, you can send a POST request like this: + +```bash +curl -X POST http://127.0.0.1:8000/summary -Fbody='{"video":{"url":"https://www.youtube.com/watch?v=VhJFyyukAzA"}}' +``` diff --git a/aana_app_project/__init__.py b/aana_app_project/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/app.py b/aana_app_project/app.py new file mode 100644 index 0000000..fddb40e --- /dev/null +++ b/aana_app_project/app.py @@ -0,0 +1,17 @@ +from aana.sdk import AanaSDK + +from aana_app_project.configs.deployments import deployments +from aana_app_project.configs.endpoints import endpoints + +aana_app = AanaSDK(name="aana_app_project") + +for deployment in deployments: + aana_app.register_deployment(**deployment) + +for endpoint in endpoints: + aana_app.register_endpoint(**endpoint) + +if __name__ == "__main__": + aana_app.connect() + aana_app.migrate() + aana_app.deploy() diff --git a/aana_app_project/configs/__init__.py b/aana_app_project/configs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/configs/deployments.py b/aana_app_project/configs/deployments.py new file mode 100644 index 0000000..3020f53 --- /dev/null +++ b/aana_app_project/configs/deployments.py @@ -0,0 +1,25 @@ +deployments: list[dict] = [] + +# Add deployments for models that you want to deploy here. +# +# For example: +# from aana.deployments.whisper_deployment import ( +# WhisperComputeType, +# WhisperConfig, +# WhisperDeployment, +# WhisperModelSize, +# ) +# asr_deployment = WhisperDeployment.options( +# num_replicas=1, +# ray_actor_options={"num_gpus": 0.1}, +# user_config=WhisperConfig( +# model_size=WhisperModelSize.MEDIUM, +# compute_type=WhisperComputeType.FLOAT16, +# ).model_dump(mode="json"), +# ) +# deployments.append({"name": "asr_deployment", "instance": asr_deployment}) +# +# You can use predefined deployments from the Aana SDK or create your own. +# See https://github.com/mobiusml/aana_sdk/blob/main/docs/integrations.md for the list of predefined deployments. +# +# If you want to create your own deployment, put your deployment classes in a separate files in the `deployments` directory and import them here. diff --git a/aana_app_project/configs/endpoints.py b/aana_app_project/configs/endpoints.py new file mode 100644 index 0000000..c0bf4e0 --- /dev/null +++ b/aana_app_project/configs/endpoints.py @@ -0,0 +1,17 @@ +endpoints: list[dict] = [] + +# Add your endpoints here. +# +# For example: +# endpoints.append( +# { +# "name": "predict", +# "path": "/predict", +# "summary": "Predict the class of an image.", +# "endpoint_cls": PredictEndpoint, +# } +# ) +# +# Endpoints can be created by inheriting from the `Endpoint` class. +# Put your endpoint classes in a separate files in the `endpoints` directory and import them here. +# See https://github.com/mobiusml/aana_sdk/tree/main?tab=readme-ov-file#endpoints in how to create endpoints. diff --git a/aana_app_project/configs/settings.py b/aana_app_project/configs/settings.py new file mode 100644 index 0000000..0199174 --- /dev/null +++ b/aana_app_project/configs/settings.py @@ -0,0 +1,13 @@ +from aana.configs.settings import Settings as AanaSettings + + +class Settings(AanaSettings): + """A pydantic model for App settings.""" + # Add your custom settings here + # Then, you can access them in your app like this: + # from aana_app_project.configs.settings import settings + # settings.custom_property + pass + + +settings = Settings() diff --git a/aana_app_project/core/__init__.py b/aana_app_project/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/core/models/__init__.py b/aana_app_project/core/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/core/prompts/__init__.py b/aana_app_project/core/prompts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/core/prompts/loader.py b/aana_app_project/core/prompts/loader.py new file mode 100644 index 0000000..f71aa9e --- /dev/null +++ b/aana_app_project/core/prompts/loader.py @@ -0,0 +1,25 @@ +from jinja2 import Environment, PackageLoader, Template + + +def get_prompt_template(name: str) -> Template: + """Load a prompt template by name. + + Use this function to load a prompt templates for LLMs: + + ```python + from aana_app_project.core.prompts.loader import get_prompt_template + + template = get_prompt_template("test") + prompt = template.render(your_variable="your_value") + ``` + + Args: + name (str): The name of the prompt template. + + Returns: + Template: The prompt template. + """ + env = Environment(loader=PackageLoader( + "aana_app_project.core", "prompts")) + template = env.get_template(f"{name}.j2") + return template diff --git a/aana_app_project/core/prompts/test.j2 b/aana_app_project/core/prompts/test.j2 new file mode 100644 index 0000000..ce86fac --- /dev/null +++ b/aana_app_project/core/prompts/test.j2 @@ -0,0 +1 @@ +Define your prompts for LLMs here. Use jinja2 templating to include variables like {{ your_variable }}. \ No newline at end of file diff --git a/aana_app_project/deployments/__init__.py b/aana_app_project/deployments/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/endpoints/__init__.py b/aana_app_project/endpoints/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/exceptions/core.py b/aana_app_project/exceptions/core.py new file mode 100644 index 0000000..9693de9 --- /dev/null +++ b/aana_app_project/exceptions/core.py @@ -0,0 +1 @@ +from aana.exceptions.core import BaseException diff --git a/aana_app_project/tests/__init__.py b/aana_app_project/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/utils/__init__.py b/aana_app_project/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aana_app_project/utils/core.py b/aana_app_project/utils/core.py new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..da4f5a8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[tool.poetry] +name = "aana_app_project" +version = "0.1.0" +description = "project_description" +authors = ["author_name"] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.10" +aana = ">=0.2.1" + +[tool.poetry.group.dev.dependencies] +ipykernel = "^6.29.4" +ruff = "^0.1.5" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"