opengradient 0.5.10__tar.gz → 0.5.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {opengradient-0.5.10/src/opengradient.egg-info → opengradient-0.5.12}/PKG-INFO +2 -1
- {opengradient-0.5.10 → opengradient-0.5.12}/pyproject.toml +2 -1
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/client.py +1 -1
- opengradient-0.5.12/src/opengradient/x402_auth.py +99 -0
- {opengradient-0.5.10 → opengradient-0.5.12/src/opengradient.egg-info}/PKG-INFO +2 -1
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient.egg-info/requires.txt +1 -0
- opengradient-0.5.10/src/opengradient/x402_auth.py +0 -102
- {opengradient-0.5.10 → opengradient-0.5.12}/LICENSE +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/README.md +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/setup.cfg +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/__init__.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/abi/InferencePrecompile.abi +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/abi/PriceHistoryInference.abi +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/abi/WorkflowScheduler.abi +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/abi/inference.abi +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/account.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/alpha.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/alphasense/__init__.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/alphasense/read_workflow_tool.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/alphasense/run_model_tool.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/alphasense/types.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/bin/PriceHistoryInference.bin +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/cli.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/defaults.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/exceptions.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/llm/__init__.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/llm/og_langchain.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/llm/og_openai.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/proto/__init__.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/proto/infer.proto +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/proto/infer_pb2.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/proto/infer_pb2_grpc.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/types.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/utils.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/workflow_models/__init__.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/workflow_models/constants.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/workflow_models/types.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/workflow_models/utils.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/workflow_models/workflow_models.py +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient.egg-info/SOURCES.txt +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient.egg-info/dependency_links.txt +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient.egg-info/entry_points.txt +0 -0
- {opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opengradient
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.12
|
|
4
4
|
Summary: Python SDK for OpenGradient decentralized model management & inference services
|
|
5
5
|
Author-email: OpenGradient <kyle@vannalabs.ai>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,6 +24,7 @@ Requires-Dist: langchain>=0.3.7
|
|
|
24
24
|
Requires-Dist: openai>=1.58.1
|
|
25
25
|
Requires-Dist: pydantic>=2.9.2
|
|
26
26
|
Requires-Dist: og-test-x402==0.0.9
|
|
27
|
+
Requires-Dist: x402==0.2.1
|
|
27
28
|
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
# OpenGradient Python SDK
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "opengradient"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.12"
|
|
8
8
|
description = "Python SDK for OpenGradient decentralized model management & inference services"
|
|
9
9
|
authors = [{name = "OpenGradient", email = "kyle@vannalabs.ai"}]
|
|
10
10
|
readme = "README.md"
|
|
@@ -30,6 +30,7 @@ dependencies = [
|
|
|
30
30
|
"openai>=1.58.1",
|
|
31
31
|
"pydantic>=2.9.2",
|
|
32
32
|
"og-test-x402==0.0.9",
|
|
33
|
+
"x402==0.2.1",
|
|
33
34
|
]
|
|
34
35
|
|
|
35
36
|
[project.scripts]
|
|
@@ -1152,7 +1152,7 @@ class Client:
|
|
|
1152
1152
|
limits=LIMITS,
|
|
1153
1153
|
http2=False,
|
|
1154
1154
|
follow_redirects=False,
|
|
1155
|
-
auth=X402Auth(account=self._wallet_account), # type: ignore
|
|
1155
|
+
auth=X402Auth(account=self._wallet_account, network_filter=DEFAULT_NETWORK_FILTER), # type: ignore
|
|
1156
1156
|
) as client:
|
|
1157
1157
|
headers = {
|
|
1158
1158
|
"Content-Type": "application/json",
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""
|
|
2
|
+
X402 Authentication handler for httpx streaming requests.
|
|
3
|
+
|
|
4
|
+
This module provides an httpx Auth class that handles x402 payment protocol
|
|
5
|
+
authentication for streaming responses.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
import typing
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
from x402.clients.base import x402Client
|
|
13
|
+
from x402.types import x402PaymentRequiredResponse, PaymentRequirements
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class X402Auth(httpx.Auth):
|
|
17
|
+
"""
|
|
18
|
+
httpx Auth handler for x402 payment protocol.
|
|
19
|
+
|
|
20
|
+
This class implements the httpx Auth interface to handle 402 Payment Required
|
|
21
|
+
responses by automatically creating and attaching payment headers.
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
async with httpx.AsyncClient(auth=X402Auth(account=wallet_account)) as client:
|
|
25
|
+
response = await client.get("https://api.example.com/paid-resource")
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
requires_response_body = True
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
account: typing.Any,
|
|
33
|
+
max_value: typing.Optional[int] = None,
|
|
34
|
+
payment_requirements_selector: typing.Optional[
|
|
35
|
+
typing.Callable[
|
|
36
|
+
[
|
|
37
|
+
list[PaymentRequirements],
|
|
38
|
+
typing.Optional[str],
|
|
39
|
+
typing.Optional[str],
|
|
40
|
+
typing.Optional[int],
|
|
41
|
+
],
|
|
42
|
+
PaymentRequirements,
|
|
43
|
+
]
|
|
44
|
+
] = None,
|
|
45
|
+
network_filter: typing.Optional[str] = None,
|
|
46
|
+
):
|
|
47
|
+
"""
|
|
48
|
+
Initialize X402Auth with an Ethereum account for signing payments.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
account: eth_account LocalAccount instance for signing payments
|
|
52
|
+
max_value: Optional maximum allowed payment amount in base units
|
|
53
|
+
network_filter: Optional network filter for selecting payment requirements
|
|
54
|
+
scheme_filter: Optional scheme filter for selecting payment requirements
|
|
55
|
+
"""
|
|
56
|
+
self.x402_client = x402Client(
|
|
57
|
+
account,
|
|
58
|
+
max_value=max_value,
|
|
59
|
+
payment_requirements_selector=payment_requirements_selector, # type: ignore
|
|
60
|
+
)
|
|
61
|
+
self.network_filter = network_filter
|
|
62
|
+
|
|
63
|
+
async def async_auth_flow(
|
|
64
|
+
self, request: httpx.Request
|
|
65
|
+
) -> typing.AsyncGenerator[httpx.Request, httpx.Response]:
|
|
66
|
+
"""
|
|
67
|
+
Handle authentication flow for x402 payment protocol.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
request: httpx Request object to be authenticated
|
|
71
|
+
|
|
72
|
+
Yields:
|
|
73
|
+
httpx Request object with authentication headers attached
|
|
74
|
+
"""
|
|
75
|
+
response = yield request
|
|
76
|
+
|
|
77
|
+
if response.status_code == 402:
|
|
78
|
+
try:
|
|
79
|
+
await response.aread()
|
|
80
|
+
data = response.json()
|
|
81
|
+
|
|
82
|
+
payment_response = x402PaymentRequiredResponse(**data)
|
|
83
|
+
|
|
84
|
+
selected_requirements = self.x402_client.select_payment_requirements(
|
|
85
|
+
payment_response.accepts,
|
|
86
|
+
self.network_filter,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
payment_header = self.x402_client.create_payment_header(
|
|
90
|
+
selected_requirements, payment_response.x402_version
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
request.headers["X-Payment"] = payment_header
|
|
94
|
+
request.headers["Access-Control-Expose-Headers"] = "X-Payment-Response"
|
|
95
|
+
yield request
|
|
96
|
+
|
|
97
|
+
except Exception as e:
|
|
98
|
+
logging.error(f"X402Auth: Error handling payment: {e}")
|
|
99
|
+
return
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opengradient
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.12
|
|
4
4
|
Summary: Python SDK for OpenGradient decentralized model management & inference services
|
|
5
5
|
Author-email: OpenGradient <kyle@vannalabs.ai>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,6 +24,7 @@ Requires-Dist: langchain>=0.3.7
|
|
|
24
24
|
Requires-Dist: openai>=1.58.1
|
|
25
25
|
Requires-Dist: pydantic>=2.9.2
|
|
26
26
|
Requires-Dist: og-test-x402==0.0.9
|
|
27
|
+
Requires-Dist: x402==0.2.1
|
|
27
28
|
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
# OpenGradient Python SDK
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
X402 Authentication handler for httpx streaming requests.
|
|
3
|
-
|
|
4
|
-
This module provides an httpx Auth class that handles x402 payment protocol
|
|
5
|
-
authentication for streaming responses.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from typing import Generator, Optional
|
|
9
|
-
|
|
10
|
-
import httpx
|
|
11
|
-
from eth_account.account import LocalAccount
|
|
12
|
-
from x402.clients.base import x402Client
|
|
13
|
-
from x402.types import x402PaymentRequiredResponse
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class X402Auth(httpx.Auth):
|
|
17
|
-
"""
|
|
18
|
-
httpx Auth handler for x402 payment protocol.
|
|
19
|
-
|
|
20
|
-
This class implements the httpx Auth interface to handle 402 Payment Required
|
|
21
|
-
responses by automatically creating and attaching payment headers.
|
|
22
|
-
|
|
23
|
-
Example:
|
|
24
|
-
async with httpx.AsyncClient(auth=X402Auth(account=wallet_account)) as client:
|
|
25
|
-
response = await client.get("https://api.example.com/paid-resource")
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
requires_response_body = True
|
|
29
|
-
|
|
30
|
-
def __init__(
|
|
31
|
-
self,
|
|
32
|
-
account: LocalAccount,
|
|
33
|
-
max_value: Optional[int] = None,
|
|
34
|
-
network_filter: Optional[str] = None,
|
|
35
|
-
scheme_filter: Optional[str] = None,
|
|
36
|
-
):
|
|
37
|
-
"""
|
|
38
|
-
Initialize X402Auth with an Ethereum account for signing payments.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
account: eth_account LocalAccount instance for signing payments
|
|
42
|
-
max_value: Optional maximum allowed payment amount in base units
|
|
43
|
-
network_filter: Optional network filter for selecting payment requirements
|
|
44
|
-
scheme_filter: Optional scheme filter for selecting payment requirements
|
|
45
|
-
"""
|
|
46
|
-
self._account = account
|
|
47
|
-
self._max_value = max_value
|
|
48
|
-
self._network_filter = network_filter
|
|
49
|
-
self._scheme_filter = scheme_filter
|
|
50
|
-
self._x402_client = x402Client(
|
|
51
|
-
account,
|
|
52
|
-
max_value=max_value,
|
|
53
|
-
network_filter=network_filter,
|
|
54
|
-
scheme_filter=scheme_filter,
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
def auth_flow(
|
|
58
|
-
self, request: httpx.Request
|
|
59
|
-
) -> Generator[httpx.Request, httpx.Response, None]:
|
|
60
|
-
"""
|
|
61
|
-
Implement the auth flow for x402 payment handling.
|
|
62
|
-
|
|
63
|
-
This method yields the initial request, and if a 402 response is received,
|
|
64
|
-
it creates a payment header and retries the request.
|
|
65
|
-
|
|
66
|
-
Args:
|
|
67
|
-
request: The initial httpx Request
|
|
68
|
-
|
|
69
|
-
Yields:
|
|
70
|
-
httpx.Request objects (initial and retry with payment header)
|
|
71
|
-
"""
|
|
72
|
-
# Send the initial request
|
|
73
|
-
response = yield request
|
|
74
|
-
|
|
75
|
-
# If not a 402, we're done
|
|
76
|
-
if response.status_code != 402:
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
# Handle 402 Payment Required
|
|
80
|
-
try:
|
|
81
|
-
data = response.json()
|
|
82
|
-
payment_response = x402PaymentRequiredResponse(**data)
|
|
83
|
-
|
|
84
|
-
# Select payment requirements
|
|
85
|
-
selected_requirements = self._x402_client.select_payment_requirements(
|
|
86
|
-
payment_response.accepts
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
# Create payment header
|
|
90
|
-
payment_header = self._x402_client.create_payment_header(
|
|
91
|
-
selected_requirements, payment_response.x402_version
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
# Add payment header and retry
|
|
95
|
-
request.headers["X-Payment"] = payment_header
|
|
96
|
-
request.headers["Access-Control-Expose-Headers"] = "X-Payment-Response"
|
|
97
|
-
|
|
98
|
-
yield request
|
|
99
|
-
|
|
100
|
-
except Exception:
|
|
101
|
-
# If payment handling fails, just return the original 402 response
|
|
102
|
-
return
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/alphasense/read_workflow_tool.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opengradient-0.5.10 → opengradient-0.5.12}/src/opengradient/workflow_models/workflow_models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|