vellum_ai 0.3.10 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/requests.rb +2 -2
  3. data/lib/types_export.rb +10 -0
  4. data/lib/vellum_ai/deployments/client.rb +10 -4
  5. data/lib/vellum_ai/document_indexes/client.rb +150 -0
  6. data/lib/vellum_ai/types/array_variable_value_item.rb +13 -0
  7. data/lib/vellum_ai/types/chat_message.rb +9 -4
  8. data/lib/vellum_ai/types/chat_message_request.rb +9 -4
  9. data/lib/vellum_ai/types/execution_array_vellum_value.rb +59 -0
  10. data/lib/vellum_ai/types/execution_chat_history_vellum_value.rb +59 -0
  11. data/lib/vellum_ai/types/execution_error_vellum_value.rb +61 -0
  12. data/lib/vellum_ai/types/execution_function_call_vellum_value.rb +61 -0
  13. data/lib/vellum_ai/types/execution_json_vellum_value.rb +55 -0
  14. data/lib/vellum_ai/types/execution_number_vellum_value.rb +55 -0
  15. data/lib/vellum_ai/types/execution_search_results_vellum_value.rb +59 -0
  16. data/lib/vellum_ai/types/execution_string_vellum_value.rb +55 -0
  17. data/lib/vellum_ai/types/execution_vellum_value.rb +168 -0
  18. data/lib/vellum_ai/types/fulfilled_workflow_node_result_event.rb +19 -5
  19. data/lib/vellum_ai/types/generate_request.rb +2 -2
  20. data/lib/vellum_ai/types/image_variable_value.rb +52 -0
  21. data/lib/vellum_ai/types/initiated_workflow_node_result_event.rb +11 -4
  22. data/lib/vellum_ai/types/prompt_template_block_properties.rb +10 -4
  23. data/lib/vellum_ai/types/prompt_template_block_properties_request.rb +10 -4
  24. data/lib/vellum_ai/types/rejected_workflow_node_result_event.rb +11 -4
  25. data/lib/vellum_ai/types/streaming_workflow_node_result_event.rb +12 -5
  26. data/lib/vellum_ai/types/workflow_execution_event_error_code.rb +1 -0
  27. data/lib/vellum_ai/types/workflow_result_event.rb +15 -4
  28. data/lib/vellum_ai.rb +6 -6
  29. metadata +12 -2
@@ -7,11 +7,12 @@ require "json"
7
7
 
8
8
  module Vellum
9
9
  class PromptTemplateBlockPropertiesRequest
10
- attr_reader :chat_role, :chat_message_unterminated, :template, :template_type, :function_name,
10
+ attr_reader :chat_role, :chat_message_unterminated, :chat_source, :template, :template_type, :function_name,
11
11
  :function_description, :function_parameters, :function_forced, :blocks, :additional_properties
12
12
 
13
13
  # @param chat_role [CHAT_MESSAGE_ROLE]
14
14
  # @param chat_message_unterminated [Boolean]
15
+ # @param chat_source [String]
15
16
  # @param template [String]
16
17
  # @param template_type [VELLUM_VARIABLE_TYPE]
17
18
  # @param function_name [String]
@@ -21,13 +22,15 @@ module Vellum
21
22
  # @param blocks [Array<PromptTemplateBlockRequest>]
22
23
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
24
  # @return [PromptTemplateBlockPropertiesRequest]
