Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,5 @@ Key dependencies (Python >=3.11):
- `click`: CLI framework
- `firebase-rest-api`: Backend services
- `pydantic`: Data validation
- `og-test-v2-x402`: x402 payment protocol
- `og-x402`: x402 payment protocol
- `numpy`: Array handling
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"langchain>=0.3.7",
"openai>=1.58.1",
"pydantic>=2.9.2",
"og-test-v2-x402==0.0.11"
"og-x402==0.0.1.dev2"
]

[project.scripts]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ requests>=2.32.3
langchain>=0.3.7
openai>=1.58.1
pydantic>=2.9.2
og-test-v2-x402==0.0.11
og-x402==0.0.1.dev2
20 changes: 10 additions & 10 deletions src/opengradient/client/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from eth_account import Account
from eth_account.account import LocalAccount
from x402v2 import x402Client as x402Clientv2
from x402v2.http.clients import x402HttpxClient as x402HttpxClientv2
from x402v2.mechanisms.evm import EthAccountSigner as EthAccountSignerv2
from x402v2.mechanisms.evm.exact.register import register_exact_evm_client as register_exact_evm_clientv2
from x402v2.mechanisms.evm.upto.register import register_upto_evm_client as register_upto_evm_clientv2
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
from x402.mechanisms.evm.upto.register import register_upto_evm_client

from ..types import TEE_LLM, StreamChoice, StreamChunk, StreamDelta, TextGenerationOutput, x402SettlementMode
from .opg_token import Permit2ApprovalResult, ensure_opg_approval
Expand Down Expand Up @@ -112,12 +112,12 @@ def __init__(
self._tls_verify: Union[ssl.SSLContext, bool] = ssl_ctx if ssl_ctx else verify_ssl

# x402 client and signer
signer = EthAccountSignerv2(self._wallet_account)
self._x402_client = x402Clientv2()
register_exact_evm_clientv2(self._x402_client, signer, networks=[BASE_TESTNET_NETWORK])
register_upto_evm_clientv2(self._x402_client, signer, networks=[BASE_TESTNET_NETWORK])
signer = EthAccountSigner(self._wallet_account)
self._x402_client = x402Client()
register_exact_evm_client(self._x402_client, signer, networks=[BASE_TESTNET_NETWORK])
register_upto_evm_client(self._x402_client, signer, networks=[BASE_TESTNET_NETWORK])
# httpx.AsyncClient subclass - construction is sync, connections open lazily
self._http_client = x402HttpxClientv2(self._x402_client, verify=self._tls_verify)
self._http_client = x402HttpxClient(self._x402_client, verify=self._tls_verify)

# ── TEE resolution ──────────────────────────────────────────────────

Expand Down
2 changes: 1 addition & 1 deletion src/opengradient/client/opg_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from eth_account.account import LocalAccount
from web3 import Web3
from x402v2.mechanisms.evm.constants import PERMIT2_ADDRESS
from x402.mechanisms.evm.constants import PERMIT2_ADDRESS

BASE_OPG_ADDRESS = "0x240b09731D96979f50B2C649C9CE10FcF9C7987F"
BASE_SEPOLIA_RPC = "https://sepolia.base.org"
Expand Down
16 changes: 8 additions & 8 deletions tests/llm_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for LLM class.

Construction patches the x402 boundary (x402HttpxClientv2, EthAccountSignerv2, etc.)
Construction patches the x402 boundary (x402HttpxClient, EthAccountSigner, etc.)
so LLM builds normally — no test-only constructor params, no mocking of private methods.
"""

Expand All @@ -19,10 +19,10 @@


class FakeHTTPClient:
"""Stands in for x402HttpxClientv2.
"""Stands in for x402HttpxClient.

Configured per-test with set_response / set_stream_response, then
injected via the x402HttpxClientv2 patch so LLM's normal __init__
injected via the x402HttpxClient patch so LLM's normal __init__
assigns it to self._http_client.
"""

Expand Down Expand Up @@ -90,11 +90,11 @@ async def aread(self) -> bytes:
# so LLM.__init__ runs its real code but gets our FakeHTTPClient.

_PATCHES = {
"x402_httpx": "src.opengradient.client.llm.x402HttpxClientv2",
"x402_client": "src.opengradient.client.llm.x402Clientv2",
"signer": "src.opengradient.client.llm.EthAccountSignerv2",
"register_exact": "src.opengradient.client.llm.register_exact_evm_clientv2",
"register_upto": "src.opengradient.client.llm.register_upto_evm_clientv2",
"x402_httpx": "src.opengradient.client.llm.x402HttpxClient",
"x402_client": "src.opengradient.client.llm.x402Client",
"signer": "src.opengradient.client.llm.EthAccountSigner",
"register_exact": "src.opengradient.client.llm.register_exact_evm_client",
"register_upto": "src.opengradient.client.llm.register_upto_evm_client",
}


Expand Down
14 changes: 7 additions & 7 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading