opengradient 0.5.10__tar.gz → 0.5.11__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.
Files changed (43) hide show
  1. {opengradient-0.5.10/src/opengradient.egg-info → opengradient-0.5.11}/PKG-INFO +1 -1
  2. {opengradient-0.5.10 → opengradient-0.5.11}/pyproject.toml +1 -1
  3. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/client.py +1 -1
  4. opengradient-0.5.11/src/opengradient/x402_auth.py +99 -0
  5. {opengradient-0.5.10 → opengradient-0.5.11/src/opengradient.egg-info}/PKG-INFO +1 -1
  6. opengradient-0.5.10/src/opengradient/x402_auth.py +0 -102
  7. {opengradient-0.5.10 → opengradient-0.5.11}/LICENSE +0 -0
  8. {opengradient-0.5.10 → opengradient-0.5.11}/README.md +0 -0
  9. {opengradient-0.5.10 → opengradient-0.5.11}/setup.cfg +0 -0
  10. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/__init__.py +0 -0
  11. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/abi/InferencePrecompile.abi +0 -0
  12. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/abi/PriceHistoryInference.abi +0 -0
  13. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/abi/WorkflowScheduler.abi +0 -0
  14. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/abi/inference.abi +0 -0
  15. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/account.py +0 -0
  16. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/alpha.py +0 -0
  17. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/alphasense/__init__.py +0 -0
  18. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/alphasense/read_workflow_tool.py +0 -0
  19. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/alphasense/run_model_tool.py +0 -0
  20. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/alphasense/types.py +0 -0
  21. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/bin/PriceHistoryInference.bin +0 -0
  22. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/cli.py +0 -0
  23. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/defaults.py +0 -0
  24. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/exceptions.py +0 -0
  25. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/llm/__init__.py +0 -0
  26. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/llm/og_langchain.py +0 -0
  27. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/llm/og_openai.py +0 -0
  28. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/proto/__init__.py +0 -0
  29. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/proto/infer.proto +0 -0
  30. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/proto/infer_pb2.py +0 -0
  31. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/proto/infer_pb2_grpc.py +0 -0
  32. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/types.py +0 -0
  33. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/utils.py +0 -0
  34. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/workflow_models/__init__.py +0 -0
  35. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/workflow_models/constants.py +0 -0
  36. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/workflow_models/types.py +0 -0
  37. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/workflow_models/utils.py +0 -0
  38. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient/workflow_models/workflow_models.py +0 -0
  39. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient.egg-info/SOURCES.txt +0 -0
  40. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient.egg-info/dependency_links.txt +0 -0
  41. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient.egg-info/entry_points.txt +0 -0
  42. {opengradient-0.5.10 → opengradient-0.5.11}/src/opengradient.egg-info/requires.txt +0 -0
  43. {opengradient-0.5.10 → opengradient-0.5.11}/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.10
3
+ Version: 0.5.11
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "opengradient"
7
- version = "0.5.10"
7
+ version = "0.5.11"
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"
@@ -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.10
3
+ Version: 0.5.11
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
@@ -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