24
- def initialize(chat_role: nil, chat_message_unterminated: nil, template: nil, template_type: nil,
25
+ def initialize(chat_role: nil, chat_message_unterminated: nil, chat_source: nil, template: nil, template_type: nil,
25
26
  function_name: nil, function_description: nil, function_parameters: nil, function_forced: nil, blocks: nil, additional_properties: nil)
26
27
  # @type [CHAT_MESSAGE_ROLE]
27
28
  @chat_role = chat_role
28
29
  # @type [Boolean]
29
30
  @chat_message_unterminated = chat_message_unterminated
30
31
  # @type [String]
32
+ @chat_source = chat_source
33
+ # @type [String]
31
34
  @template = template
32
35
  # @type [VELLUM_VARIABLE_TYPE]
33
36
  @template_type = template_type
@@ -54,6 +57,7 @@ module Vellum
54
57
  parsed_json = JSON.parse(json_object)
55
58
  chat_role = CHAT_MESSAGE_ROLE.key(parsed_json["chat_role"]) || parsed_json["chat_role"]
56
59
  chat_message_unterminated = struct.chat_message_unterminated
60
+ chat_source = struct.chat_source
57
61
  template = struct.template
58
62
  template_type = VELLUM_VARIABLE_TYPE.key(parsed_json["template_type"]) || parsed_json["template_type"]
59
63
  function_name = struct.function_name
@@ -64,8 +68,8 @@ module Vellum
64
68
  v = v.to_json
65
69
  PromptTemplateBlockRequest.from_json(json_object: v)
66
70
  end
67
- new(chat_role: chat_role, chat_message_unterminated: chat_message_unterminated, template: template,
68
- template_type: template_type, function_name: function_name, function_description: function_description, function_parameters: function_parameters, function_forced: function_forced, blocks: blocks, additional_properties: struct)
71
+ new(chat_role: chat_role, chat_message_unterminated: chat_message_unterminated, chat_source: chat_source,
72
+ template: template, template_type: template_type, function_name: function_name, function_description: function_description, function_parameters: function_parameters, function_forced: function_forced, blocks: blocks, additional_properties: struct)
69
73
  end
70
74
 
71
75
  # Serialize an instance of PromptTemplateBlockPropertiesRequest to a JSON object
@@ -75,6 +79,7 @@ module Vellum
75
79
  {
76
80
  "chat_role": CHAT_MESSAGE_ROLE[@chat_role] || @chat_role,
77
81
  "chat_message_unterminated": @chat_message_unterminated,
82
+ "chat_source": @chat_source,
78
83
  "template": @template,
79
84
  "template_type": VELLUM_VARIABLE_TYPE[@template_type] || @template_type,
80
85
  "function_name": @function_name,
@@ -92,6 +97,7 @@ module Vellum
92
97
  def self.validate_raw(obj:)
93
98
  obj.chat_role&.is_a?(CHAT_MESSAGE_ROLE) != false || raise("Passed value for field obj.chat_role is not the expected type, validation failed.")
94
99
  obj.chat_message_unterminated&.is_a?(Boolean) != false || raise("Passed value for field obj.chat_message_unterminated is not the expected type, validation failed.")
100
+ obj.chat_source&.is_a?(String) != false || raise("Passed value for field obj.chat_source is not the expected type, validation failed.")
95
101
  obj.template&.is_a?(String) != false || raise("Passed value for field obj.template is not the expected type, validation failed.")
96
102
  obj.template_type&.is_a?(VELLUM_VARIABLE_TYPE) != false || raise("Passed value for field obj.template_type is not the expected type, validation failed.")
97
103
  obj.function_name&.is_a?(String) != false || raise("Passed value for field obj.function_name is not the expected type, validation failed.")
@@ -8,17 +8,19 @@ require "json"
8
8
  module Vellum
9
9
  # An event that indicates that the node has rejected its execution.
10
10
  class RejectedWorkflowNodeResultEvent
11
- attr_reader :id, :node_id, :node_result_id, :ts, :data, :error, :additional_properties
11
+ attr_reader :id, :node_id, :node_result_id, :ts, :data, :source_execution_id, :error, :additional_properties
12
12
 
13
13
  # @param id [String]
14
14
  # @param node_id [String]
15
15
  # @param node_result_id [String]
16
16
  # @param ts [DateTime]
17
17
  # @param data [WorkflowNodeResultData]
18
+ # @param source_execution_id [String]
18
19
  # @param error [WorkflowEventError]
19
20
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
20
21
  # @return [RejectedWorkflowNodeResultEvent]
21
- def initialize(id:, node_id:, node_result_id:, error:, ts: nil, data: nil, additional_properties: nil)
22
+ def initialize(id:, node_id:, node_result_id:, error:, ts: nil, data: nil, source_execution_id: nil,
23
+ additional_properties: nil)
22
24
  # @type [String]
23
25
  @id = id
24
26
  # @type [String]
@@ -29,6 +31,8 @@ module Vellum
29
31
  @ts = ts
30
32
  # @type [WorkflowNodeResultData]
31
33
  @data = data
34
+ # @type [String]
35
+ @source_execution_id = source_execution_id
32
36
  # @type [WorkflowEventError]
33
37
  @error = error
34
38
  # @type [OpenStruct] Additional properties unmapped to the current class definition
@@ -52,14 +56,15 @@ module Vellum
52
56
  data = parsed_json["data"].to_json
53
57
  data = WorkflowNodeResultData.from_json(json_object: data)
54
58
  end
59
+ source_execution_id = struct.source_execution_id
55
60
  if parsed_json["error"].nil?
56
61
  error = nil
57
62
  else
58
63
  error = parsed_json["error"].to_json
59
64
  error = WorkflowEventError.from_json(json_object: error)
60
65
  end
61
- new(id: id, node_id: node_id, node_result_id: node_result_id, ts: ts, data: data, error: error,
62
- additional_properties: struct)
66
+ new(id: id, node_id: node_id, node_result_id: node_result_id, ts: ts, data: data,
67
+ source_execution_id: source_execution_id, error: error, additional_properties: struct)
63
68
  end
64
69
 
65
70
  # Serialize an instance of RejectedWorkflowNodeResultEvent to a JSON object
@@ -72,6 +77,7 @@ module Vellum
72
77
  "node_result_id": @node_result_id,
73
78
  "ts": @ts,
74
79
  "data": @data,
80
+ "source_execution_id": @source_execution_id,
75
81
  "error": @error
76
82
  }.to_json
77
83
  end
@@ -86,6 +92,7 @@ module Vellum
86
92
  obj.node_result_id.is_a?(String) != false || raise("Passed value for field obj.node_result_id is not the expected type, validation failed.")
87
93
  obj.ts&.is_a?(DateTime) != false || raise("Passed value for field obj.ts is not the expected type, validation failed.")
88
94
  obj.data.nil? || WorkflowNodeResultData.validate_raw(obj: obj.data)
95
+ obj.source_execution_id&.is_a?(String) != false || raise("Passed value for field obj.source_execution_id is not the expected type, validation failed.")
89
96
  WorkflowEventError.validate_raw(obj: obj.error)
90
97
  end
91
98
  end
@@ -8,19 +8,21 @@ require "json"
8
8
  module Vellum
9
9
  # An event that indicates that the node has execution is in progress.
10
10
  class StreamingWorkflowNodeResultEvent
11
- attr_reader :id, :node_id, :node_result_id, :ts, :data, :output, :output_index, :additional_properties
11
+ attr_reader :id, :node_id, :node_result_id, :ts, :data, :source_execution_id, :output, :output_index,
12
+ :additional_properties
12
13
 
13
14
  # @param id [String]
14
15
  # @param node_id [String]
15
16
  # @param node_result_id [String]
16
17
  # @param ts [DateTime]
17
18
  # @param data [WorkflowNodeResultData]
19
+ # @param source_execution_id [String]
18
20
  # @param output [NodeOutputCompiledValue]
19
21
  # @param output_index [Integer]
20
22
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
21
23
  # @return [StreamingWorkflowNodeResultEvent]
22
- def initialize(id:, node_id:, node_result_id:, ts: nil, data: nil, output: nil, output_index: nil,
23
- additional_properties: nil)
24
+ def initialize(id:, node_id:, node_result_id:, ts: nil, data: nil, source_execution_id: nil, output: nil,
25
+ output_index: nil, additional_properties: nil)
24
26
  # @type [String]
25
27
  @id = id
26
28
  # @type [String]
@@ -31,6 +33,8 @@ module Vellum
31
33
  @ts = ts
32
34
  # @type [WorkflowNodeResultData]
33
35
  @data = data
36
+ # @type [String]
37
+ @source_execution_id = source_execution_id
34
38
  # @type [NodeOutputCompiledValue]
35
39
  @output = output
36
40
  # @type [Integer]
@@ -56,6 +60,7 @@ module Vellum
56
60
  data = parsed_json["data"].to_json
57
61
  data = WorkflowNodeResultData.from_json(json_object: data)
58
62
  end
63
+ source_execution_id = struct.source_execution_id
59
64
  if parsed_json["output"].nil?
60
65
  output = nil
61
66
  else
@@ -63,8 +68,8 @@ module Vellum
63
68
  output = NodeOutputCompiledValue.from_json(json_object: output)
64
69
  end
65
70
  output_index = struct.output_index
66
- new(id: id, node_id: node_id, node_result_id: node_result_id, ts: ts, data: data, output: output,
67
- output_index: output_index, additional_properties: struct)
71
+ new(id: id, node_id: node_id, node_result_id: node_result_id, ts: ts, data: data,
72
+ source_execution_id: source_execution_id, output: output, output_index: output_index, additional_properties: struct)
68
73
  end
69
74
 
70
75
  # Serialize an instance of StreamingWorkflowNodeResultEvent to a JSON object
@@ -77,6 +82,7 @@ module Vellum
77
82
  "node_result_id": @node_result_id,
78
83
  "ts": @ts,
79
84
  "data": @data,
85
+ "source_execution_id": @source_execution_id,
80
86
  "output": @output,
81
87
  "output_index": @output_index
82
88
  }.to_json
