opengradient 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl
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.
- opengradient/__init__.py +15 -2
- opengradient/cli.py +33 -8
- opengradient/defaults.py +2 -1
- {opengradient-0.3.3.dist-info → opengradient-0.3.5.dist-info}/METADATA +1 -1
- {opengradient-0.3.3.dist-info → opengradient-0.3.5.dist-info}/RECORD +9 -9
- {opengradient-0.3.3.dist-info → opengradient-0.3.5.dist-info}/WHEEL +1 -1
- {opengradient-0.3.3.dist-info → opengradient-0.3.5.dist-info}/LICENSE +0 -0
- {opengradient-0.3.3.dist-info → opengradient-0.3.5.dist-info}/entry_points.txt +0 -0
- {opengradient-0.3.3.dist-info → opengradient-0.3.5.dist-info}/top_level.txt +0 -0
opengradient/__init__.py
CHANGED
|
@@ -2,7 +2,10 @@ from .client import Client
|
|
|
2
2
|
from .defaults import *
|
|
3
3
|
from .types import InferenceMode
|
|
4
4
|
from typing import List, Dict, Optional, Tuple
|
|
5
|
-
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
__version__ = "0.3.5"
|
|
8
|
+
__all__ = ['init', 'upload', 'create_model', 'create_version', 'infer', 'infer_llm', 'login', 'list_files', 'InferenceMode']
|
|
6
9
|
|
|
7
10
|
_client = None
|
|
8
11
|
|
|
@@ -59,4 +62,14 @@ def login(email: str, password: str):
|
|
|
59
62
|
def list_files(model_name: str, version: str) -> List[Dict]:
|
|
60
63
|
if _client is None:
|
|
61
64
|
raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
|
|
62
|
-
return _client.list_files(model_name, version)
|
|
65
|
+
return _client.list_files(model_name, version)
|
|
66
|
+
|
|
67
|
+
def create_model_from_huggingface(repo_id: str, model_name: str, model_desc: str):
|
|
68
|
+
if _client is None:
|
|
69
|
+
raise RuntimeError("OpenGradient client not initialized. Call og.init() first.")
|
|
70
|
+
|
|
71
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
72
|
+
snapshot_download(repo_id, local_dir=temp_dir)
|
|
73
|
+
result = create_model(model_name, model_desc, temp_dir)
|
|
74
|
+
|
|
75
|
+
return result
|
opengradient/cli.py
CHANGED
|
@@ -118,7 +118,7 @@ def cli(ctx):
|
|
|
118
118
|
try:
|
|
119
119
|
ctx.obj['client'] = Client(private_key=ctx.obj['private_key'],
|
|
120
120
|
rpc_url=ctx.obj['rpc_url'],
|
|
121
|
-
contract_address=
|
|
121
|
+
contract_address=DEFAULT_INFERENCE_CONTRACT_ADDRESS,
|
|
122
122
|
email=ctx.obj.get('email'),
|
|
123
123
|
password=ctx.obj.get('password'))
|
|
124
124
|
except Exception as e:
|
|
@@ -301,12 +301,23 @@ def infer(ctx, model_cid: str, inference_mode: str, input_data, input_file: Path
|
|
|
301
301
|
with input_file.open('r') as file:
|
|
302
302
|
model_input = json.load(file)
|
|
303
303
|
|
|
304
|
-
click.echo(f"Running {inference_mode} inference for model \"{model_cid}\"
|
|
304
|
+
click.echo(f"Running {inference_mode} inference for model \"{model_cid}\"")
|
|
305
305
|
tx_hash, model_output = client.infer(model_cid=model_cid, inference_mode=InferenceModes[inference_mode], model_input=model_input)
|
|
306
306
|
|
|
307
|
-
click.
|
|
308
|
-
click.
|
|
309
|
-
click.echo(
|
|
307
|
+
click.echo() # Add a newline for better spacing
|
|
308
|
+
click.secho("✅ Transaction successful", fg="green", bold=True)
|
|
309
|
+
click.echo("──────────────────────────────────────")
|
|
310
|
+
click.echo(f"Transaction hash: ", nl=False)
|
|
311
|
+
click.secho(tx_hash, fg="cyan", bold=True)
|
|
312
|
+
|
|
313
|
+
block_explorer_link = f"{DEFAULT_BLOCKCHAIN_EXPLORER}0x{tx_hash}"
|
|
314
|
+
click.echo(f"Block explorer link: ", nl=False)
|
|
315
|
+
click.secho(block_explorer_link, fg="blue", underline=True)
|
|
316
|
+
click.echo()
|
|
317
|
+
|
|
318
|
+
click.secho("Inference result:", fg="green")
|
|
319
|
+
formatted_output = json.dumps(model_output, indent=2, default=lambda x: x.tolist() if hasattr(x, 'tolist') else str(x))
|
|
320
|
+
click.echo(formatted_output)
|
|
310
321
|
except json.JSONDecodeError as e:
|
|
311
322
|
click.echo(f"Error decoding JSON: {e}", err=True)
|
|
312
323
|
click.echo(f"Error occurred on line {e.lineno}, column {e.colno}", err=True)
|
|
@@ -343,12 +354,26 @@ def llm(ctx, model_cid: str, prompt: str, max_tokens: int, stop_sequence: List[s
|
|
|
343
354
|
temperature=temperature
|
|
344
355
|
)
|
|
345
356
|
|
|
346
|
-
|
|
347
|
-
click.echo(f"Transaction hash: {tx_hash}")
|
|
348
|
-
click.echo(f"LLM output:\n{llm_output}")
|
|
357
|
+
print_llm_inference_result(model_cid, tx_hash, llm_output)
|
|
349
358
|
except Exception as e:
|
|
350
359
|
click.echo(f"Error running LLM inference: {str(e)}")
|
|
351
360
|
|
|
361
|
+
def print_llm_inference_result(model_cid, tx_hash, llm_output):
|
|
362
|
+
click.secho(f"✅ LLM Inference Successful", fg="green", bold=True)
|
|
363
|
+
click.echo("──────────────────────────────────────")
|
|
364
|
+
click.echo(f"Model CID: ", nl=False)
|
|
365
|
+
click.secho(model_cid, fg="cyan", bold=True)
|
|
366
|
+
click.echo(f"Transaction hash: ", nl=False)
|
|
367
|
+
click.secho(tx_hash, fg="cyan", bold=True)
|
|
368
|
+
block_explorer_link = f"{DEFAULT_BLOCKCHAIN_EXPLORER}0x{tx_hash}"
|
|
369
|
+
click.echo(f"Block explorer link: ", nl=False)
|
|
370
|
+
click.secho(block_explorer_link, fg="blue", underline=True)
|
|
371
|
+
click.echo("──────────────────────────────────────")
|
|
372
|
+
click.secho("LLM Output:", fg="yellow", bold=True)
|
|
373
|
+
click.echo()
|
|
374
|
+
click.echo(llm_output)
|
|
375
|
+
click.echo()
|
|
376
|
+
|
|
352
377
|
@cli.command()
|
|
353
378
|
def create_account():
|
|
354
379
|
"""Create a new test account for OpenGradient inference and model management"""
|
opengradient/defaults.py
CHANGED
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
DEFAULT_RPC_URL="http://18.218.115.248:8545"
|
|
4
4
|
DEFAULT_OG_FAUCET_URL="http://18.218.115.248:8080/?address="
|
|
5
5
|
DEFAULT_HUB_SIGNUP_URL="https://hub.opengradient.ai/signup"
|
|
6
|
-
DEFAULT_INFERENCE_CONTRACT_ADDRESS="
|
|
6
|
+
DEFAULT_INFERENCE_CONTRACT_ADDRESS="0x24Ec56879245C707220Af7234d2fF3F22cA9Aa63"
|
|
7
|
+
DEFAULT_BLOCKCHAIN_EXPLORER="http://3.145.62.2/tx/"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
opengradient/__init__.py,sha256=
|
|
1
|
+
opengradient/__init__.py,sha256=sRZyD9zh_QZFC8H9P8T8pOL5l_ebe3I7hn_gTbTzr6I,2976
|
|
2
2
|
opengradient/account.py,sha256=s1C4hAtc8vcHObWjwxwlYJA041S6DTbr7-rK6qiWPsQ,1149
|
|
3
|
-
opengradient/cli.py,sha256=
|
|
3
|
+
opengradient/cli.py,sha256=gbYJcfLWSZRQ8-xZ2OM0PbicutVGclMiCvCFIQxkvD0,17548
|
|
4
4
|
opengradient/client.py,sha256=DCDp2EWPF62ZQnx2_cM0wPghRxgn213VnR65R8yZBVY,23964
|
|
5
|
-
opengradient/defaults.py,sha256=
|
|
5
|
+
opengradient/defaults.py,sha256=YI84_wWTvWxPMQIuKiSair2wffATnhitE3Ll2P1jHMU,319
|
|
6
6
|
opengradient/exceptions.py,sha256=v4VmUGTvvtjhCZAhR24Ga42z3q-DzR1Y5zSqP_yn2Xk,3366
|
|
7
7
|
opengradient/types.py,sha256=EoJN-DkQrJ2WTUv8OenlrlWJWFY2jPGTl-T8C_OVjp8,1849
|
|
8
8
|
opengradient/utils.py,sha256=F1Nj-GMNFQFxCtbGgWQq1RP4TSurbpQxJV3yKeEo1b0,6482
|
|
9
9
|
opengradient/abi/inference.abi,sha256=u8FsW0s1YeRjUb9eLS1k_qh_5f_cwOdr0bii-tAdxh0,2683
|
|
10
10
|
opengradient/abi/llm.abi,sha256=zhiPFyBT09EI3QU5DVoKHo7e8T9PFcfIQ3RHDYetm4M,3609
|
|
11
|
-
opengradient-0.3.
|
|
12
|
-
opengradient-0.3.
|
|
13
|
-
opengradient-0.3.
|
|
14
|
-
opengradient-0.3.
|
|
15
|
-
opengradient-0.3.
|
|
16
|
-
opengradient-0.3.
|
|
11
|
+
opengradient-0.3.5.dist-info/LICENSE,sha256=xEcvQ3AxZOtDkrqkys2Mm6Y9diEnaSeQRKvxi-JGnNA,1069
|
|
12
|
+
opengradient-0.3.5.dist-info/METADATA,sha256=jqfpyRml-74KsXuOK-b0nA9RyU9jOS4vUbizBTbr38k,7805
|
|
13
|
+
opengradient-0.3.5.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
14
|
+
opengradient-0.3.5.dist-info/entry_points.txt,sha256=yUKTaJx8RXnybkob0J62wVBiCp_1agVbgw9uzsmaeJc,54
|
|
15
|
+
opengradient-0.3.5.dist-info/top_level.txt,sha256=oC1zimVLa2Yi1LQz8c7x-0IQm92milb5ax8gHBHwDqU,13
|
|
16
|
+
opengradient-0.3.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|