@@ -60,8 +60,8 @@ def __init__(
6060 twins_api_key : Optional [str ] = None ,
6161 rpc_url : str = DEFAULT_RPC_URL ,
6262 api_url : str = DEFAULT_API_URL ,
63- contract_address : str = DEFAULT_INFERENCE_CONTRACT_ADDRESS ,
64- og_llm_server_url : Optional [str ] = None ,
63+ inference_contract_address : str = DEFAULT_INFERENCE_CONTRACT_ADDRESS ,
64+ llm_server_url : Optional [str ] = None ,
6565 tee_registry_address : str = DEFAULT_TEE_REGISTRY_ADDRESS ,
6666 ):
6767 """
@@ -76,54 +76,51 @@ def __init__(
7676 By default the LLM server endpoint and its TLS certificate are fetched from
7777 the on-chain TEE Registry, which stores certificates that were verified during
7878 enclave attestation. You can override the endpoint by passing
79- ``og_llm_server_url `` explicitly (the system CA bundle is used for that URL).
79+ ``llm_server_url `` explicitly (the system CA bundle is used for that URL).
8080
8181 Args:
8282 private_key: Private key whose wallet holds **Base Sepolia OPG tokens**
8383 for x402 LLM payments.
8484 alpha_private_key: Private key whose wallet holds **OpenGradient testnet
8585 gas tokens** for on-chain inference. Optional -- falls back to
8686 ``private_key`` for backward compatibility.
87- email: Email for Model Hub authentication. Optional.
88- password: Password for Model Hub authentication. Optional.
87+ email: Email for Model Hub authentication. Must be provided together
88+ with ``password``.
89+ password: Password for Model Hub authentication. Must be provided
90+ together with ``email``.
8991 twins_api_key: API key for digital twins chat (twin.fun). Optional.
9092 rpc_url: RPC URL for the OpenGradient Alpha Testnet.
9193 api_url: API URL for the OpenGradient API.
92- contract_address: Inference contract address.
93- og_llm_server_url: Override the LLM server URL instead of using the
94+ inference_contract_address: Inference contract address on the
95+ OpenGradient Alpha Testnet.
96+ llm_server_url: Override the LLM server URL instead of using the
9497 registry-discovered endpoint. When set, the TLS certificate is
9598 validated against the system CA bundle rather than the registry.
9699 tee_registry_address: Address of the TEERegistry contract used to
97100 discover active LLM proxy endpoints and their verified TLS certs.
98101 """
99- blockchain = Web3 ( Web3 . HTTPProvider ( rpc_url ))
100- wallet_account = blockchain . eth . account . from_key ( private_key )
102+ if ( email is None ) != ( password is None ):
103+ raise ValueError ( "Both 'email' and 'password' must be provided together for Model Hub authentication." )
101104
102- # Use a separate account for Alpha Testnet when provided
103- if alpha_private_key is not None :
104- alpha_wallet_account = blockchain .eth .account .from_key (alpha_private_key )
105- else :
106- alpha_wallet_account = wallet_account
105+ w3 = Web3 (Web3 .HTTPProvider (rpc_url ))
106+ account = w3 .eth .account .from_key (private_key )
107107
108- hub_user = None
109- if email is not None :
110- hub_user = ModelHub ._login_to_hub (email , password )
108+ # Use a separate account for Alpha Testnet when provided
109+ alpha_account = w3 .eth .account .from_key (alpha_private_key ) if alpha_private_key is not None else account
111110
112- # Create namespaces
113- self .model_hub = ModelHub (hub_user = hub_user )
114- self .wallet_address = wallet_account .address
111+ self .model_hub = ModelHub (email = email , password = password )
115112
116113 self .llm = LLM (
117- wallet_account = wallet_account ,
118- og_llm_server_url = og_llm_server_url ,
114+ wallet_account = account ,
115+ llm_server_url = llm_server_url ,
119116 rpc_url = rpc_url ,
120117 tee_registry_address = tee_registry_address ,
121118 )
122119
123120 self .alpha = Alpha (
124- blockchain = blockchain ,
125- wallet_account = alpha_wallet_account ,
126- inference_hub_contract_address = contract_address ,
121+ blockchain = w3 ,
122+ wallet_account = alpha_account ,
123+ inference_hub_contract_address = inference_contract_address ,
127124 api_url = api_url ,
128125 )
129126
0 commit comments