MOSS signing integration for LangChain via callback handler
Project description
moss-langchain
MOSS signing integration for LangChain via callback handler.
Installation
pip install moss-langchain
Usage
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from moss_langchain import SignedCallbackHandler
# Create callback handler
cb = SignedCallbackHandler("moss:bot:summary")
# Create your chain
chain = ChatPromptTemplate.from_template("Summarize: {text}") | ChatOpenAI()
# Invoke with callback
result = chain.invoke(
{"text": "Long document..."},
config={"callbacks": [cb]}
)
# Access the signature
envelope = cb.envelope
Verification
from moss import Subject
# Verify the output
result = Subject.verify(cb.envelope)
assert result.valid
Multiple Outputs
The handler tracks all outputs during a session:
cb = SignedCallbackHandler("moss:bot:pipeline")
# Run multiple operations
chain1.invoke(input1, config={"callbacks": [cb]})
chain2.invoke(input2, config={"callbacks": [cb]})
# Access all envelopes
for envelope in cb.envelopes:
print(f"Seq {envelope.seq}: {envelope.payload_hash}")
# Clear for next session
cb.clear()
Async Chains
from moss_langchain import AsyncSignedCallbackHandler
cb = AsyncSignedCallbackHandler("moss:bot:async")
result = await chain.ainvoke(input, config={"callbacks": [cb]})
Signed Events
The handler signs outputs from:
on_llm_end- LLM generation completeon_chain_end- Chain execution completeon_tool_end- Tool execution completeon_agent_finish- Agent finishedon_retriever_end- Retriever returned documents
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moss_langchain-0.1.0.tar.gz.
File metadata
- Download URL: moss_langchain-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35148799daef5481e9be5156541e9b61e948e7a0277ae45efd48ad8f44aab618
|
|
| MD5 |
83b2eba380946dc3e8635a0f7485b64e
|
|
| BLAKE2b-256 |
e60ffc990f6a75b1088964e686a684e3e708cf1e91a973fc8fe22e9f13a62c5b
|
Provenance
The following attestation bundles were made for moss_langchain-0.1.0.tar.gz:
Publisher:
release.yml on mosscomputing/moss-langchain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moss_langchain-0.1.0.tar.gz -
Subject digest:
35148799daef5481e9be5156541e9b61e948e7a0277ae45efd48ad8f44aab618 - Sigstore transparency entry: 747571047
- Sigstore integration time:
-
Permalink:
mosscomputing/moss-langchain@10924e71668ffd4c6cf93ba46b537916cab18e73 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mosscomputing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@10924e71668ffd4c6cf93ba46b537916cab18e73 -
Trigger Event:
push
-
Statement type:
File details
Details for the file moss_langchain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: moss_langchain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3525b6ad52face4df74522a18d0e6b4da8678b5d2b2dd7efe6313ea375f49a80
|
|
| MD5 |
3e7d7c841455414a113c1a7e86557bd6
|
|
| BLAKE2b-256 |
2dc783ba15d54e2776bbc403e62993443834db662ef76e4ea3aac09f8f6b2018
|
Provenance
The following attestation bundles were made for moss_langchain-0.1.0-py3-none-any.whl:
Publisher:
release.yml on mosscomputing/moss-langchain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moss_langchain-0.1.0-py3-none-any.whl -
Subject digest:
3525b6ad52face4df74522a18d0e6b4da8678b5d2b2dd7efe6313ea375f49a80 - Sigstore transparency entry: 747571052
- Sigstore integration time:
-
Permalink:
mosscomputing/moss-langchain@10924e71668ffd4c6cf93ba46b537916cab18e73 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mosscomputing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@10924e71668ffd4c6cf93ba46b537916cab18e73 -
Trigger Event:
push
-
Statement type: