opengradient 0.5.4__tar.gz → 0.5.8__tar.gz

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.
Files changed (40) hide show
  1. {opengradient-0.5.4/src/opengradient.egg-info → opengradient-0.5.8}/PKG-INFO +5 -1
  2. {opengradient-0.5.4 → opengradient-0.5.8}/README.md +4 -0
  3. {opengradient-0.5.4 → opengradient-0.5.8}/pyproject.toml +1 -1
  4. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/__init__.py +28 -4
  5. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/cli.py +67 -52
  6. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/client.py +122 -121
  7. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/defaults.py +1 -1
  8. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/llm/og_langchain.py +6 -1
  9. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/types.py +77 -49
  10. {opengradient-0.5.4 → opengradient-0.5.8/src/opengradient.egg-info}/PKG-INFO +5 -1
  11. {opengradient-0.5.4 → opengradient-0.5.8}/LICENSE +0 -0
  12. {opengradient-0.5.4 → opengradient-0.5.8}/setup.cfg +0 -0
  13. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/abi/InferencePrecompile.abi +0 -0
  14. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/abi/PriceHistoryInference.abi +0 -0
  15. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/abi/WorkflowScheduler.abi +0 -0
  16. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/abi/inference.abi +0 -0
  17. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/account.py +0 -0
  18. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/alphasense/__init__.py +0 -0
  19. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/alphasense/read_workflow_tool.py +0 -0
  20. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/alphasense/run_model_tool.py +0 -0
  21. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/alphasense/types.py +0 -0
  22. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/bin/PriceHistoryInference.bin +0 -0
  23. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/exceptions.py +0 -0
  24. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/llm/__init__.py +0 -0
  25. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/llm/og_openai.py +0 -0
  26. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/proto/__init__.py +0 -0
  27. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/proto/infer.proto +0 -0
  28. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/proto/infer_pb2.py +0 -0
  29. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/proto/infer_pb2_grpc.py +0 -0
  30. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/utils.py +0 -0
  31. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/workflow_models/__init__.py +0 -0
  32. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/workflow_models/constants.py +0 -0
  33. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/workflow_models/types.py +0 -0
  34. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/workflow_models/utils.py +0 -0
  35. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient/workflow_models/workflow_models.py +0 -0
  36. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient.egg-info/SOURCES.txt +0 -0
  37. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient.egg-info/dependency_links.txt +0 -0
  38. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient.egg-info/entry_points.txt +0 -0
  39. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient.egg-info/requires.txt +0 -0
  40. {opengradient-0.5.4 → opengradient-0.5.8}/src/opengradient.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opengradient
