Skip to content

Commit 320d64b

Browse files
author
balogh.adam@icloud.com
committed
rm client class
1 parent bf76c9f commit 320d64b

30 files changed

Lines changed: 219 additions & 517 deletions

examples/alpha/create_workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import opengradient as og
44

5-
og_client = og.Client(private_key=os.environ.get("OG_PRIVATE_KEY"))
5+
alpha = og.Alpha(private_key=os.environ.get("OG_PRIVATE_KEY"))
66

77
# Define model input
88
input_query = og.HistoricalInputQuery(
@@ -21,7 +21,7 @@
2121
model_cid = "hJD2Ja3akZFt1A2LT-D_1oxOCz_OtuGYw4V9eE1m39M"
2222

2323
# Deploy schedule
24-
contract_address = og_client.alpha.new_workflow(
24+
contract_address = alpha.new_workflow(
2525
model_cid=model_cid,
2626
input_query=input_query,
2727
# Input name in ONNX model

examples/alpha/run_embeddings_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import opengradient as og
44

5-
og_client = og.Client(private_key=os.environ.get("OG_PRIVATE_KEY"))
5+
alpha = og.Alpha(private_key=os.environ.get("OG_PRIVATE_KEY"))
66

77
queries = [
88
"how much protein should a female eat",
@@ -14,7 +14,7 @@
1414
"Since you're reading this, you are probably someone from a judo background or someone who is just wondering how judo techniques can be applied under wrestling rules. So without further ado, let's get to the question. Are Judo throws allowed in wrestling? Yes, judo throws are allowed in freestyle and folkstyle wrestling. You only need to be careful to follow the slam rules when executing judo throws. In wrestling, a slam is lifting and returning an opponent to the mat with unnecessary force.",
1515
]
1616

17-
model_embeddings = og_client.alpha.infer(
17+
model_embeddings = alpha.infer(
1818
model_cid="intfloat/multilingual-e5-large-instruct",
1919
model_input={"queries": queries, "instruction": instruction, "passages": passages},
2020
inference_mode=og.InferenceMode.VANILLA,

examples/alpha/run_inference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import opengradient as og
44

5-
og_client = og.Client(private_key=os.environ.get("OG_PRIVATE_KEY"))
5+
alpha = og.Alpha(private_key=os.environ.get("OG_PRIVATE_KEY"))
66

7-
inference_result = og_client.alpha.infer(
7+
inference_result = alpha.infer(
88
model_cid="hJD2Ja3akZFt1A2LT-D_1oxOCz_OtuGYw4V9eE1m39M",
99
model_input={
1010
"open_high_low_close": [

examples/alpha/use_workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import opengradient as og
44

5-
og_client = og.Client(private_key=os.environ.get("OG_PRIVATE_KEY"))
5+
alpha = og.Alpha(private_key=os.environ.get("OG_PRIVATE_KEY"))
66

7-
model_output = og_client.alpha.read_workflow_result(
7+
model_output = alpha.read_workflow_result(
88
# This is the workflow contract address that you previously deployed
99
contract_address="0x58Dd93E1aE6B6f21b479b3B2913B055eFD2E74Ee"
1010
)
1111

1212
print(f"Latest model prediction: {model_output.numbers}")
1313

14-
model_output_history = og_client.alpha.read_workflow_history(
14+
model_output_history = alpha.read_workflow_history(
1515
# This is the workflow contract address that you previously deployed
1616
contract_address="0x58Dd93E1aE6B6f21b479b3B2913B055eFD2E74Ee",
1717
num_results=5,

examples/create_model_repo.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
import opengradient as og
44

5-
og_client = og.Client(
6-
private_key=os.environ.get("OG_PRIVATE_KEY"),
5+
hub = og.ModelHub(
76
email=os.environ.get("OG_MODEL_HUB_EMAIL"),
87
password=os.environ.get("OG_MODEL_HUB_PASSWORD"),
98
)
109

11-
og_client.model_hub.create_model(
12-
model_name="example-model", model_desc="An example machine learning model for demonstration purposes", version="1.0.0"
13-
)
10+
hub.create_model(model_name="example-model", model_desc="An example machine learning model for demonstration purposes", version="1.0.0")

examples/langchain_react_agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515

1616
import opengradient as og
1717

18+
private_key = os.environ.get("OG_PRIVATE_KEY")
19+
1820
# One-time Permit2 approval for OPG spending (idempotent)
19-
client = og.init(private_key=os.environ.get("OG_PRIVATE_KEY"))
20-
client.llm.ensure_opg_approval(opg_amount=5)
21+
llm_client = og.LLM(private_key=private_key)
22+
llm_client.ensure_opg_approval(opg_amount=5)
2123

2224
# Create the OpenGradient LangChain adapter
2325
llm = og.agents.langchain_adapter(
24-
private_key=os.environ.get("OG_PRIVATE_KEY"),
26+
private_key=private_key,
2527
model_cid=og.TEE_LLM.GPT_4_1_2025_04_14,
2628
max_tokens=300,
2729
x402_settlement_mode=og.x402SettlementMode.INDIVIDUAL_FULL,

examples/llm_chat.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99

1010

1111
async def main():
12-
client = og.Client(
13-
private_key=os.environ.get("OG_PRIVATE_KEY"),
14-
)
15-
client.llm.ensure_opg_approval(opg_amount=2)
12+
llm = og.LLM(private_key=os.environ.get("OG_PRIVATE_KEY"))
13+
llm.ensure_opg_approval(opg_amount=2)
1614

1715
messages = [
1816
{"role": "user", "content": "What is the capital of France?"},
1917
]
2018

21-
result = await client.llm.chat(
19+
result = await llm.chat(
2220
model=og.TEE_LLM.GEMINI_2_5_FLASH,
2321
messages=messages,
2422
max_tokens=300,

examples/llm_chat_streaming.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55

66

77
async def main():
8-
client = og.Client(
9-
private_key=os.environ.get("OG_PRIVATE_KEY"),
10-
)
11-
client.llm.ensure_opg_approval(opg_amount=1)
8+
llm = og.LLM(private_key=os.environ.get("OG_PRIVATE_KEY"))
9+
llm.ensure_opg_approval(opg_amount=1)
1210

1311
messages = [
1412
{"role": "user", "content": "What is Python?"},
1513
{"role": "assistant", "content": "Python is a high-level programming language."},
1614
{"role": "user", "content": "What makes it good for beginners?"},
1715
]
1816

19-
stream = await client.llm.chat(
17+
stream = await llm.chat(
2018
model=og.TEE_LLM.GPT_4_1_2025_04_14,
2119
messages=messages,
2220
x402_settlement_mode=og.x402SettlementMode.INDIVIDUAL_FULL,

examples/llm_tool_calling.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313

1414

1515
async def main():
16-
# Initialize client
17-
client = og.Client(
18-
private_key=os.environ.get("OG_PRIVATE_KEY"),
19-
)
16+
llm = og.LLM(private_key=os.environ.get("OG_PRIVATE_KEY"))
2017

2118
# Define a simple tool
2219
tools = [
@@ -54,15 +51,15 @@ async def main():
5451
]
5552

5653
# One-time Permit2 approval for OPG spending (idempotent)
57-
client.llm.ensure_opg_approval(opg_amount=5)
54+
llm.ensure_opg_approval(opg_amount=5)
5855

5956
print("Testing Gemini tool calls...")
6057
print(f"Model: {og.TEE_LLM.GEMINI_2_5_FLASH_LITE}")
6158
print(f"Messages: {messages}")
6259
print(f"Tools: {tools}")
6360
print("-" * 50)
6461

65-
result = await client.llm.chat(
62+
result = await llm.chat(
6663
model=og.TEE_LLM.GEMINI_2_5_FLASH_LITE,
6764
messages=messages,
6865
tools=tools,

examples/twins_chat.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55

66
import opengradient as og
77

8-
client = og.init(
9-
private_key=os.environ.get("OG_PRIVATE_KEY"),
10-
twins_api_key=os.environ.get("TWINS_API_KEY"),
11-
)
8+
twins = og.Twins(api_key=os.environ.get("TWINS_API_KEY"))
129

1310
# Chat with Elon Musk
1411
print("--------------------------------")
1512
print("Chat with Elon Musk")
1613
print("--------------------------------")
1714

18-
elon = client.twins.chat(
15+
elon = twins.chat(
1916
twin_id="0x1abd463fd6244be4a1dc0f69e0b70cd5",
2017
model=og.TEE_LLM.GROK_4_1_FAST_NON_REASONING,
2118
messages=[{"role": "user", "content": "What do you think about AI?"}],
@@ -28,7 +25,7 @@
2825
print("Chat with Donald Trump")
2926
print("--------------------------------")
3027

31-
trump = client.twins.chat(
28+
trump = twins.chat(
3229
twin_id="0x66ae99aae4324ed580b2787ac5e811f6",
3330
model=og.TEE_LLM.GROK_4_1_FAST_NON_REASONING,
3431
messages=[{"role": "user", "content": "What's your plan for America?"}],

0 commit comments

Comments
 (0)