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
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "opengradient"
version = "0.9.7"
version = "0.9.8"
description = "Python SDK for OpenGradient decentralized model management & inference services"
authors = [{name = "OpenGradient", email = "adam@vannalabs.ai"}]
readme = "README.md"
Expand All @@ -27,7 +27,8 @@ dependencies = [
"langchain>=0.3.7",
"openai>=1.58.1",
"pydantic>=2.9.2",
"og-x402==0.0.1.dev4"
"og-x402>=0.0.1.dev8",
"og-x402[extensions]>=0.0.1.dev8",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -76,9 +77,6 @@ target-version = "py310"
select = ["E", "F", "I", "N"]
ignore = []

[tool.uv]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we wanted to include this for security

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we need this in for now because the dependency we're updating is too new...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#275
made issue to add this back

exclude-newer = "7d"

[tool.ruff.mccabe]
max-complexity = 10

Expand Down
13 changes: 10 additions & 3 deletions src/opengradient/client/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import AsyncGenerator, Awaitable, Callable, Dict, List, Optional, TypeVar, Union
import httpx
import asyncio
import os

from eth_account import Account
from eth_account.account import LocalAccount
Expand All @@ -28,6 +29,7 @@
X402_PROCESSING_HASH_HEADER = "x-processing-hash"
X402_PLACEHOLDER_API_KEY = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
BASE_TESTNET_NETWORK = "eip155:84532"
BASE_TESTNET_RPC = os.getenv("BASE_TESTNET_RPC", "https://sepolia.base.org")

_CHAT_ENDPOINT = "/v1/chat/completions"
_COMPLETION_ENDPOINT = "/v1/completions"
Expand Down Expand Up @@ -85,7 +87,7 @@ def __init__(
raise ValueError("A private key is required to use the LLM client. Pass a valid private_key to the constructor.")
self._wallet_account: LocalAccount = Account.from_key(private_key)

x402_client = LLM._build_x402_client(private_key)
x402_client = LLM._build_x402_client(private_key, rpc_url=BASE_TESTNET_RPC)
onchain_registry = TEERegistry(rpc_url=rpc_url, registry_address=tee_registry_address)
self._tee: TEEConnectionInterface = RegistryTEEConnection(x402_client=x402_client, registry=onchain_registry)

Expand Down Expand Up @@ -115,13 +117,18 @@ def from_url(
return instance

@staticmethod
def _build_x402_client(private_key: str) -> x402Client:
def _build_x402_client(private_key: str, rpc_url: str = BASE_TESTNET_RPC) -> x402Client:
"""Build the x402 payment stack from a private key."""
account = Account.from_key(private_key)
signer = EthAccountSigner(account)
client = x402Client()
register_exact_evm_client(client, signer, networks=[BASE_TESTNET_NETWORK])
register_upto_evm_client(client, signer, networks=[BASE_TESTNET_NETWORK])
register_upto_evm_client(
client,
signer,
networks=[BASE_TESTNET_NETWORK],
rpc_url=rpc_url,
)
return client

# ── Lifecycle ───────────────────────────────────────────────────────
Expand Down
Loading
Loading