Class: Zavudev::Resources::Senders::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/senders/agent.rb,
lib/zavudev/resources/senders/agent/flows.rb,
lib/zavudev/resources/senders/agent/tools.rb,
lib/zavudev/resources/senders/agent/executions.rb,
lib/zavudev/resources/senders/agent/knowledge_bases.rb,
lib/zavudev/resources/senders/agent/knowledge_bases/documents.rb,
sig/zavudev/resources/senders/agent.rbs,
sig/zavudev/resources/senders/agent/flows.rbs,
sig/zavudev/resources/senders/agent/tools.rbs,
sig/zavudev/resources/senders/agent/executions.rbs,
sig/zavudev/resources/senders/agent/knowledge_bases.rbs,
sig/zavudev/resources/senders/agent/knowledge_bases/documents.rbs

Defined Under Namespace

Classes: Executions, Flows, KnowledgeBases, Tools

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Agent

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 Agent.

Parameters:



185
186
187
188
189
190
191
# File 'lib/zavudev/resources/senders/agent.rb', line 185

def initialize(client:)
  @client = client
  @executions = Zavudev::Resources::Senders::Agent::Executions.new(client: client)
  @flows = Zavudev::Resources::Senders::Agent::Flows.new(client: client)
  @tools = Zavudev::Resources::Senders::Agent::Tools.new(client: client)
  @knowledge_bases = Zavudev::Resources::Senders::Agent::KnowledgeBases.new(client: client)
end

Instance Attribute Details

#executionsZavudev::Resources::Senders::Agent::Executions (readonly)



8
9
10
# File 'lib/zavudev/resources/senders/agent.rb', line 8

def executions
  @executions
end

#flowsZavudev::Resources::Senders::Agent::Flows (readonly)



11
12
13
# File 'lib/zavudev/resources/senders/agent.rb', line 11

def flows
  @flows
end

#knowledge_basesZavudev::Resources::Senders::Agent::KnowledgeBases (readonly)



17
18
19
# File 'lib/zavudev/resources/senders/agent.rb', line 17

def knowledge_bases
  @knowledge_bases
end

#toolsZavudev::Resources::Senders::Agent::Tools (readonly)



14
15
16
# File 'lib/zavudev/resources/senders/agent.rb', line 14

def tools
  @tools
end

Instance Method Details

#create(sender_id, model:, name:, provider:, system_prompt:, api_key: nil, 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::Senders::AgentResponse

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

Create an AI agent for a sender. Each sender can have at most one agent.

Parameters:

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

    LLM provider for the AI agent.

  • system_prompt (String)
  • api_key (String)

    API key for the LLM provider. Required unless provider is 'zavu'.

  • 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::Senders::AgentCreateParams::Voice)

    Voice Agent configuration. Enable this to let the agent answer and place phone c

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

Returns:

See Also:



57
58
59
60
61
62
63
64
65
66
# File 'lib/zavudev/resources/senders/agent.rb', line 57

def create(sender_id, params)
  parsed, options = Zavudev::Senders::AgentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/senders/%1$s/agent", sender_id],
    body: parsed,
    model: Zavudev::Senders::AgentResponse,
    options: options
  )
end

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

Delete an AI agent.

Parameters:

Returns:

  • (nil)

See Also:



148
149
150
151
152
153
154
155
# File 'lib/zavudev/resources/senders/agent.rb', line 148

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

#retrieve(sender_id, request_options: {}) ⇒ Zavudev::Models::Senders::AgentResponse

Get the AI agent configuration for a sender.

Parameters:

Returns:

See Also:



78
79
80
81
82
83
84
85
# File 'lib/zavudev/resources/senders/agent.rb', line 78

def retrieve(sender_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/senders/%1$s/agent", sender_id],
    model: Zavudev::Senders::AgentResponse,
    options: params[:request_options]
  )
end

#stats(sender_id, request_options: {}) ⇒ Zavudev::Models::Senders::AgentStats

Get statistics for an AI agent including invocations, tokens, and costs.

Covers the messaging channels only. Voice calls are not counted here: a call is a multi-turn conversation rather than one inbound message and one reply, so it is recorded as a call, not an execution. An agent that only answers phone calls reports zeros on every field. Use GET /v1/calls for voice activity, duration, and cost.

Parameters:

Returns:

See Also:



173
174
175
176
177
178
179
180
# File 'lib/zavudev/resources/senders/agent.rb', line 173

def stats(sender_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/senders/%1$s/agent/stats", sender_id],
    model: Zavudev::Senders::AgentStats,
    options: params[:request_options]
  )
end

#update(sender_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::Senders::AgentResponse

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

Update an AI agent's configuration.

Parameters:

  • sender_id (String)
  • 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::Senders::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:



127
128
129
130
131
132
133
134
135
136
# File 'lib/zavudev/resources/senders/agent.rb', line 127

def update(sender_id, params = {})
  parsed, options = Zavudev::Senders::AgentUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["v1/senders/%1$s/agent", sender_id],
    body: parsed,
    model: Zavudev::Senders::AgentResponse,
    options: options
  )
end