langchain-pangea
Pangea's tools for LangChain provide AI security features to protect your applications and data. Using these tools you can:
- Defend against prompt injection attacks.
- Prevent the exposure of sensitive information, including:
- Personally Identifiable Information (PII)
- Protected Health Information (PHI)
- Financial data
- Secrets
- Intellectual property
- Profanity
- Remove malicious content from inputs and outputs, such as IP addresses, domains, and URLs.
- Monitor user inputs and model responses to support threat analysis, auditing, and compliance efforts.
Installation
pip install -U langchain-pangea
Tools
One can run Pangea tools using agents or invoke them as a Runnable within chains.
AI Guard
import os
from langchain_pangea import PangeaAIGuard
from pangea import PangeaConfig
from pydantic import SecretStr
pangea_ai_guard_token = SecretStr(os.getenv("PANGEA_AI_GUARD_TOKEN"))
pangea_ai_guard_tool = PangeaAIGuard(
token=pangea_ai_guard_token, config=PangeaConfig(), recipe="pangea_llm_response_guard"
)
Agent
from langgraph.prebuilt import create_react_agent
from langchain_core.tools import tool
@tool
def search_tool(data):
"""Call to perform search"""
return """
47.84.32.175
37.44.238.68
47.84.73.221
47.236.252.254
34.201.186.27
52.89.173.88
"""
tools = [search_tool, pangea_ai_guard_tool]
query = """
Hi, I am Bond, James Bond. I monitor IPs found in MI6 network traffic.
Please find me the most recent ones, you copy?
"""
system_message="Always use AI Guard before your final response to keep it safe for the user."
langgraph_agent_executor = create_react_agent(model, tools, prompt=system_message)
state = langgraph_agent_executor.invoke({"messages": [("human", query)]})
Chain
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
prompt = ChatPromptTemplate.from_messages([("human", "{input}")])
query = """
Hi, I am Bond, James Bond. I am looking for a job. Please write me a super short resume.
I am skilled in international espionage, covert operations, and seduction.
Include a contact header:
Email: j.bond@mi6.co.uk
Phone: +44 20 0700 7007
Address: Universal Exports, 85 Albert Embankment, London, United Kingdom
"""
chain = (
prompt
| pangea_ai_guard_tool
| model
| StrOutputParser()
)
Standalone
pangea_ai_guard_tool.run("Spam me at example@example.com")
pangea_ai_guard_tool.invoke("Take my SSN: 234-56-7890")
Metadata
Release files for langchain-pangea 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_pangea-0.1.6.tar.gz | 11.9 kB | Without provenance | Details for langchain_pangea-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_pangea-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for langchain_pangea-0.1.6-py3-none-any.whl |
Total release size: 30.5 kB
Release files / langchain_pangea-0.1.6.tar.gz
| Download URL | langchain_pangea-0.1.6.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36a103d150fea5ae8ce446eadcf778691c75a4d92d7368a9fbb1a370be11799d
|
|
BLAKE2b-256 checksum How to use checksums |
9ac79c57d4723c02cc07a12ba17f1d931868e7db4d70079a7ec1a70083792ddd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / langchain_pangea-0.1.6-py3-none-any.whl
| Download URL | langchain_pangea-0.1.6-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b36b970f7712ff8ab76d2f53123275e208f4a2fb68e7b508a249d8c01f866e6e
|
|
BLAKE2b-256 checksum How to use checksums |
59466e67dab9e28bf9a3c6a14e57cbfb7762bccb2710fe5be02488671a7443cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for langchain-pangea 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.