Skip to content

Commit 4adb77c

Browse files
author
balogh.adam@icloud.com
committed
llm refactor
1 parent 646c38b commit 4adb77c

4 files changed

Lines changed: 275 additions & 393 deletions

File tree

examples/llm_chat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import logging
12
import os
23

34
import opengradient as og
45

6+
logging.basicConfig()
7+
logging.getLogger("opengradient").setLevel(logging.DEBUG)
8+
59
client = og.Client(
610
private_key=os.environ.get("OG_PRIVATE_KEY"),
711
)

src/opengradient/client/client.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Main Client class that unifies all OpenGradient service namespaces."""
22

3-
import logging
43
from typing import Optional
54

65
from web3 import Web3
@@ -14,11 +13,8 @@
1413
from .alpha import Alpha
1514
from .llm import LLM
1615
from .model_hub import ModelHub
17-
from .tee_registry import TEERegistry
1816
from .twins import Twins
1917

20-
logger = logging.getLogger(__name__)
21-
2218

2319
class Client:
2420
"""
@@ -113,42 +109,15 @@ def __init__(
113109
if email is not None:
114110
hub_user = ModelHub._login_to_hub(email, password)
115111

116-
# Resolve LLM server URL and TLS certificate.
117-
# If the caller provided explicit URLs, use those with standard CA verification.
118-
# Otherwise, discover the endpoint and registry-verified cert from the TEE Registry.
119-
llm_tls_cert_der: Optional[bytes] = None
120-
tee = None
121-
if og_llm_server_url is None:
122-
try:
123-
registry = TEERegistry(
124-
rpc_url=rpc_url,
125-
registry_address=tee_registry_address,
126-
)
127-
tee = registry.get_llm_tee()
128-
if tee is not None:
129-
og_llm_server_url = tee.endpoint
130-
llm_tls_cert_der = tee.tls_cert_der
131-
logger.info("Using TEE endpoint from registry: %s (teeId=%s)", tee.endpoint, tee.tee_id)
132-
else:
133-
raise ValueError("No active LLM proxy TEE found in the registry. Pass og_llm_server_url explicitly to override.")
134-
except ValueError:
135-
raise
136-
except Exception as e:
137-
raise RuntimeError(
138-
f"Failed to fetch LLM TEE endpoint from registry ({tee_registry_address} on {rpc_url}): {e}. "
139-
"Pass og_llm_server_url explicitly to override."
140-
) from e
141-
142112
# Create namespaces
143113
self.model_hub = ModelHub(hub_user=hub_user)
144114
self.wallet_address = wallet_account.address
145115

146116
self.llm = LLM(
147117
wallet_account=wallet_account,
148118
og_llm_server_url=og_llm_server_url,
149-
tls_cert_der=llm_tls_cert_der,
150-
tee_id=tee.tee_id if tee is not None else None,
151-
tee_payment_address=tee.payment_address if tee is not None else None,
119+
rpc_url=rpc_url,
120+
tee_registry_address=tee_registry_address,
152121
)
153122

154123
self.alpha = Alpha(

0 commit comments

Comments
 (0)