├── .flake8 ├── .github ├── release.yml └── workflows │ ├── docs.yaml │ └── mega-linter.yml ├── .gitignore ├── .mega-linter.yml ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── .spellcheck.yml ├── .yaml-lint.yml ├── README.md ├── docs ├── css │ └── extra.css ├── getting_started │ ├── background.md │ ├── overview.md │ └── quickstart.md ├── images │ ├── logo.png │ ├── logo.svg │ ├── logo_color.png │ └── opaque_prompts_logo.png ├── index.md ├── overrides │ └── partials │ │ └── integrations │ │ └── analytics │ │ └── custom.html ├── reference │ └── library_api.md ├── requirements.in ├── requirements.txt └── spelling_wordlist.txt ├── mkdocs.yml ├── pyproject.toml ├── python-package ├── LICENSE ├── README.md ├── pyproject.toml ├── setup.py └── src │ └── opaqueprompts │ ├── __init__.py │ ├── authentication.py │ ├── configuration.py │ └── opaqueprompts_service.py └── scripts └── install_pre_commit.sh /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = 3 | # E203: Whitespace before ':' 4 | # Causing false positive on list slices 5 | # https://github.com/PyCQA/pycodestyle/issues/373 6 | E203, 7 | # E266: Too many leading '#' for block comment 8 | # This rule is too strict for comment blocks that we currently have 9 | E266, 10 | # W503: Line break occurred before a binary operator 11 | # PEP8 now recommend line breaks should occur before the binary operator 12 | W503 13 | exclude = 14 | .git, 15 | __pycache__, 16 | max-line-length = 79 17 | max-doc-length = 79 18 | max-complexity = 18 19 | select = B,C,E,F,W,T4,B9 20 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | changelog: 3 | exclude: 4 | labels: [] 5 | authors: [] 6 | categories: 7 | - title: User-facing features 8 | labels: 9 | - feat 10 | - title: Bug fixes 11 | labels: 12 | - fix 13 | - title: Performance improvements 14 | labels: 15 | - perf 16 | - title: Documentation updates 17 | labels: 18 | - docs 19 | - title: Formatting changes 20 | labels: 21 | - style 22 | - title: Refactoring 23 | labels: 24 | - refactor 25 | - title: Test updates 26 | labels: 27 | - test 28 | - title: Build system updates 29 | labels: 30 | - build 31 | -------------------------------------------------------------------------------- /.github/workflows/docs.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Spellcheck Documentation 3 | 4 | on: 5 | push: 6 | branches: 7 | - dev 8 | - master 9 | paths: 10 | - 'docs/**' 11 | pull_request: 12 | paths: 13 | - 'docs/**' 14 | 15 | # Only allow one run of this workflow per PR at a time. 16 | # 17 | # This will cancel any still-running workflows triggered by a previous commit to 18 | # this PR. Note this will not affect workflows triggered by a push (e.g. merging 19 | # a PR to `dev` or `master`). 20 | concurrency: 21 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 22 | cancel-in-progress: true 23 | 24 | jobs: 25 | spellcheck: 26 | runs-on: ubuntu-20.04 27 | steps: 28 | - name: Checkout repo 29 | uses: actions/checkout@v4 30 | 31 | # Spellcheck documentation 32 | - name: Spellcheck 33 | uses: rojopolis/spellcheck-github-actions@0.36.0 34 | with: 35 | config_path: .spellcheck.yml 36 | -------------------------------------------------------------------------------- /.github/workflows/mega-linter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # MegaLinter GitHub Action configuration file 3 | # More info at https://oxsecurity.github.io/megalinter 4 | name: MegaLinter 5 | 6 | # Run this workflow every time a new commit pushed to your repository 7 | on: 8 | push: 9 | branches: 10 | - dev 11 | - master 12 | pull_request: 13 | branches: 14 | - dev 15 | - release-* 16 | - hotfix-* 17 | - master 18 | 19 | env: 20 | # Apply linter fixes configuration, see link for details 21 | # https://oxsecurity.github.io/megalinter/latest/configuration/#apply-fixes 22 | APPLY_FIXES: none # do not apply any fixes 23 | APPLY_FIXES_EVENT: pull_request 24 | APPLY_FIXES_MODE: commit 25 | 26 | # Only allow one run of this workflow per PR at a time. 27 | # 28 | # This will cancel any still-running workflows triggered by a previous commit to 29 | # this PR. Note this will not affect workflows triggered by a push (e.g. merging 30 | # a PR to `dev` or `master`). 31 | concurrency: 32 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 33 | cancel-in-progress: true 34 | 35 | jobs: 36 | build: 37 | name: MegaLinter 38 | runs-on: ubuntu-latest 39 | steps: 40 | # Git Checkout 41 | - name: Checkout Code 42 | uses: actions/checkout@v4 43 | with: 44 | token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} 45 | # If you use VALIDATE_ALL_CODEBASE = true, 46 | # you can remove this line to improve performances 47 | # fetch-depth: 0 48 | 49 | # MegaLinter 50 | - name: MegaLinter 51 | id: ml 52 | # You can override MegaLinter flavor used to have faster performances 53 | # More info at https://oxsecurity.github.io/megalinter/flavors/ 54 | uses: oxsecurity/megalinter/flavors/cupcake@beta 55 | env: 56 | # All available variables are described in documentation 57 | # https://oxsecurity.github.io/megalinter/configuration/ 58 | # Set ${{ github.event_name == 59 | # 'push' && github.ref == 'refs/heads/main' }} 60 | # to validate only diff with main branch 61 | VALIDATE_ALL_CODEBASE: true 62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 63 | FILTER_REGEX_EXCLUDE: .*run-clang-tidy\.py 64 | # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES 65 | # OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY 66 | 67 | # Upload MegaLinter artifacts 68 | - name: Archive production artifacts 69 | if: ${{ success() || failure() }} 70 | uses: actions/upload-artifact@v4 71 | with: 72 | name: MegaLinter reports 73 | path: | 74 | megalinter-reports 75 | mega-linter.log 76 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *__pycache__* 2 | *.egg-info* 3 | -------------------------------------------------------------------------------- /.mega-linter.yml: -------------------------------------------------------------------------------- 1 | # Configuration file for MegaLinter 2 | # See all available variables at 3 | # https://oxsecurity.github.io/megalinter/configuration/ 4 | # and in linters documentation 5 | 6 | ########## Mega Linter Settings ########## 7 | APPLY_FIXES: none # all, none, or list of linter keys 8 | # If you use ENABLE variable, all other languages/formats/tooling-formats 9 | # will be disabled by default 10 | # ENABLE: 11 | # If you use ENABLE_LINTERS variable, 12 | # all other linters will be disabled by default 13 | ENABLE_LINTERS: 14 | - ACTION_ACTIONLINT 15 | - PYTHON_BLACK 16 | - PYTHON_FLAKE8 17 | - PYTHON_ISORT 18 | - YAML_YAMLLINT 19 | # DISABLE: 20 | # - COPYPASTE # Uncomment to disable checks of excessive copy-pastes 21 | # - SPELL # Uncomment to disable checks of spelling mistakes 22 | SHOW_ELAPSED_TIME: true 23 | FILEIO_REPORTER: false 24 | # Uncomment if you want MegaLinter to detect errors but not block CI to pass 25 | # DISABLE_ERRORS: true 26 | # FILTER_REGEX_EXCLUDE: > 27 | LINTER_RULES_PATH: / 28 | ########## Individual Linter Settings ########## 29 | 30 | #===== Github Action =====# 31 | ACTION_ACTIONLINT_RULES_PATH: .github 32 | 33 | #===== Python =====# 34 | PYTHON_BLACK_CONFIG_FILE: pyproject.toml 35 | PYTHON_BLACK_DISABLE_ERRORS: false 36 | PYTHON_FLAKE8_CONFIG_FILE: .flake8 37 | PYTHON_ISORT_CONFIG_FILE: pyproject.toml 38 | PYTHON_ISORT_DISABLE_ERRORS: false 39 | 40 | #===== YAML =====# 41 | YAML_YAMLLINT_CONFIG_FILE: .yaml-lint.yml 42 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | repos: 3 | - repo: https://github.com/ambv/black 4 | rev: 23.1.0 5 | hooks: 6 | - id: black 7 | args: [--config=pyproject.toml] 8 | language_version: python3 9 | exclude: ^(sql/src/cpp/thirdparty/duckdb/.*)|(scripts/run-clang-tidy.py) 10 | - repo: https://github.com/pycqa/flake8 11 | rev: 5.0.4 12 | hooks: 13 | - id: flake8 14 | exclude: ^(sql/src/cpp/thirdparty/duckdb/.*)|(scripts/run-clang-tidy.py) 15 | - repo: https://github.com/pocc/pre-commit-hooks 16 | rev: v1.3.5 17 | hooks: 18 | - id: clang-format 19 | args: 20 | - -i 21 | - --style=file 22 | - --fallback-style=Chromium 23 | - repo: https://github.com/pycqa/isort 24 | rev: 5.12.0 25 | hooks: 26 | - id: isort 27 | files: "\\.(py)$" 28 | args: [--settings-path=pyproject.toml] 29 | - repo: https://github.com/pre-commit/mirrors-mypy 30 | rev: v0.991 31 | hooks: 32 | - id: mypy 33 | args: 34 | - --ignore-missing-imports 35 | - --follow-imports=silent 36 | additional_dependencies: ['types-waitress'] 37 | - repo: https://github.com/rhysd/actionlint 38 | rev: v1.6.22 39 | hooks: 40 | - id: actionlint 41 | - repo: https://github.com/adrienverge/yamllint.git 42 | rev: v1.28.0 43 | hooks: 44 | - id: yamllint 45 | args: [-c=.yaml-lint.yml] 46 | - repo: https://github.com/getindata/py-pre-commit-hooks 47 | rev: v0.2.0 48 | hooks: 49 | - id: pyspelling-docker 50 | name: spellcheck 51 | files: ^docs/ 52 | - repo: local 53 | hooks: 54 | - id: sort-spelling-wordlist 55 | name: sort-spelling-wordlist 56 | description: Sort spelling wordlist 57 | language: system 58 | entry: bash -c 'sort -f docs/spelling_wordlist.txt 59 | -o docs/spelling_wordlist.txt' 60 | files: ^docs/spelling_wordlist.txt$ 61 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # .readthedocs.yaml 3 | # Read the Docs configuration file 4 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 5 | 6 | # Required 7 | version: 2 8 | 9 | # Set the version of Python and other tools you might need 10 | build: 11 | os: ubuntu-20.04 12 | tools: 13 | python: "3.9" 14 | 15 | mkdocs: 16 | configuration: mkdocs.yml 17 | 18 | # Optionally declare the Python requirements required to build your docs 19 | python: 20 | install: 21 | - requirements: docs/requirements.txt 22 | -------------------------------------------------------------------------------- /.spellcheck.yml: -------------------------------------------------------------------------------- 1 | --- 2 | matrix: 3 | - name: Markdown 4 | aspell: 5 | lang: en 6 | ignore-case: true 7 | dictionary: 8 | wordlists: 9 | - docs/spelling_wordlist.txt 10 | encoding: utf-8 11 | pipeline: 12 | - pyspelling.filters.markdown: 13 | markdown_extensions: 14 | - pymdownx.superfences: 15 | - pyspelling.filters.html: 16 | comments: false 17 | ignores: 18 | - code 19 | - pre 20 | sources: 21 | - 'docs/**/*.md' 22 | default_encoding: utf-8 23 | -------------------------------------------------------------------------------- /.yaml-lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | truthy: 6 | ignore: | 7 | # The truthy rule is not relevant for GitHub Actions workflows, 8 | # as the YAML syntax for it is a bit different from normal YAML 9 | .github/*/*.yaml 10 | # Set line length to warning because some bash commands are long 11 | line-length: 12 | max: 80 13 | level: warning 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | OpaquePrompts logo 5 |
6 | 7 | --- 8 | 9 | [![](https://dcbadge.vercel.app/api/server/mVuCfxudrD?compact=true&style=flat)](https://discord.gg/mVuCfxudrD) 10 | [![PyPI version](https://badge.fury.io/py/opaqueprompts.svg)](https://badge.fury.io/py/opaqueprompts) 11 | 12 | Opaque Gateway enables applications to leverage the power of language models while preserving user privacy. This repo contains the Opaque Gateway Python library, which provides a simple interface for interacting with the Opaque Gateway Service. More information about Opaque Gateway can be found in the [documentation](https://opaquegateway.readthedocs.io/). 13 | 14 | **API Stability:** This package is still in development. As such, its API may 15 | change until it is sufficiently mature. 16 | 17 | ## Installation 18 | 19 | The Opaque Gateway Python library can be installed via pip: 20 | 21 | ```bash 22 | pip install opaqueprompts 23 | ``` 24 | 25 | ## Documentation 26 | For a quickstart, technical overview, and API reference, see the [Opaque Gateway documentation](https://opaquegateway.readthedocs.io/). 27 | 28 | ## Contact 29 | To contact us, join our [Discord server](https://discord.gg/mVuCfxudrD) or email us at [opaquegateway@opaque.co](mailto:opaquegateway@opaque.co). 30 | -------------------------------------------------------------------------------- /docs/css/extra.css: -------------------------------------------------------------------------------- 1 | /* Taken from https://mkdocstrings.github.io/python/customization/ */ 2 | /* Indentation. */ 3 | div.doc-contents:not(.first) { 4 | padding-left: 25px; 5 | border-left: .05rem solid var(--md-typeset-table-color); 6 | } 7 | 8 | /* Mark external links as such. */ 9 | a.autorefs-external::after { 10 | /* https://primer.style/octicons/arrow-up-right-24 */ 11 | background-image: url('data:image/svg+xml,'); 12 | content: ' '; 13 | 14 | display: inline-block; 15 | position: relative; 16 | top: 0.1em; 17 | margin-left: 0.2em; 18 | margin-right: 0.1em; 19 | 20 | height: 1em; 21 | width: 1em; 22 | border-radius: 100%; 23 | background-color: var(--md-typeset-a-color); 24 | } 25 | 26 | a.autorefs-external:hover::after { 27 | background-color: var(--md-accent-fg-color); 28 | } 29 | 30 | .hidden-warning { 31 | display: none 32 | } 33 | 34 | /* The Read the Docs flyout is formatted with a font-size that is 90% of the 35 | body's. Material for MkDocs has a body font-size that is 0.5rem. This body 36 | font-size will result in the flyout having a font-size of 0.7rem, consistent 37 | with the font-size of other elements in the theme. 38 | */ 39 | body { 40 | font-size: 0.777778rem; 41 | } 42 | 43 | /* Increase h2, h3, and h4 font size and reduce h4 font weight */ 44 | .md-typeset h2 { 45 | font-size: 1.7em; 46 | } 47 | 48 | .md-typeset h3 { 49 | font-size: 1.4em; 50 | } 51 | 52 | .md-typeset h4 { 53 | font-size: 1.2em; 54 | font-weight: 300; 55 | } 56 | 57 | /* h6 for glossary terms */ 58 | .md-typeset h6 { 59 | font-size: 1em; 60 | font-weight: 600; 61 | color: #000000de; 62 | } 63 | 64 | /* Indent glossary definitions */ 65 | .md-typeset h6~p, 66 | .md-typeset h6~ul { 67 | padding-left: 1.25rem; 68 | } 69 | 70 | .md-typeset h6~ol { 71 | padding-left: .75rem; 72 | } 73 | 74 | /* Unordered list