@@ -92,6 +98,7 @@ module Vellum
92
98
  obj.node_result_id.is_a?(String) != false || raise("Passed value for field obj.node_result_id is not the expected type, validation failed.")
93
99
  obj.ts&.is_a?(DateTime) != false || raise("Passed value for field obj.ts is not the expected type, validation failed.")
94
100
  obj.data.nil? || WorkflowNodeResultData.validate_raw(obj: obj.data)
101
+ obj.source_execution_id&.is_a?(String) != false || raise("Passed value for field obj.source_execution_id is not the expected type, validation failed.")
95
102
  obj.output.nil? || NodeOutputCompiledValue.validate_raw(obj: obj.output)
96
103
  obj.output_index&.is_a?(Integer) != false || raise("Passed value for field obj.output_index is not the expected type, validation failed.")
97
104
  end
@@ -4,6 +4,7 @@ module Vellum
4
4
  # @type [WORKFLOW_EXECUTION_EVENT_ERROR_CODE]
5
5
  WORKFLOW_EXECUTION_EVENT_ERROR_CODE = {
6
6
  workflow_initialization: "WORKFLOW_INITIALIZATION",
7
+ workflow_cancelled: "WORKFLOW_CANCELLED",
7
8
  node_execution_count_limit_reached: "NODE_EXECUTION_COUNT_LIMIT_REACHED",
8
9
  internal_server_error: "INTERNAL_SERVER_ERROR",
9
10
  node_execution: "NODE_EXECUTION",
@@ -5,11 +5,12 @@ require "date"
5
5
  require_relative "workflow_result_event_output_data"
6
6
  require_relative "workflow_event_error"
7
7
  require_relative "workflow_output"
8
+ require_relative "execution_vellum_value"
8
9
  require "json"
9
10
 
10
11
  module Vellum
11
12
  class WorkflowResultEvent
12
- attr_reader :id, :state, :ts, :output, :error, :outputs, :additional_properties
13
+ attr_reader :id, :state, :ts, :output, :error, :outputs, :inputs, :additional_properties
13
14
 
14
15
  # @param id [String]
15
16
  # @param state [WORKFLOW_NODE_RESULT_EVENT_STATE]
@@ -17,9 +18,10 @@ module Vellum
17
18
  # @param output [WorkflowResultEventOutputData]
18
19
  # @param error [WorkflowEventError]
19
20
  # @param outputs [Array<WorkflowOutput>]
21
+ # @param inputs [Array<ExecutionVellumValue>]
20
22
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
21
23
  # @return [WorkflowResultEvent]
22
- def initialize(id:, state:, ts:, output: nil, error: nil, outputs: nil, additional_properties: nil)
24
+ def initialize(id:, state:, ts:, output: nil, error: nil, outputs: nil, inputs: nil, additional_properties: nil)
23
25
  # @type [String]
24
26
  @id = id
25
27
  # @type [WORKFLOW_NODE_RESULT_EVENT_STATE]
@@ -32,6 +34,8 @@ module Vellum
32
34
  @error = error
33
35
  # @type [Array<WorkflowOutput>]
34
36
  @outputs = outputs
37
+ # @type [Array<ExecutionVellumValue>]
38
+ @inputs = inputs
35
39
  # @type [OpenStruct] Additional properties unmapped to the current class definition
36
40
  @additional_properties = additional_properties
37
41
  end
@@ -62,7 +66,12 @@ module Vellum
62
66
  v = v.to_json
63
67
  WorkflowOutput.from_json(json_object: v)
64
68
  end
65
- new(id: id, state: state, ts: ts, output: output, error: error, outputs: outputs, additional_properties: struct)
69
+ inputs = parsed_json["inputs"].map do |v|
70
+ v = v.to_json
71
+ ExecutionVellumValue.from_json(json_object: v)
72
+ end
73
+ new(id: id, state: state, ts: ts, output: output, error: error, outputs: outputs, inputs: inputs,
74
+ additional_properties: struct)
66
75
  end
67
76
 
68
77
  # Serialize an instance of WorkflowResultEvent to a JSON object
@@ -75,7 +84,8 @@ module Vellum
75
84
  "ts": @ts,
76
85
  "output": @output,
77
86
  "error": @error,
78
- "outputs": @outputs
87
+ "outputs": @outputs,
88
+ "inputs": @inputs
79
89
  }.to_json
