opengradient 0.5.2__py3-none-any.whl → 0.5.4__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/cli.py CHANGED
@@ -20,7 +20,7 @@ from .defaults import (
20
20
  DEFAULT_API_URL,
21
21
  DEFAULT_LLM_SERVER_URL,
22
22
  )
23
- from .types import InferenceMode, LlmInferenceMode, LLM, TEE_LLM
23
+ from .types import InferenceMode, LlmInferenceMode, LLM, TEE_LLM, x402SettlementMode
24
24
 
25
25
  OG_CONFIG_FILE = Path.home() / ".opengradient_config.json"
26
26
 
@@ -74,6 +74,12 @@ LlmInferenceModes = {
74
74
  }
75
75
 
76
76
 
77
+ x402SettlementModes = {
78
+ "settle-batch": x402SettlementMode.SETTLE_BATCH,
79
+ "settle": x402SettlementMode.SETTLE,
80
+ "settle-metadata": x402SettlementMode.SETTLE_METADATA,
81
+ }
82
+
77
83
  def initialize_config(ctx):
78
84
  """Interactively initialize OpenGradient config"""
79
85
  if ctx.obj: # Check if config data already exists
@@ -422,8 +428,9 @@ def infer(ctx, model_cid: str, inference_mode: str, input_data, input_file: Path
422
428
  @click.option("--stop-sequence", multiple=True, help="Stop sequences for LLM")
423
429
  @click.option("--temperature", type=float, default=0.0, help="Temperature for LLM inference (0.0 to 1.0)")
424
430
  @click.option("--local", is_flag=True, help="Force use of local model even if not in LLM enum")
431
+ @click.option("--x402-settlement-mode", "x402_settlement_mode", type=click.Choice(x402SettlementModes.keys()), default="settle-batch", help="Settlement mode for x402 payload")
425
432
  @click.pass_context
426
- def completion(ctx, model_cid: str, inference_mode: str, prompt: str, max_tokens: int, stop_sequence: List[str], temperature: float, local: bool):
433
+ def completion(ctx, model_cid: str, inference_mode: str, x402_settlement_mode: str, prompt: str, max_tokens: int, stop_sequence: List[str], temperature: float, local: bool):
427
434
  """
428
435
  Run completion inference on an LLM model (local or external).
429
436
 
@@ -464,6 +471,7 @@ def completion(ctx, model_cid: str, inference_mode: str, prompt: str, max_tokens
464
471
  stop_sequence=list(stop_sequence),
465
472
  temperature=temperature,
466
473
  local_model=local,
474
+ x402_settlement_mode=x402_settlement_mode,
467
475
  )
468
476
 
469
477
  print_llm_completion_result(model_cid, completion_output.transaction_hash, completion_output.completion_output, is_local)
@@ -529,6 +537,7 @@ def print_llm_completion_result(model_cid, tx_hash, llm_output, is_local=True):
529
537
  )
530
538
  @click.option("--tool-choice", type=str, default="", help="Specific tool choice for the LLM")
531
539
  @click.option("--local", is_flag=True, help="Force use of local model even if not in LLM enum")
540
+ @click.option("--x402-settlement-mode", type=click.Choice(x402SettlementModes.keys()), default="settle-batch", help="Settlement mode for x402 payload")
532
541
  @click.pass_context
533
542
  def chat(
534
543
  ctx,
@@ -542,6 +551,7 @@ def chat(
542
551
  tools: Optional[str],
543
552
  tools_file: Optional[Path],
544
553
  tool_choice: Optional[str],
554
+ x402_settlement_mode: Optional[str],
545
555
  local: bool,
546
556
  ):
547
557
  """
@@ -637,6 +647,7 @@ def chat(
637
647
  tools=parsed_tools,
638
648
  tool_choice=tool_choice,
639
649
  local_model=local,
650
+ x402_settlement_mode=x402_settlement_mode,
640
651
  )
641
652
 
642
653
  print_llm_chat_result(
opengradient/client.py CHANGED
@@ -23,6 +23,7 @@ from .proto import infer_pb2, infer_pb2_grpc
23
23
  from .types import (
24
24
  LLM,
25
25
  TEE_LLM,
26
+ x402SettlementMode,
26
27
  HistoricalInputQuery,
27
28
  InferenceMode,
28
29
  LlmInferenceMode,
@@ -436,6 +437,7 @@ class Client:
436
437
  inference_mode: LlmInferenceMode = LlmInferenceMode.VANILLA,
437
438
  max_retries: Optional[int] = None,
438
439
  local_model: Optional[bool] = False,
440
+ x402_settlement_mode: Optional[x402SettlementMode] = x402SettlementMode.SETTLE_BATCH,
439
441
  ) -> TextGenerationOutput:
440
442
  """
441
443
  Perform inference on an LLM model using completions.
@@ -470,6 +472,7 @@ class Client:
470
472
  max_tokens=max_tokens,
471
473
  stop_sequence=stop_sequence,
472
474
  temperature=temperature,
475
+ x402_settlement_mode=x402_settlement_mode,
473
476
  )
474
477
 
475
478
  # Original local model logic
@@ -516,6 +519,7 @@ class Client:
516
519
  max_tokens: int = 100,
517
520
  stop_sequence: Optional[List[str]] = None,
518
521
  temperature: float = 0.0,
522
+ x402_settlement_mode: Optional[x402SettlementMode] = x402SettlementMode.SETTLE_BATCH,
519
523
  ) -> TextGenerationOutput:
520
524
  """
521
525
  Route completion request to external LLM server with x402 payments.
@@ -584,7 +588,8 @@ class Client:
584
588
  ) as client:
585
589
  headers = {
586
590
  "Content-Type": "application/json",
587
- "Authorization": f"Bearer {X402_PLACEHOLDER_API_KEY}"
591
+ "Authorization": f"Bearer {X402_PLACEHOLDER_API_KEY}",
592
+ "X-SETTLEMENT-TYPE": x402_settlement_mode,
588
593
  }
589
594
 
590
595
  payload = {
@@ -645,6 +650,7 @@ class Client:
645
650
  tool_choice: Optional[str] = None,
646
651
  max_retries: Optional[int] = None,
647
652
  local_model: Optional[bool] = False,
653
+ x402_settlement_mode: Optional[x402SettlementMode] = x402SettlementMode.SETTLE_BATCH,
648
654
  ) -> TextGenerationOutput:
649
655
  """
650
656
  Perform inference on an LLM model using chat.
@@ -681,6 +687,7 @@ class Client:
681
687
  temperature=temperature,
682
688
  tools=tools,
683
689
  tool_choice=tool_choice,
690
+ x402_settlement_mode=x402_settlement_mode,
684
691
  )
685
692
 
686
693
  # Original local model logic
@@ -760,6 +767,7 @@ class Client:
760
767
  temperature: float = 0.0,
761
768
  tools: Optional[List[Dict]] = None,
762
769
  tool_choice: Optional[str] = None,
770
+ x402_settlement_mode: x402SettlementMode = x402SettlementMode.SETTLE_BATCH,
763
771
  ) -> TextGenerationOutput:
764
772
  """
765
773
  Route chat request to external LLM server with x402 payments.
@@ -835,7 +843,8 @@ class Client:
835
843
  ) as client:
836
844
  headers = {
837
845
  "Content-Type": "application/json",
838
- "Authorization": f"Bearer {X402_PLACEHOLDER_API_KEY}"
846
+ "Authorization": f"Bearer {X402_PLACEHOLDER_API_KEY}",
847
+ "X-SETTLEMENT-TYPE": x402_settlement_mode
839
848
  }
840
849
 
841
850
  payload = {
opengradient/types.py CHANGED
@@ -1,10 +1,15 @@
1
1
  import time
2
2
  from dataclasses import dataclass
3
- from enum import Enum, IntEnum
3
+ from enum import Enum, IntEnum, StrEnum
4
4
  from typing import Dict, List, Optional, Tuple, Union, DefaultDict
5
5
  import numpy as np
6
6
 
7
7
 
8
+ class x402SettlementMode(StrEnum):
9
+ SETTLE = "settle"
10
+ SETTLE_METADATA = "settle-metadata"
11
+ SETTLE_BATCH = "settle-batch"
12
+
8
13
  class CandleOrder(IntEnum):
9
14
  ASCENDING = 0
10
15
  DESCENDING = 1
@@ -215,11 +220,12 @@ class LLM(str, Enum):
215
220
  GEMINI_2_5_FLASH = "Google/gemini-2.5-flash"
216
221
  GEMINI_2_5_PRO = "Google/gemini-2.5-pro"
217
222
  GEMINI_2_0_FLASH = "Google/gemini-2.0-flash"
223
+ GEMINI_2_5_FLASH_LITE = "Google/gemini-2.5-flash-lite"
218
224
 
219
225
  # xAI Grok models via TEE
220
226
  GROK_3_MINI_BETA = "xAI/grok-3-mini-beta"
221
227
  GROK_3_BETA = "xAI/grok-3-beta"
222
- GROK_2_1212 = "grok-2-1212"
228
+ GROK_2_1212 = "xAI/grok-2-1212"
223
229
  GROK_2_VISION_LATEST = "xAI/grok-2-vision-latest"
224
230
  GROK_4_1_FAST = "xAI/grok-4.1-fast"
225
231
  GROK_4_1_FAST_NON_REASONING = "xAI/grok-4-1-fast-non-reasoning"
@@ -244,6 +250,7 @@ class TEE_LLM(str, Enum):
244
250
  GEMINI_2_5_FLASH = "Google/gemini-2.5-flash"
245
251
  GEMINI_2_5_PRO = "Google/gemini-2.5-pro"
246
252
  GEMINI_2_0_FLASH = "Google/gemini-2.0-flash"
253
+ GEMINI_2_5_FLASH_LITE = "Google/gemini-2.5-flash-lite"
247
254
 
248
255
  # xAI Grok models via TEE
249
256
  GROK_3_MINI_BETA = "xAI/grok-3-mini-beta"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opengradient
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: Python SDK for OpenGradient decentralized model management & inference services
5
5
  Author-email: OpenGradient <kyle@vannalabs.ai>
6
6
  License-Expression: MIT
@@ -1,10 +1,10 @@
1
1
  opengradient/__init__.py,sha256=wVg0KTFNBl7RnZF9huR5-m_q1E7tO-YyQwY7AD9JFoc,12635
2
2
  opengradient/account.py,sha256=5wrYpws_1lozjOFjLCTHtxgoxK-LmObDAaVy9eDcJY4,1145
3
- opengradient/cli.py,sha256=QzjH_KS6TF8gm_L1otFWA-oHkJ5SSfizFoRn0xR0b70,29162
4
- opengradient/client.py,sha256=Seid3raffwAcrc3qVIINu259iO-BdaGXGT5O2VaT6ac,62356
3
+ opengradient/cli.py,sha256=RksBEGVcZgUg6ng53Fgz-Ncv1erBwdADgblB2HmKkwk,29868
4
+ opengradient/client.py,sha256=4_Rr5oQ-wrj-LTA54uWF_FplkpkRWT1K2ectD8SSEoA,62991
5
5
  opengradient/defaults.py,sha256=w8-dr5ciF2TGnqbm_ib0Yz4U0YL5ikpNqkcPVpmXzP8,673
6
6
  opengradient/exceptions.py,sha256=88tfegboGtlehQcwhxsl6ZzhLJWZWlkf_bkHTiCtXpo,3391
7
- opengradient/types.py,sha256=ygnQXoGJPv9i3daS0oduUsmUNoPGx6Oozkt-Yy7Nn6s,7548
7
+ opengradient/types.py,sha256=mMIuPdabk0EOTX7GKlve6Po8fXdaXJf0ty4FkK8FPBw,7811
8
8
  opengradient/utils.py,sha256=ZUq4OBIml2vsC0tRqus4Zwb_e3g4woo00apByrafuVw,8058
9
9
  opengradient/abi/InferencePrecompile.abi,sha256=reepTHg6Q01UrFP0Gexc-JayplsvOLPfG7jrEZ-cV28,10197
10
10
  opengradient/abi/PriceHistoryInference.abi,sha256=ZB3fZdx1kaFlp2wt1vTbTZZG1k8HPvmNtkG5Q8Bnajw,5098
@@ -27,9 +27,9 @@ opengradient/workflow_models/constants.py,sha256=viIkb_LGcfVprqQNaA80gBTj6cfYam0
27
27
  opengradient/workflow_models/types.py,sha256=Z22hF6c8Y4D2GlzVEIBODGwsqSjSrQvUcpZ7R-mIJdI,409
28
28
  opengradient/workflow_models/utils.py,sha256=ySfpuiOBqLTlfto6ZxZf2vc7K6RGIja0l4eaVm5AOzY,1503
29
29
  opengradient/workflow_models/workflow_models.py,sha256=d4C_gs39DAfy4cdY9Ee6GMXpPfzwvKFpmxzK1A7LNgU,3900
30
- opengradient-0.5.2.dist-info/licenses/LICENSE,sha256=xEcvQ3AxZOtDkrqkys2Mm6Y9diEnaSeQRKvxi-JGnNA,1069
31
- opengradient-0.5.2.dist-info/METADATA,sha256=vKpBpoNs4RhhXcz275SIoYrIpL550Z7ykk_9zS0-CdA,3992
32
- opengradient-0.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- opengradient-0.5.2.dist-info/entry_points.txt,sha256=yUKTaJx8RXnybkob0J62wVBiCp_1agVbgw9uzsmaeJc,54
34
- opengradient-0.5.2.dist-info/top_level.txt,sha256=oC1zimVLa2Yi1LQz8c7x-0IQm92milb5ax8gHBHwDqU,13
35
- opengradient-0.5.2.dist-info/RECORD,,
30
+ opengradient-0.5.4.dist-info/licenses/LICENSE,sha256=xEcvQ3AxZOtDkrqkys2Mm6Y9diEnaSeQRKvxi-JGnNA,1069
31
+ opengradient-0.5.4.dist-info/METADATA,sha256=pTq5pCDiXEEcu0TcTjYVQ6I5M5OGtP257if1ssTCFkQ,3992
32
+ opengradient-0.5.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ opengradient-0.5.4.dist-info/entry_points.txt,sha256=yUKTaJx8RXnybkob0J62wVBiCp_1agVbgw9uzsmaeJc,54
34
+ opengradient-0.5.4.dist-info/top_level.txt,sha256=oC1zimVLa2Yi1LQz8c7x-0IQm92milb5ax8gHBHwDqU,13
35
+ opengradient-0.5.4.dist-info/RECORD,,