Skip to content

Commit

Permalink
feat: Set Client-Version header when calling the OpaquePrompts Service (
Browse files Browse the repository at this point in the history
#37)

Co-authored-by: Chester Leung <[email protected]>
Co-authored-by: Hernan Gatta <[email protected]>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent a3039e6 commit aae9394
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

# Upload MegaLinter artifacts
- name: Archive production artifacts
if: ${{ success() }} || ${{ failure() }}
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v2
with:
name: MegaLinter reports
Expand Down
22 changes: 22 additions & 0 deletions docs/getting_started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,25 @@ DesanitizeResponse(desanitized_text='Sarah Jane and John Smith will be meeting i
## Using OpaquePrompts with LangChain

OpaquePrompts offers a [LangChain](https://python.langchain.com/docs/get_started/introduction.html) integration, enabling you to easily build privacy-preserving LLM applications. See the [OpaquePrompts page in the LangChain documentation](https://python.langchain.com/docs/integrations/llms/opaqueprompts) for more.

## Troubleshooting

### Version Mismatch

We may make breaking changes and drop support for old versions of the Python package. If this happens, you should see an error message like this when making a `sanitize` or `desanitize` call:

```
Request sent using package version 0.1.0, but minimum supported version is 0.2.0. Please update the opaqueprompts package to a supported version.
```

If you see this, simply upgrade `opaqueprompts` with `pip install -U opaqueprompts` and then you should be able to continue using the package without issue.

### Missing Version Header

The logic to gracefully handle version mismatch was not added to the `opaqueprompts` package until version 0.1.0. As such, if you are using an older version of `opaqueprompts`, you may see the following error:

```
Client-Version header not set, please ensure this request was sent using opaqueprompts version >= 0.1.0
```

If you see this, make sure to update your `opaqueprompts` package to the latest version per the instructions in the "Version Mismatch" section.
2 changes: 1 addition & 1 deletion python-package/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "opaqueprompts"
version = "0.0.6"
version = "0.1.0"
description = "The client-side SDK for OpaquePrompts, a privacy layer that enables applications to wrap external provider calls with a sanitization mechanism that hides sensitive inputs via an attested trusted execution environment."
readme = "README.md"
authors= [{ name = "Opaque Systems", email = "[email protected]" }]
Expand Down
6 changes: 5 additions & 1 deletion python-package/src/opaqueprompts/opaqueprompts_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from dataclasses import dataclass
from http import HTTPStatus
from http.client import HTTPException
from importlib import metadata
from typing import Dict, List, Optional, Union

import requests
Expand Down Expand Up @@ -197,7 +198,10 @@ def _send_request_to_opaqueprompts_service(
response = _session.request(
"POST",
f"{http_protocol}://{hostname}:{port}/{endpoint}",
headers={"Authorization": f"Bearer {api_key}"},
headers={
"Authorization": f"Bearer {api_key}",
"Client-Version": metadata.version("opaqueprompts"),
},
data=json.dumps(payload),
timeout=timeout,
)
Expand Down

0 comments on commit aae9394

Please sign in to comment.