Skip to content

Commit ddfe7a8

Browse files
namespaces
1 parent 1376caf commit ddfe7a8

5 files changed

Lines changed: 44 additions & 48 deletions

File tree

docs/opengradient/client/client.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,7 @@ def __init__(private_key: str, email: Optional[str] = None, password: Optio
3535

3636
#### Variables
3737

38-
* static `inference``Inference`
39-
* static `llm``LLM`
40-
* static `model_hub``ModelHub`
41-
* `alpha` - Access Alpha Testnet features.
42-
43-
Returns:
44-
Alpha: Alpha namespace with workflow and ML model execution methods.
45-
46-
Example:
47-
client = og.Client(...)
48-
result = client.alpha.new_workflow(model_cid, input_query, input_tensor_name)
38+
* [**`inference`**](./onchain_inference): On-chain ONNX model inference via blockchain smart contracts.
39+
* [**`llm`**](./llm): LLM chat and completion via TEE-verified execution.
40+
* [**`model_hub`**](./model_hub): Model Hub for creating, versioning, and uploading ML models.
41+
* [**`alpha`**](./alpha): Alpha Testnet features including workflow management and ML model execution.

docs/opengradient/client/index.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,7 @@ def __init__(private_key: str, email: Optional[str] = None, password: Optio
8282

8383
#### Variables
8484

85-
* static `inference``Inference`
86-
* static `llm``LLM`
87-
* static `model_hub``ModelHub`
88-
* `alpha` - Access Alpha Testnet features.
89-
90-
Returns:
91-
Alpha: Alpha namespace with workflow and ML model execution methods.
92-
93-
Example:
94-
client = og.Client(...)
95-
result = client.alpha.new_workflow(model_cid, input_query, input_tensor_name)
85+
* [**`inference`**](./onchain_inference): On-chain ONNX model inference via blockchain smart contracts.
86+
* [**`llm`**](./llm): LLM chat and completion via TEE-verified execution.
87+
* [**`model_hub`**](./model_hub): Model Hub for creating, versioning, and uploading ML models.
88+
* [**`alpha`**](./alpha): Alpha Testnet features including workflow management and ML model execution.

docs/opengradient/index.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,10 @@ def __init__(private_key: str, email: Optional[str] = None, password: Optio
140140

141141
#### Variables
142142

143-
* static `inference``Inference`
144-
* static `llm``LLM`
145-
* static `model_hub``ModelHub`
146-
* `alpha` - Access Alpha Testnet features.
147-
148-
Returns:
149-
Alpha: Alpha namespace with workflow and ML model execution methods.
150-
151-
Example:
152-
client = og.Client(...)
153-
result = client.alpha.new_workflow(model_cid, input_query, input_tensor_name)
143+
* [**`inference`**](./onchain_inference): On-chain ONNX model inference via blockchain smart contracts.
144+
* [**`llm`**](./llm): LLM chat and completion via TEE-verified execution.
145+
* [**`model_hub`**](./model_hub): Model Hub for creating, versioning, and uploading ML models.
146+
* [**`alpha`**](./alpha): Alpha Testnet features including workflow management and ML model execution.
154147

155148
### `InferenceMode`
156149

src/opengradient/client/client.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
DEFAULT_OPENGRADIENT_LLM_STREAMING_SERVER_URL,
1111
DEFAULT_RPC_URL,
1212
)
13+
from .alpha import Alpha
1314
from .llm import LLM
1415
from .model_hub import ModelHub
1516
from .onchain_inference import Inference
@@ -31,8 +32,13 @@ class Client:
3132
"""
3233

3334
model_hub: ModelHub
35+
"""Model Hub for creating, versioning, and uploading ML models."""
36+
3437
llm: LLM
38+
"""LLM chat and completion via TEE-verified execution."""
39+
3540
inference: Inference
41+
"""On-chain ONNX model inference via blockchain smart contracts."""
3642

3743
def __init__(
3844
self,
@@ -88,19 +94,8 @@ def __init__(
8894
self._alpha = None # Lazy initialization for alpha namespace
8995

9096
@property
91-
def alpha(self):
92-
"""
93-
Access Alpha Testnet features.
94-
95-
Returns:
96-
Alpha: Alpha namespace with workflow and ML model execution methods.
97-
98-
Example:
99-
client = og.Client(...)
100-
result = client.alpha.new_workflow(model_cid, input_query, input_tensor_name)
101-
"""
97+
def alpha(self) -> Alpha:
98+
"""Alpha Testnet features including workflow management and ML model execution."""
10299
if self._alpha is None:
103-
from .alpha import Alpha
104-
105100
self._alpha = Alpha(self._blockchain, self._wallet_account)
106101
return self._alpha

templates/text.mako

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ def format_for_list(docstring, depth=1):
6464
spaces = depth * 2 * ' '
6565
return re.compile(r'\n\n', re.MULTILINE).sub('\n\n' + spaces, docstring)
6666
67+
def resolve_namespace_target(v):
68+
"""If v's type resolves to an opengradient class in a different module, return link target."""
69+
result = [None]
70+
var_mod = v.module.name if hasattr(v, 'module') and v.module else ''
71+
def capture(dobj):
72+
if not isinstance(dobj, pdoc.Module) and hasattr(dobj, 'module') and dobj.module is not None:
73+
mod_parts = dobj.module.name.split('.')
74+
if (len(mod_parts) >= 2 and mod_parts[0] == 'opengradient'
75+
and dobj.module.name != var_mod):
76+
result[0] = mod_parts[-1] if len(mod_parts) > 2 else mod_parts[1]
77+
return '`{}`'.format(dobj.qualname.split('.')[-1])
78+
if show_type_annotations:
79+
v.type_annotation(link=capture)
80+
return result[0]
81+
6782
def linkify(text, mod):
6883
"""Convert backtick-wrapped qualified names to markdown links."""
6984
cur_parts = mod.name.split('.')
@@ -185,14 +200,21 @@ prefix = qual + ' ' if qual else ''
185200
%>\
186201
% for v in vs:
187202
<%
188-
return_type = get_annotation(v.type_annotation, link=link)
189-
type_str = return_type if return_type else ''
190203
raw_desc = v.docstring.strip() if v.docstring else ''
191204
if raw_desc == 'The type of the None singleton.':
192205
raw_desc = ''
206+
ns_target = resolve_namespace_target(v)
207+
%>\
208+
% if ns_target:
209+
* [**`${v.name}`**](./${ns_target})${ ': ' + firstline(raw_desc) if raw_desc else ''}
210+
% else:
211+
<%
212+
return_type = get_annotation(v.type_annotation, link=link)
213+
type_str = return_type if return_type else ''
193214
desc = ' - ' + format_for_list(raw_desc, 1) if raw_desc else ''
194215
%>\
195216
* ${prefix}`${v.name}`${type_str}${desc}
217+
% endif
196218
% endfor
197219
</%def>\
198220
<%def name="show_module(module)">\

0 commit comments

Comments
 (0)