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

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:



169
170
171
172
173
174
175
# File 'lib/zavudev/resources/senders/agent.rb', line 169

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, request_options: {}) ⇒ Zavudev::Models::Senders::AgentResponse

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>)
  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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

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:



138
139
140
141
142
143
144
145
# File 'lib/zavudev/resources/senders/agent.rb', line 138

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:



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

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.

Parameters:

Returns:

See Also:



157
158
159
160
161
162
163
164
# File 'lib/zavudev/resources/senders/agent.rb', line 157

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, request_options: {}) ⇒ Zavudev::Models::Senders::AgentResponse

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>)
  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



117
118
119
120
121
122
123
124
125
126
# File 'lib/zavudev/resources/senders/agent.rb', line 117

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