3
- Version: 0.5.4
3
+ Version: 0.5.8
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
@@ -132,6 +132,10 @@ For comprehensive documentation, API reference, and examples, visit:
132
132
  - [OpenGradient Documentation](https://docs.opengradient.ai/)
133
133
  - [API Reference](https://docs.opengradient.ai/api_reference/python_sdk/)
134
134
 
135
+ ### Claude Code Users
136
+
137
+ If you use [Claude Code](https://claude.ai/code), copy [docs/CLAUDE_SDK_USERS.md](docs/CLAUDE_SDK_USERS.md) to your project's `CLAUDE.md` to help Claude assist you with OpenGradient SDK development.
138
+
135
139
  ## Support
136
140
 
137
141
  - Run `opengradient --help` for CLI command reference
@@ -104,6 +104,10 @@ For comprehensive documentation, API reference, and examples, visit:
104
104
  - [OpenGradient Documentation](https://docs.opengradient.ai/)
105
105
  - [API Reference](https://docs.opengradient.ai/api_reference/python_sdk/)
106
106
 
107
+ ### Claude Code Users
108
+
109
+ If you use [Claude Code](https://claude.ai/code), copy [docs/CLAUDE_SDK_USERS.md](docs/CLAUDE_SDK_USERS.md) to your project's `CLAUDE.md` to help Claude assist you with OpenGradient SDK development.
110
+
107
111
  ## Support
108
112
 
109
113
  - Run `opengradient --help` for CLI command reference
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "opengradient"
7
- version = "0.5.4"
7
+ version = "0.5.8"
8
8
  description = "Python SDK for OpenGradient decentralized model management & inference services"
9
9
  authors = [{name = "OpenGradient", email = "kyle@vannalabs.ai"}]
10
10
  readme = "README.md"
@@ -20,6 +20,7 @@ from .types import (
20
20
  ModelOutput,
21
21
  ModelRepository,
22
22
  FileUploadResult,
23
+ x402SettlementMode,
23
24
  )
24
25
 
25
26
  from . import llm, alphasense
@@ -47,10 +48,25 @@ def new_client(
47
48
  contract_address: Optional inference contract address
48
49
  """
49
50
 
50
- return Client(email=email, password=password, private_key=private_key, rpc_url=rpc_url, api_url=api_url, contract_address=contract_address, **kwargs)
51
+ return Client(
52
+ email=email,
53
+ password=password,
54
+ private_key=private_key,
55
+ rpc_url=rpc_url,
56
+ api_url=api_url,
57
+ contract_address=contract_address,
58
+ **kwargs,
59
+ )
51
60
 
52
61
 
53
- def init(email: str, password: str, private_key: str, rpc_url=DEFAULT_RPC_URL, api_url=DEFAULT_API_URL, contract_address=DEFAULT_INFERENCE_CONTRACT_ADDRESS):
62
+ def init(
63
+ email: str,
64
+ password: str,
65
+ private_key: str,
66
+ rpc_url=DEFAULT_RPC_URL,
67
+ api_url=DEFAULT_API_URL,
68
+ contract_address=DEFAULT_INFERENCE_CONTRACT_ADDRESS,
69
+ ):
54
70
  """Initialize the OpenGradient SDK with authentication and network settings.
55
71
 
56
72
  Args:
@@ -62,8 +78,10 @@ def init(email: str, password: str, private_key: str, rpc_url=DEFAULT_RPC_URL, a
62
78
  contract_address: Optional inference contract address
63
79
  """
64
80
  global _client
65
-
66
- _client = Client(private_key=private_key, rpc_url=rpc_url, api_url=api_url, email=email, password=password, contract_address=contract_address)
81
+
82
+ _client = Client(
83
+ private_key=private_key, rpc_url=rpc_url, api_url=api_url, email=email, password=password, contract_address=contract_address
84
+ )
67
85
  return _client
68
86
 
69
87
 
@@ -162,6 +180,7 @@ def llm_completion(
162
180
  stop_sequence: Optional[List[str]] = None,
163
181
  temperature: float = 0.0,
164
182
  max_retries: Optional[int] = None,
183
+ x402_settlement_mode: Optional[x402SettlementMode] = x402SettlementMode.SETTLE_BATCH,
165
184
  ) -> TextGenerationOutput:
166
185
  """Generate text completion using an LLM.
167
186
 
@@ -173,6 +192,7 @@ def llm_completion(
173
192
  stop_sequence: Optional list of sequences where generation should stop
174
193
  temperature: Sampling temperature (0.0 = deterministic, 1.0 = creative)
175
194
  max_retries: Maximum number of retries for failed transactions
195
+ x402_settlement_mode: Settlement modes for x402 payment protocol transactions (enum x402SettlementMode)
176
196
 
177
197
  Returns:
178
198
  TextGenerationOutput: Transaction hash and generated text
@@ -190,6 +210,7 @@ def llm_completion(
190
210
  stop_sequence=stop_sequence,
191
211
  temperature=temperature,
192
212
  max_retries=max_retries,
213
+ x402_settlement_mode=x402_settlement_mode
193
214
  )
194
215
 
195
216
 
@@ -203,6 +224,7 @@ def llm_chat(
203
224
  tools: Optional[List[Dict]] = None,
204
225
  tool_choice: Optional[str] = None,
205
226
  max_retries: Optional[int] = None,
227
+ x402_settlement_mode: Optional[x402SettlementMode] = x402SettlementMode.SETTLE_BATCH,
206
228
  ) -> TextGenerationOutput:
207
229
  """Have a chat conversation with an LLM.
208
230
 
@@ -216,6 +238,7 @@ def llm_chat(
216
238
  tools: Optional list of tools the model can use
217
239
  tool_choice: Optional specific tool to use
218
240
  max_retries: Maximum number of retries for failed transactions
241
+ x402_settlement_mode: Settlement modes for x402 payment protocol transactions (enum x402SettlementMode)
219
242
 
220
243
  Returns:
221
244
  TextGenerationOutput
@@ -235,6 +258,7 @@ def llm_chat(
235
258
  tools=tools,
236
259
  tool_choice=tool_choice,
237
260
  max_retries=max_retries,
261
+ x402_settlement_mode=x402_settlement_mode
238
262
  )
239
263
 
240
264
 
@@ -80,6 +80,7 @@ x402SettlementModes = {
80
80
  "settle-metadata": x402SettlementMode.SETTLE_METADATA,
81
81
  }
82
82
 
83
+
83
84
  def initialize_config(ctx):
84
85
  """Interactively initialize OpenGradient config"""
85
86
  if ctx.obj: # Check if config data already exists
@@ -140,7 +141,7 @@ def cli(ctx):
140
141
  openai_api_key = ctx.obj.get("openai_api_key")
141
142
  anthropic_api_key = ctx.obj.get("anthropic_api_key")
142
143
  google_api_key = ctx.obj.get("google_api_key")
143
-
144
+
144
145
  ctx.obj["client"] = Client(
145
146
  private_key=ctx.obj["private_key"],
146
147
  rpc_url=DEFAULT_RPC_URL,
@@ -219,9 +220,9 @@ def clear(ctx):
219
220
  def set_api_key(ctx, provider: str, key: str):
220
221
  """
221
222
  Set API key for external LLM providers.
222
-
223
+
223
224
  Example usage:
224
-
225
+
225
226
  \b
226
227
  opengradient config set-api-key --provider openai --key ..
227
228
  opengradient config set-api-key --provider anthropic --key ...
@@ -230,7 +231,7 @@ def set_api_key(ctx, provider: str, key: str):
230
231
  config_key = f"{provider}_api_key"
231
232
  ctx.obj[config_key] = key
232
233
  save_og_config(ctx)
233
-
234
+
234
235
  click.secho(f"✅ API key for {provider} has been set", fg="green")
235
236
  click.echo("You can now use models from this provider in completion and chat commands.")
236
237
 
@@ -241,9 +242,9 @@ def set_api_key(ctx, provider: str, key: str):
241
242
  def remove_api_key(ctx, provider: str):
242
243
  """
243
244
  Remove API key for an external LLM provider.
244
-
245
+
245
246
  Example usage:
246
-
247
+
247
248
  \b
248
249
  opengradient config remove-api-key --provider openai
249
250
  """
@@ -417,52 +418,68 @@ def infer(ctx, model_cid: str, inference_mode: str, input_data, input_file: Path
417
418
  help="Model identifier (local model from LLM enum or external model like 'gpt-4o', 'gemini-2.5-flash-lite', etc.)",
418
419
  )
419
420
  @click.option(
420
- "--mode",
421
- "inference_mode",
422
- type=click.Choice(LlmInferenceModes.keys()),
423
- default="VANILLA",
424
- help="Inference mode (only applies to local models, default: VANILLA)"
421
+ "--mode",
422
+ "inference_mode",
423
+ type=click.Choice(LlmInferenceModes.keys()),
424
+ default="VANILLA",
425
+ help="Inference mode (only applies to local models, default: VANILLA)",
425
426
  )
426
427
  @click.option("--prompt", "-p", required=True, help="Input prompt for the LLM completion")
427
428
  @click.option("--max-tokens", type=int, default=100, help="Maximum number of tokens for LLM completion output")
428
429
  @click.option("--stop-sequence", multiple=True, help="Stop sequences for LLM")
429
430
  @click.option("--temperature", type=float, default=0.0, help="Temperature for LLM inference (0.0 to 1.0)")
430
431
  @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")
432
+ @click.option(
433
+ "--x402-settlement-mode",
434
+ "x402_settlement_mode",
435
+ type=click.Choice(x402SettlementModes.keys()),
436
+ default="settle-batch",
437
+ help="Settlement mode for x402 payments: settle (hashes only), settle-batch (batched, default), settle-metadata (full data)",
438
+ )
432
439
  @click.pass_context
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):
440
+ def completion(
441
+ ctx,
442
+ model_cid: str,
443
+ inference_mode: str,
444
+ x402_settlement_mode: str,
445
+ prompt: str,
446
+ max_tokens: int,
447
+ stop_sequence: List[str],
448
+ temperature: float,
449
+ local: bool,
450
+ ):
434
451
  """
435
452
  Run completion inference on an LLM model (local or external).
436
453
 
437
- This command supports both local OpenGradient models and external providers
438
- (OpenAI, Anthropic, Google, etc.). For external models, make sure to set
454
+ This command supports both local OpenGradient models and external providers
455
+ (OpenAI, Anthropic, Google, etc.). For external models, make sure to set
439
456
  the appropriate API key using 'opengradient config set-api-key'.
440
457
 
441
458
  Example usage:
442
459
 
443
460
  \b
444
- # Local model
445
- opengradient completion --model meta-llama/Meta-Llama-3-8B-Instruct --prompt "Hello, how are you?" --max-tokens 50
446
-
461
+ # TEE model
462
+ opengradient completion --model anthropic/claude-3.5-haiku --prompt "Hello, how are you?" --max-tokens 50
463
+
447
464
  # External OpenAI model
448
465
  opengradient completion --model gpt-4o --prompt "Translate to French: Hello world" --max-tokens 50
449
-
466
+
450
467
  # External Anthropic model
451
- opengradient completion --model claude-haiku-4-5-20251001--prompt "Write a haiku about coding" --max-tokens 100
452
-
468
+ opengradient completion --model claude-haiku-4-5-20251001 --prompt "Write a haiku about coding" --max-tokens 100
469
+
453
470
  # External Google model
454
471
  opengradient completion --model gemini-2.5-flash-lite --prompt "Explain quantum computing" --max-tokens 200
455
472
  """
456
473
  client: Client = ctx.obj["client"]
457
-
474
+
458
475
  try:
459
476
  is_local = local or model_cid in [llm.value for llm in LLM]
460
-
477
+
461
478
  if is_local:
462
479
  click.echo(f'Running LLM completion inference for local model "{model_cid}"\n')
463
480
  else:
464
481
  click.echo(f'Running LLM completion inference for external model "{model_cid}"\n')
465
-
482
+
466
483
  completion_output = client.llm_completion(
467
484
  model_cid=model_cid,
468
485
  inference_mode=LlmInferenceModes[inference_mode],
@@ -475,7 +492,7 @@ def completion(ctx, model_cid: str, inference_mode: str, x402_settlement_mode: s
475
492
  )
476
493
 
477
494
  print_llm_completion_result(model_cid, completion_output.transaction_hash, completion_output.completion_output, is_local)
478
-
495
+
479
496
  except Exception as e:
480
497
  click.echo(f"Error running LLM completion: {str(e)}")
481
498
 
@@ -485,7 +502,7 @@ def print_llm_completion_result(model_cid, tx_hash, llm_output, is_local=True):
485
502
  click.echo("──────────────────────────────────────")
486
503
  click.echo("Model: ", nl=False)
487
504
  click.secho(model_cid, fg="cyan", bold=True)
488
-
505
+
489
506
  if is_local and tx_hash != "external":
490
507
  click.echo("Transaction hash: ", nl=False)
491
508
  click.secho(tx_hash, fg="cyan", bold=True)
@@ -495,7 +512,7 @@ def print_llm_completion_result(model_cid, tx_hash, llm_output, is_local=True):
495
512
  else:
496
513
  click.echo("Source: ", nl=False)
497
514
  click.secho("External Provider", fg="cyan", bold=True)
498
-
515
+
499
516
  click.echo("──────────────────────────────────────")
500
517
  click.secho("LLM Output:", fg="yellow", bold=True)
501
518
  click.echo()
@@ -512,11 +529,11 @@ def print_llm_completion_result(model_cid, tx_hash, llm_output, is_local=True):
512
529
  help="Model identifier (local model from LLM enum or external model like 'gpt-4o', 'gemini-2.5-flash-lite', etc.)",
513
530
  )
514
531
  @click.option(
515
- "--mode",
516
- "inference_mode",
517
- type=click.Choice(LlmInferenceModes.keys()),
518
- default="VANILLA",
519
- help="Inference mode (only applies to local models, default: VANILLA)"
532
+ "--mode",
533
+ "inference_mode",
534
+ type=click.Choice(LlmInferenceModes.keys()),
535
+ default="VANILLA",
536
+ help="Inference mode (only applies to local models, default: VANILLA)",
520
537
  )
521
538
  @click.option("--messages", type=str, required=False, help="Input messages for the chat inference in JSON format")
522
539
  @click.option(
@@ -530,14 +547,16 @@ def print_llm_completion_result(model_cid, tx_hash, llm_output, is_local=True):
530
547
  @click.option("--temperature", type=float, default=0.0, help="Temperature for LLM inference (0.0 to 1.0)")
531
548
  @click.option("--tools", type=str, default=None, help="Tool configurations in JSON format")
532
549
  @click.option(
533
- "--tools-file",
534
- type=click.Path(exists=True, path_type=Path),
535
- required=False,
536
- help="Path to JSON file containing tool configurations"
550
+ "--tools-file", type=click.Path(exists=True, path_type=Path), required=False, help="Path to JSON file containing tool configurations"
537
551
  )
538
552
  @click.option("--tool-choice", type=str, default="", help="Specific tool choice for the LLM")
539
553
  @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")
554
+ @click.option(
555
+ "--x402-settlement-mode",
556
+ type=click.Choice(x402SettlementModes.keys()),
557
+ default="settle-batch",
558
+ help="Settlement mode for x402 payments: settle (hashes only), settle-batch (batched, default), settle-metadata (full data)",
559
+ )
541
560
  @click.pass_context
542
561
  def chat(
543
562
  ctx,
@@ -563,25 +582,25 @@ def chat(
563
582
  Example usage:
564
583
 
565
584
  \b
566
- # Local model
567
- opengradient chat --model meta-llama/Meta-Llama-3-8B-Instruct --messages '[{"role":"user","content":"hello"}]' --max-tokens 50
568
-
585
+ # TEE model
586
+ opengradient chat --model anthropic/claude-3.5-haiku --messages '[{"role":"user","content":"hello"}]' --max-tokens 50
587
+
569
588
  # External OpenAI model with tools
570
589
  opengradient chat --model gpt-4o --messages-file messages.json --tools-file tools.json --max-tokens 200
571
-
590
+
572
591
  # External Anthropic model
573
592
  opengradient chat --model claude-haiku-4-5-20251001 --messages '[{"role":"user","content":"Write a poem"}]' --max-tokens 100
574
593
  """
575
594
  client: Client = ctx.obj["client"]
576
-
595
+
577
596
  try:
578
597
  is_local = local or model_cid in [llm.value for llm in LLM]
579
-
598
+
580
599
  if is_local:
581
600
  click.echo(f'Running LLM chat inference for local model "{model_cid}"\n')
582
601
  else:
583
602
  click.echo(f'Running LLM chat inference for external model "{model_cid}"\n')
584
-
603
+
585
604
  # Parse messages
586
605
  if not messages and not messages_file:
587
606
  click.echo("Must specify either messages or messages-file")
@@ -651,13 +670,9 @@ def chat(
651
670
  )
652
671
 
653
672
  print_llm_chat_result(
654
- model_cid,
655
- completion_output.transaction_hash,
656
- completion_output.finish_reason,
657
- completion_output.chat_output,
658
- is_local
673
+ model_cid, completion_output.transaction_hash, completion_output.finish_reason, completion_output.chat_output, is_local
659
674
  )
660
-
675
+
661
676
  except Exception as e:
662
677
  click.echo(f"Error running LLM chat inference: {str(e)}")
663
678
 
@@ -667,7 +682,7 @@ def print_llm_chat_result(model_cid, tx_hash, finish_reason, chat_output, is_loc
667
682
  click.echo("──────────────────────────────────────")
668
683
  click.echo("Model: ", nl=False)
669
684
  click.secho(model_cid, fg="cyan", bold=True)
670
-
685
+
671
686
  if is_local and tx_hash != "external":
672
687
  click.echo("Transaction hash: ", nl=False)
673
688
  click.secho(tx_hash, fg="cyan", bold=True)
@@ -677,7 +692,7 @@ def print_llm_chat_result(model_cid, tx_hash, finish_reason, chat_output, is_loc
677
692
  else:
678
693
  click.echo("Source: ", nl=False)
679
694
  click.secho("External Provider", fg="cyan", bold=True)
680
-
695
+
681
696
  click.echo("──────────────────────────────────────")
682
697
  click.secho("Finish Reason: ", fg="yellow", bold=True)
683
698
  click.echo()