mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
pkg/hanzoai/cloud goes +2186 -2126 ~175: 1700 paths / 2354 operations / 2186 schemas, 182 api modules and 2172 model modules, against the 239/1116 it carried from hanzo.yaml. The document is hanzoai/cloud's own emission now, pinned in a new .spec-lock by commit and sha256, and generate.py reaches it by value — --skip-validate-spec means the 1012 missing-`responses` errors no longer write zero files, so a client can be cut from the authority instead of a projection of it. Two renamings come with that, and both are the fix rather than the damage. IAM's types are namespace-qualified (iam.Role, iam.Application, 95 of them) because a bare `Role` was two unrelated shapes wearing one name. And the <svc>_ prefix is gone from every operationId, so every generated method lost it. The prefix is what broke the examples, and the gate saw only two thirds of it. Four flows failed on their imports; `money` and `tools` PASSED while every call in them named a method that no longer existed — an import resolves the names in the `from … import` line and a method is looked up at call time. All five flows now name operations that exist, checked by resolving each one as an attribute, and hanzo.yml records that ceiling so the next reader does not trust the gate for more than it says. `chat` is removed, which is a measurement and not a preference: cloud declares POST /v1/chat/completions with no requestBody and no responses at all, so the generated method takes no body and returns None — the one call a chat example exists to make cannot be expressed. Inventing the type, or hand-rolling the HTTP inside a generated client, is the drift these SDKs exist to prevent; js-sdk dropped its own chat flow at 2.0.7 for exactly this. It returns the release cloud gives that route a body. Two smoke assertions were already red before this regeneration and are now true again: they pinned AIApi/APIKeysApi/MCPApi and AdminApi.plugin_admin_*, names from the retired lineage. The surface is all still there under AiApi/KeysApi/ McpApi and AdminApi.admin_plugins. tests/test_zap_transport.py still errors, exactly as it did before: it imports `Hanzo` from hanzoai, which the hand-written package does not define. That is not this document's business and is untouched. Minor rather than patch: every generated method changed name. Co-authored-by: Hanzo Dev <[email protected]>
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
"""agent — define one, run it, read the run back.
|
|
|
|
POST /v1/agents post_v1_agents
|
|
POST /v1/agents/{ref}/run post_v1_agents_by_ref_run
|
|
GET /v1/agents/{ref}/runs get_v1_agents_ref_runs
|
|
|
|
``ref`` is the agent's public id (``agent_...``) OR its org-unique name, which
|
|
is why the run and the read below can both use the name we just created without
|
|
waiting for an id to come back.
|
|
|
|
The read-back is the RUN list rather than the agent record: an agent you just
|
|
created tells you nothing you did not just send, while its runs are the part the
|
|
server actually produced.
|
|
|
|
python -m examples.agent
|
|
"""
|
|
|
|
import time
|
|
|
|
from hanzoai.cloud import AgentsApi, CreateAgentIn
|
|
|
|
from examples.client import MODEL, client, run
|
|
|
|
# Org-unique: a fixed name collides with itself on the second run.
|
|
NAME = f"example-greeter-{time.time_ns()}"
|
|
|
|
|
|
def main() -> None:
|
|
with client() as api:
|
|
agents = AgentsApi(api)
|
|
|
|
created = agents.post_v1_agents(
|
|
CreateAgentIn(
|
|
name=NAME,
|
|
model=MODEL,
|
|
description="Created by the hanzoai SDK agent example.",
|
|
instructions="You greet the user in one short sentence.",
|
|
)
|
|
)
|
|
print(f"created {created.name} ({created.id}) on {created.model}")
|
|
|
|
agents.post_v1_agents_by_ref_run(NAME)
|
|
print("run started")
|
|
|
|
runs = agents.get_v1_agents_ref_runs(NAME, limit=5)
|
|
entries = runs.runs or []
|
|
print(f"{len(entries)} run(s):")
|
|
for entry in entries:
|
|
print(f" {entry.to_str()}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run(main)
|