An example Python app that demonstrates integrating Pangea's AI Guard service into a LangChain app to protect data ingestion.
In this case, the data to be ingested consists of articles about authentication
from our Secure by Design Hub included in langchain_aig_ingestion/data
.
- Python v3.12 or greater.
- pip v24.2 or uv v0.4.29.
- A Pangea account with AI Guard enabled.
- An OpenAI API key.
git clone https://github.com/pangeacyber/langchain-python-aig-ingestion.git
cd langchain-python-aig-ingestion
If using pip:
python -m venv .venv
source .venv/bin/activate
pip install .
Or, if using uv:
uv sync
source .venv/bin/activate
The sample can then be executed with:
python -m langchain_aig_ingestion "What do you know about OAuth?"
Note: Because our context is limited to the authentication articles mentioned above, if you ask a question outside that context, you will get some variation of "I don't know."
Usage: python -m langchain_aig_ingestion [OPTIONS] PROMPT
Options:
--model TEXT OpenAI model. [default: gpt-4o-mini; required]
--ai-guard-token SECRET Pangea AI Guard API token. May also be set via the
`PANGEA_AI_GUARD_TOKEN` environment variable.
[required]
--pangea-domain TEXT Pangea API domain. May also be set via the
`PANGEA_DOMAIN` environment variable. [default:
aws.us.pangea.cloud; required]
--openai-api-key SECRET OpenAI API key. May also be set via the
`OPENAI_API_KEY` environment variable. [required]
--help Show this message and exit.
python -m langchain_aig_ingestion "What do you know about OAuth?"
OAuth 2.0 is a protocol primarily focused on authorization and resource access control, while OpenID Connect (OIDC) is built on top of OAuth 2.0 and specializes in user authentication. OIDC allows applications to verify a user's identity through a trusted identity provider, ensuring that apps do not handle sensitive user credentials directly. This combination provides a secure and convenient authentication process for users accessing online services.