80
90
  end
81
91
 
@@ -90,6 +100,7 @@ module Vellum
90
100
  obj.output.nil? || WorkflowResultEventOutputData.validate_raw(obj: obj.output)
91
101
  obj.error.nil? || WorkflowEventError.validate_raw(obj: obj.error)
92
102
  obj.outputs&.is_a?(Array) != false || raise("Passed value for field obj.outputs is not the expected type, validation failed.")
103
+ obj.inputs&.is_a?(Array) != false || raise("Passed value for field obj.inputs is not the expected type, validation failed.")
93
104
  end
94
105
  end
95
106
  end
data/lib/vellum_ai.rb CHANGED
@@ -96,11 +96,11 @@ module Vellum
96
96
 
97
97
  # Executes a deployed Workflow and returns its outputs.
98
98
  #
99
+ # @param inputs [Array<Hash>] The list of inputs defined in the Workflow's Deployment with their corresponding values.Request of type Array<WorkflowRequestInputRequest>, as a Hash
99
100
  # @param workflow_deployment_id [String] The ID of the Workflow Deployment. Must provide either this or workflow_deployment_name.
100
101
  # @param workflow_deployment_name [String] The name of the Workflow Deployment. Must provide either this or workflow_deployment_id.
101
102
  # @param release_tag [String] Optionally specify a release tag if you want to pin to a specific release of the Workflow Deployment
