Class: ZnyxSdk::Client
- Inherits:
-
Object
- Object
- ZnyxSdk::Client
- Defined in:
- lib/znyx_sdk/client.rb
Overview
Official Ruby SDK for the ZNYX Runtime guardrails API.
Instance Method Summary collapse
-
#evaluate_input(text:, tenant_id: "default", app_id: "default", **kwargs) ⇒ EvaluationResponse
Evaluates a user prompt before sending it to the LLM.
-
#evaluate_output(text:, tenant_id: "default", app_id: "default", **kwargs) ⇒ Object
Evaluates an LLM response before returning it to the user.
-
#evaluate_tool(tool_name:, tool_args:, tenant_id: "default", app_id: "default", **kwargs) ⇒ Object
Evaluates a tool call before executing it.
-
#initialize(base_url, api_key: nil, timeout: 10) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(base_url, api_key: nil, timeout: 10) ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/znyx_sdk/client.rb', line 23 def initialize(base_url, api_key: nil, timeout: 10) @uri = URI.parse(base_url.chomp("/")) @api_key = api_key @timeout = timeout # Anonymous, opt-out install telemetry (ZNYX_TELEMETRY=false to disable). begin Telemetry.maybe_send_install_ping rescue StandardError # telemetry must never break client construction end end |
Instance Method Details
#evaluate_input(text:, tenant_id: "default", app_id: "default", **kwargs) ⇒ EvaluationResponse
Evaluates a user prompt before sending it to the LLM.
43 44 45 |
# File 'lib/znyx_sdk/client.rb', line 43 def evaluate_input(text:, tenant_id: "default", app_id: "default", **kwargs) post("/v1/evaluate/input", build_payload(text: text, tenant_id: tenant_id, app_id: app_id, **kwargs)) end |
#evaluate_output(text:, tenant_id: "default", app_id: "default", **kwargs) ⇒ Object
Evaluates an LLM response before returning it to the user.
48 49 50 |
# File 'lib/znyx_sdk/client.rb', line 48 def evaluate_output(text:, tenant_id: "default", app_id: "default", **kwargs) post("/v1/evaluate/output", build_payload(text: text, tenant_id: tenant_id, app_id: app_id, **kwargs)) end |
#evaluate_tool(tool_name:, tool_args:, tenant_id: "default", app_id: "default", **kwargs) ⇒ Object
Evaluates a tool call before executing it.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/znyx_sdk/client.rb', line 56 def evaluate_tool(tool_name:, tool_args:, tenant_id: "default", app_id: "default", **kwargs) payload = { request_id: new_request_id, tenant_id: tenant_id, app_id: app_id, agent_id: kwargs.delete(:agent_id) || "default", env: kwargs.delete(:env) || "prod", tool_name: tool_name, tool_args: tool_args, }.merge(kwargs.compact) post("/v1/evaluate/tool", payload) end |