Class: Zavudev::Resources::Agents

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/agents.rb,
lib/zavudev/resources/agents/senders.rb,
sig/zavudev/resources/agents.rbs,
sig/zavudev/resources/agents/senders.rbs

Defined Under Namespace

Classes: Senders

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Agents

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Agents.

Parameters:



247
248
249
250
# File 'lib/zavudev/resources/agents.rb', line 247

def initialize(client:)
  @client = client
  @senders = Zavudev::Resources::Agents::Senders.new(client: client)
end

Instance Attribute Details

#senders ⇒ Zavudev::Resources::Agents::Senders (readonly)



7
8
9
# File 'lib/zavudev/resources/agents.rb', line 7

def senders
  @senders
end

Instance Method Details

#create(model:, name:, provider:, system_prompt:, context_window_messages: nil, include_contact_metadata: nil, max_tokens: nil, temperature: nil, trigger_on_channels: nil, trigger_on_message_types: nil, voice: nil, request_options: {}) ⇒ Zavudev::Models::AgentCreateResponse

Some parameter documentations has been truncated, see Models::AgentCreateParams for more details.

Create an agent without a sender. It is created disabled; connect a sender and enable it when you are ready for it to answer.

Sub-resources. An agent's tools, flows and knowledge bases are reachable at /v1/agents/{agentId}/tools, /v1/agents/{agentId}/flows and /v1/agents/{agentId}/knowledge-bases, mirroring the sender-scoped routes documented under /v1/senders/{senderId}/agent/... exactly. Use the agent-scoped form while the agent has no sender: the sender-scoped one cannot address it.

Parameters:

  • model (String)
  • name (String)
  • provider (Symbol, Zavudev::Models::Senders::AgentProvider) —

    LLM provider for the AI agent.

  • system_prompt (String)
  • context_window_messages (Integer)
  • include_contact_metadata (Boolean)
  • max_tokens (Integer)
  • temperature (Float)
  • trigger_on_channels (Array<String>)
  • trigger_on_message_types (Array<String>)
  • voice (Zavudev::Models::AgentCreateParams::Voice) —

    Voice Agent configuration on a sender's AI agent. Controls how the agent behaves

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



51
52
53
54
55
56
57
58
59
60
# File 'lib/zavudev/resources/agents.rb', line 51

def create(params)
  parsed, options = Zavudev::AgentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/agents",
    body: parsed,
    model: Zavudev::Models::AgentCreateResponse,
    options: options
  )
end

#delete(agent_id, request_options: {}) ⇒ nil

Delete an agent

Parameters:

Returns:

  • (nil)

See Also:



170
171
172
173
174
175
176
177
# File 'lib/zavudev/resources/agents.rb', line 170

def delete(agent_id, params = {})
  @client.request(
    method: :delete,
    path: ["v1/agents/%1$s", agent_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(cursor: nil, limit: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::Senders::SendersAgent>

Every agent in the project, newest first — including agents that are not connected to any sender yet, which the sender-scoped routes cannot reach. Each item carries senderIds, the senders the agent answers on.

Parameters:

Returns:

See Also:



146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/zavudev/resources/agents.rb', line 146

def list(params = {})
  parsed, options = Zavudev::AgentListParams.dump_request(params)
  query = Zavudev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/agents",
    query: query,
    page: Zavudev::Internal::Cursor,
    model: Zavudev::Senders::SendersAgent,
    options: options
  )
end

#list_voices(language: nil, request_options: {}) ⇒ Zavudev::Models::AgentListVoicesResponse

The voices an agent can speak with, for voice.ttsVoiceId. Filter by language to get the ones that speak it; a voice can still be used with language: auto, where the agent follows the caller and keeps the chosen voice.

Parameters:

  • language (String) —

    BCP-47 tag (en, es, pt-BR). Omit, or pass auto, for every voice.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



192
193
194
195
196
197
198
199
200
201
202
# File 'lib/zavudev/resources/agents.rb', line 192

def list_voices(params = {})
  parsed, options = Zavudev::AgentListVoicesParams.dump_request(params)
  query = Zavudev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/agents/voices",
    query: query,
    model: Zavudev::Models::AgentListVoicesResponse,
    options: options
  )
end

#retrieve(agent_id, request_options: {}) ⇒ Zavudev::Models::AgentRetrieveResponse

Get an agent

Parameters:

Returns:

See Also:



73
74
75
76
77
78
79
80
# File 'lib/zavudev/resources/agents.rb', line 73

def retrieve(agent_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/agents/%1$s", agent_id],
    model: Zavudev::Models::AgentRetrieveResponse,
    options: params[:request_options]
  )
end

#test_(agent_id, message:, execute_tools: nil, history: nil, use_knowledge_base: nil, request_options: {}) ⇒ Zavudev::Models::AgentTestResponse

Some parameter documentations has been truncated, see Models::AgentTestParams for more details.

Run the agent's prompt, model and knowledge base against a message and return the reply instead of delivering it. Writes nothing and charges nothing, so it is safe to call repeatedly while iterating on a prompt.

Note that a dry run never executes tools — running them would cause real side effects. Live conversations on every channel do call them. When the agent has enabled tools, that gap is reported in warnings rather than silently producing an answer that looks like a tool call happened.

Parameters:

  • agent_id (String) —

    Agent ID.

  • message (String) —

    What to say to the agent.

  • execute_tools (Boolean) —

    Run the tools the agent calls instead of reporting the choice and stopping.

  • history (Array<Zavudev::Models::AgentTestParams::History>) —

    Prior turns, oldest first, to exercise multi-turn behaviour without persisting a

  • use_knowledge_base (Boolean) —

    Set false to skip retrieval and isolate prompt behaviour from the knowledge base

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



233
234
235
236
237
238
239
240
241
242
# File 'lib/zavudev/resources/agents.rb', line 233

def test_(agent_id, params)
  parsed, options = Zavudev::AgentTestParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/agents/%1$s/test", agent_id],
    body: parsed,
    model: Zavudev::Models::AgentTestResponse,
    options: options
  )
end

#update(agent_id, api_key: nil, context_window_messages: nil, enabled: nil, include_contact_metadata: nil, max_tokens: nil, model: nil, name: nil, provider: nil, system_prompt: nil, temperature: nil, trigger_on_channels: nil, trigger_on_message_types: nil, voice: nil, request_options: {}) ⇒ Zavudev::Models::AgentUpdateResponse

Some parameter documentations has been truncated, see Models::AgentUpdateParams for more details.

Update an agent

Parameters:

  • agent_id (String) —

    Agent ID.

  • api_key (String)
  • context_window_messages (Integer)
  • enabled (Boolean)
  • include_contact_metadata (Boolean)
  • max_tokens (Integer, nil)
  • model (String)
  • name (String)
  • provider (Symbol, Zavudev::Models::Senders::AgentProvider) —

    LLM provider for the AI agent.

  • system_prompt (String)
  • temperature (Float, nil)
  • trigger_on_channels (Array<String>)
  • trigger_on_message_types (Array<String>)
  • voice (Zavudev::Models::AgentUpdateParams::Voice) —

    Voice Agent configuration. Patch this object to enable voice, change the greetin

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



122
123
124
125
126
127
128
129
130
131
# File 'lib/zavudev/resources/agents.rb', line 122

def update(agent_id, params = {})
  parsed, options = Zavudev::AgentUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/agents/%1$s", agent_id],
    body: parsed,
    model: Zavudev::Models::AgentUpdateResponse,
    options: options
  )
end