1919from x402v2 .mechanisms .evm .upto .register import register_upto_evm_client as register_upto_evm_clientv2
2020from eth_account import Account
2121
22- from ..defaults import (
23- DEFAULT_NETWORK_FILTER ,
24- DEFAULT_OPENGRADIENT_V2_LLM_SERVER_URL
25- )
26- from ..types import (
27- TEE_LLM ,
28- StreamChunk ,
29- TextGenerationOutput ,
30- TextGenerationStream ,
31- x402SettlementMode ,
32- x402Network
33- )
22+ from ..defaults import DEFAULT_NETWORK_FILTER , DEFAULT_OPENGRADIENT_V2_LLM_SERVER_URL
23+ from ..types import TEE_LLM , StreamChunk , TextGenerationOutput , TextGenerationStream , x402SettlementMode , x402Network
3424from .exceptions import OpenGradientError
3525from .x402_auth import X402Auth
3626
@@ -167,7 +157,8 @@ async def make_request():
167157 result = json .loads (content .decode ())
168158
169159 return TextGenerationOutput (
170- transaction_hash = "external" , completion_output = result .get ("completion" ),
160+ transaction_hash = "external" ,
161+ completion_output = result .get ("completion" ),
171162 )
172163
173164 except Exception as e :
@@ -243,7 +234,7 @@ def chat(
243234 tools = tools ,
244235 tool_choice = tool_choice ,
245236 x402_settlement_mode = x402_settlement_mode ,
246- network = network
237+ network = network ,
247238 )
248239
249240 def _tee_llm_chat (
@@ -310,17 +301,14 @@ async def make_request():
310301
311302 except Exception as e :
312303 raise OpenGradientError (f"TEE LLM chat request failed: { str (e )} " )
313-
314304
315305 async def make_request_v2 ():
316306 x402_client = x402Clientv2 ()
317- register_exact_evm_clientv2 (x402_client , EthAccountSignerv2 (self ._wallet_account ),networks = [BASE_TESTNET_NETWORK ])
318- register_upto_evm_clientv2 (x402_client , EthAccountSignerv2 (self ._wallet_account ),networks = [BASE_TESTNET_NETWORK ])
307+ register_exact_evm_clientv2 (x402_client , EthAccountSignerv2 (self ._wallet_account ), networks = [BASE_TESTNET_NETWORK ])
308+ register_upto_evm_clientv2 (x402_client , EthAccountSignerv2 (self ._wallet_account ), networks = [BASE_TESTNET_NETWORK ])
319309
320310 # Security Fix: verify=True enabled
321- async with x402HttpxClientv2 (
322- x402_client
323- ) as client :
311+ async with x402HttpxClientv2 (x402_client ) as client :
324312 headers = {
325313 "Content-Type" : "application/json" ,
326314 "Authorization" : f"Bearer { X402_PLACEHOLDER_API_KEY } " ,
@@ -344,8 +332,10 @@ async def make_request_v2():
344332 try :
345333 # Non-streaming with x402
346334 endpoint = "/v1/chat/completions"
347- response = await client .post (DEFAULT_OPENGRADIENT_V2_LLM_SERVER_URL + endpoint , json = payload , headers = headers , timeout = 60 )
348-
335+ response = await client .post (
336+ DEFAULT_OPENGRADIENT_V2_LLM_SERVER_URL + endpoint , json = payload , headers = headers , timeout = 60
337+ )
338+
349339 content = await response .aread ()
350340 result = json .loads (content .decode ())
351341
0 commit comments