Service Registering
This example creates a graph in a specific Governance Studio project and registers the graph, statements, and blobs with a service endpoint.
Source: examples/service-registering.py
from uuid import UUID
from eqty_sdk import (
Agent,
Computation,
Context,
Dataset,
Model,
Service,
Signer,
init,
set_active_signer,
)
gov_studio_project = UUID("00000000-0000-0000-0000-000000000000")
gov_ctx = Context.from_uuid(gov_studio_project)
ctx = Context.with_parent(gov_ctx).new("My Agent v1")
cfg = init(default_context=ctx)
signer = Signer.new()
set_active_signer(signer)
user_prompt = Dataset.from_object("User Prompt", name="User Prompt")
system_prompt = Dataset.from_object("System Prompt", name="System Prompt")
model_v1 = Model.from_object("GPT-4", name="GPT-4")
agent = Agent.from_object("Agent v1", name="Agent 1")
Computation.new(name="Agent 1 Compute").add_input_cid(
[user_prompt.cid, system_prompt.cid, model_v1.cid, agent.cid]
).add_output_cid([Dataset.from_object("Output1", name="Output 1").cid]).finalize()
service = Service.new("http://localhost:3050")
cfg.get_default_context().register(service)
Important details:
Context.from_uuid(...)takes the UUID for the Governance Studio project where you want this graph tree to be registered.Context.with_parent(gov_ctx).new("My Agent v1")creates a child graph under that Governance Studio project, and the name passed to.new(...)is the label that Governance Studio shows for the child graph.Service.new(...)uses theEQTY_API_KEYenvironment variable when an API key is not passed directly. SetEQTY_API_KEYto an API key created in Governance Studio before running this example.- If you expect to register blobs to a remote service often, pair this pattern with
cfg.set_store_all_blobs(True)as shown inRemote Service Workflow.