langchain-0g
This package contains the LangChain integrations for 0G.ai through their a0g SDK.
Installation and Setup
- Install the 0G.ai Python package:
pip install python-0g langchain_0g
- Set your 0G.ai wallet private key as an environment variable:
export A0G_PRIVATE_KEY="your_wallet_private_key"
Chat model
ZGChat is a wrapper around 0G.ai chat models. It allows you to interact with 0G.ai-hosted LLMs in a LangChain-compatible way.
from langchain_0g import ZGChat
chat = ZGChat(provider="0xf07240Efa67755B5311bc75784a061eDB47165Dd")
response = chat.invoke("Hello 0G!")
print(response)
provideris the ENS address of the 0G.ai model.private_keyis optional if you haveA0G_PRIVATE_KEYin the environment.
Asynchronous Usage
import asyncio
from langchain_0g import ZGChat
async def main():
chat = ZGChat(provider="0xf07240Efa67755B5311bc75784a061eDB47165Dd")
response = await chat.ainvoke("Hi!")
print(response)
asyncio.run(main())
LLM (Legacy)
ZGLLM refers to legacy text-completion models hosted on 0G.ai.
from langchain_0g import ZGLLM
llm = ZGLLM(provider="0xf07240Efa67755B5311bc75784a061eDB47165Dd")
text = llm.invoke("Summarize the following article...")
print(text)
providerspecifies the 0G.ai model.- Use
private_keyto sign requests via your wallet.
List available models
from langchain_0g import ZGChat
llm = ZGChat(provider="0xf07240Efa67755B5311bc75784a061eDB47165Dd")
print(llm.zg_client.get_all_services())
Notes
- 0G.ai clients (
clientandasync_client) handle authentication using your wallet private key instead of traditional OpenAI API keys. - The ENS
provideridentifies which LLM to query. - All requests go through 0G.ai smart contracts for on-chain verification.
Metadata
Release files for langchain-0g 0.1.0
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_0g-0.1.0.tar.gz | 3.1 kB | Without provenance | Details for langchain_0g-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_0g-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_0g-0.1.0-py3-none-any.whl |
Total release size: 8.8 kB
Release files / langchain_0g-0.1.0.tar.gz
| Download URL | langchain_0g-0.1.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2f413efa2e52e32e3c85af73cbd148db5619c36c95f92181b108df39a0b4c16
|
|
BLAKE2b-256 checksum How to use checksums |
f08486cda6f40cea10ea5b9b1da8fa1ae745688921bd154b7584273d2101fbcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / langchain_0g-0.1.0-py3-none-any.whl
| Download URL | langchain_0g-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2aaafb1b646e9989d04d6c79519f83cfca698951356650a5a0d58acae6b75f23
|
|
BLAKE2b-256 checksum How to use checksums |
a176f69ab884397b538429f4e9fbbadb03c695f8a4e108864ee64816a3d72039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for langchain-0g 0.1.0
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.