102
- # @param inputs [Array<Hash>] The list of inputs defined in the Workflow's Deployment with their corresponding values.Request of type Array<WorkflowRequestInputRequest>, as a Hash
103
- # @param external_id [String] Optionally include a unique identifier for monitoring purposes. Must be unique for a given workflow deployment.
103
+ # @param external_id [String] Optionally include a unique identifier for tracking purposes. Must be unique for a given workflow deployment.
104
104
  # @param request_options [RequestOptions]
105
105
  # @return [ExecuteWorkflowResponse]
106
106
  def execute_workflow(inputs:, workflow_deployment_id: nil, workflow_deployment_name: nil, release_tag: nil,
@@ -111,10 +111,10 @@ module Vellum
111
111
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
112
112
  req.body = {
113
113
  **(request_options&.additional_body_parameters || {}),
114
+ inputs: inputs,
114
115
  workflow_deployment_id: workflow_deployment_id,
115
116
  workflow_deployment_name: workflow_deployment_name,
116
117
  release_tag: release_tag,
117
- inputs: inputs,
118
118
  external_id: external_id
119
119
  }.compact
120
120
  req.url "#{@request_client.default_environment[:Predict]}/v1/execute-workflow"
@@ -318,11 +318,11 @@ module Vellum
318
318
 
319
319
  # Executes a deployed Workflow and returns its outputs.
320
320
  #
321
+ # @param inputs [Array<Hash>] The list of inputs defined in the Workflow's Deployment with their corresponding values.Request of type Array<WorkflowRequestInputRequest>, as a Hash
321
322
  # @param workflow_deployment_id [String] The ID of the Workflow Deployment. Must provide either this or workflow_deployment_name.
322
323
  # @param workflow_deployment_name [String] The name of the Workflow Deployment. Must provide either this or workflow_deployment_id.
323
324
  # @param release_tag [String] Optionally specify a release tag if you want to pin to a specific release of the Workflow Deployment
324
- # @param inputs [Array<Hash>] The list of inputs defined in the Workflow's Deployment with their corresponding values.Request of type Array<WorkflowRequestInputRequest>, as a Hash
325
- # @param external_id [String] Optionally include a unique identifier for monitoring purposes. Must be unique for a given workflow deployment.
325
+ # @param external_id [String] Optionally include a unique identifier for tracking purposes. Must be unique for a given workflow deployment.
326
326
  # @param request_options [RequestOptions]
327
327
  # @return [ExecuteWorkflowResponse]
328
328
  def execute_workflow(inputs:, workflow_deployment_id: nil, workflow_deployment_name: nil, release_tag: nil,
@@ -333,10 +333,10 @@ module Vellum
333
333
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
334
334
  req.body = {
335
335
  **(request_options&.additional_body_parameters || {}),
336
+ inputs: inputs,
336
337
  workflow_deployment_id: workflow_deployment_id,
337
338
  workflow_deployment_name: workflow_deployment_name,
338
339
  release_tag: release_tag,
339
- inputs: inputs,
340
340
  external_id: external_id
341
341
  }.compact
342
342
  req.url "#{@async_request_client.default_environment[:Predict]}/v1/execute-workflow"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vellum_ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vellum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-07 00:00:00.000000000 Z
11
+ date: 2024-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http-faraday
@@ -148,6 +148,15 @@ files:
148
148
  - lib/vellum_ai/types/execute_workflow_response.rb
149
149
  - lib/vellum_ai/types/execute_workflow_stream_error_response.rb
150
150
  - lib/vellum_ai/types/execute_workflow_workflow_result_event.rb
151
+ - lib/vellum_ai/types/execution_array_vellum_value.rb
152
+ - lib/vellum_ai/types/execution_chat_history_vellum_value.rb
153
+ - lib/vellum_ai/types/execution_error_vellum_value.rb
154
+ - lib/vellum_ai/types/execution_function_call_vellum_value.rb
155
+ - lib/vellum_ai/types/execution_json_vellum_value.rb
156
+ - lib/vellum_ai/types/execution_number_vellum_value.rb
157
+ - lib/vellum_ai/types/execution_search_results_vellum_value.rb
158
+ - lib/vellum_ai/types/execution_string_vellum_value.rb
159
+ - lib/vellum_ai/types/execution_vellum_value.rb
151
160
  - lib/vellum_ai/types/finish_reason_enum.rb
152
161
  - lib/vellum_ai/types/fulfilled_enum.rb
153
162
  - lib/vellum_ai/types/fulfilled_execute_prompt_event.rb
@@ -176,6 +185,7 @@ files:
176
185
  - lib/vellum_ai/types/image_chat_message_content.rb
177
186
  - lib/vellum_ai/types/image_chat_message_content_request.rb
178
187
  - lib/vellum_ai/types/image_enum.rb
188
+ - lib/vellum_ai/types/image_variable_value.rb
179
189
  - lib/vellum_ai/types/indexing_state_enum.rb
180
190
  - lib/vellum_ai/types/initiated_enum.rb
181
191
  - lib/vellum_ai/types/initiated_execute_prompt_event.rb