vellum_ai 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +7 -0
  2. data/lib/core/file_utilities.rb +26 -0
  3. data/lib/environment.rb +11 -0
  4. data/lib/gemconfig.rb +14 -0
  5. data/lib/requests.rb +88 -0
  6. data/lib/types_export.rb +255 -0
  7. data/lib/vellum_ai/deployments/client.rb +157 -0
  8. data/lib/vellum_ai/deployments/types/deployments_list_request_status.rb +8 -0
  9. data/lib/vellum_ai/document_indexes/client.rb +135 -0
  10. data/lib/vellum_ai/documents/client.rb +245 -0
  11. data/lib/vellum_ai/model_versions/client.rb +61 -0
  12. data/lib/vellum_ai/registered_prompts/client.rb +154 -0
  13. data/lib/vellum_ai/sandboxes/client.rb +132 -0
  14. data/lib/vellum_ai/test_suites/client.rb +130 -0
  15. data/lib/vellum_ai/types/api_node_result.rb +52 -0
  16. data/lib/vellum_ai/types/api_node_result_data.rb +80 -0
  17. data/lib/vellum_ai/types/array_chat_message_content.rb +50 -0
  18. data/lib/vellum_ai/types/array_chat_message_content_item.rb +103 -0
  19. data/lib/vellum_ai/types/array_chat_message_content_item_request.rb +103 -0
  20. data/lib/vellum_ai/types/array_chat_message_content_request.rb +50 -0
  21. data/lib/vellum_ai/types/block_type_enum.rb +11 -0
  22. data/lib/vellum_ai/types/chat_history_enum.rb +5 -0
  23. data/lib/vellum_ai/types/chat_history_input_request.rb +55 -0
  24. data/lib/vellum_ai/types/chat_message.rb +62 -0
  25. data/lib/vellum_ai/types/chat_message_content.rb +116 -0
  26. data/lib/vellum_ai/types/chat_message_content_request.rb +116 -0
  27. data/lib/vellum_ai/types/chat_message_request.rb +62 -0
  28. data/lib/vellum_ai/types/chat_message_role.rb +6 -0
  29. data/lib/vellum_ai/types/code_execution_node_chat_history_result.rb +54 -0
  30. data/lib/vellum_ai/types/code_execution_node_error_result.rb +56 -0
  31. data/lib/vellum_ai/types/code_execution_node_json_result.rb +50 -0
  32. data/lib/vellum_ai/types/code_execution_node_number_result.rb +50 -0
  33. data/lib/vellum_ai/types/code_execution_node_result.rb +52 -0
  34. data/lib/vellum_ai/types/code_execution_node_result_data.rb +51 -0
  35. data/lib/vellum_ai/types/code_execution_node_result_output.rb +142 -0
  36. data/lib/vellum_ai/types/code_execution_node_search_results_result.rb +54 -0
  37. data/lib/vellum_ai/types/code_execution_node_string_result.rb +50 -0
  38. data/lib/vellum_ai/types/conditional_node_result.rb +52 -0
  39. data/lib/vellum_ai/types/conditional_node_result_data.rb +45 -0
  40. data/lib/vellum_ai/types/deployment_provider_payload_response.rb +45 -0
  41. data/lib/vellum_ai/types/deployment_read.rb +115 -0
  42. data/lib/vellum_ai/types/document_document_to_document_index.rb +70 -0
  43. data/lib/vellum_ai/types/document_index_read.rb +98 -0
  44. data/lib/vellum_ai/types/document_read.rb +121 -0
  45. data/lib/vellum_ai/types/document_status.rb +5 -0
  46. data/lib/vellum_ai/types/enriched_normalized_completion.rb +118 -0
  47. data/lib/vellum_ai/types/entity_status.rb +6 -0
  48. data/lib/vellum_ai/types/environment_enum.rb +6 -0
  49. data/lib/vellum_ai/types/error_enum.rb +5 -0
  50. data/lib/vellum_ai/types/error_variable_value.rb +51 -0
  51. data/lib/vellum_ai/types/execute_prompt_api_error_response.rb +45 -0
  52. data/lib/vellum_ai/types/execute_prompt_event.rb +116 -0
  53. data/lib/vellum_ai/types/execute_prompt_response.rb +90 -0
  54. data/lib/vellum_ai/types/execute_workflow_error_response.rb +45 -0
  55. data/lib/vellum_ai/types/execute_workflow_response.rb +67 -0
  56. data/lib/vellum_ai/types/execute_workflow_stream_error_response.rb +45 -0
  57. data/lib/vellum_ai/types/execute_workflow_workflow_result_event.rb +90 -0
  58. data/lib/vellum_ai/types/finish_reason_enum.rb +6 -0
  59. data/lib/vellum_ai/types/fulfilled_enum.rb +5 -0
  60. data/lib/vellum_ai/types/fulfilled_execute_prompt_event.rb +66 -0
  61. data/lib/vellum_ai/types/fulfilled_execute_prompt_response.rb +71 -0
  62. data/lib/vellum_ai/types/fulfilled_execute_workflow_workflow_result_event.rb +61 -0
  63. data/lib/vellum_ai/types/fulfilled_function_call.rb +56 -0
  64. data/lib/vellum_ai/types/fulfilled_prompt_execution_meta.rb +52 -0
  65. data/lib/vellum_ai/types/fulfilled_workflow_node_result_event.rb +90 -0
  66. data/lib/vellum_ai/types/function_call.rb +90 -0
  67. data/lib/vellum_ai/types/function_call_chat_message_content.rb +52 -0
  68. data/lib/vellum_ai/types/function_call_chat_message_content_request.rb +52 -0
  69. data/lib/vellum_ai/types/function_call_chat_message_content_value.rb +56 -0
  70. data/lib/vellum_ai/types/function_call_chat_message_content_value_request.rb +56 -0
  71. data/lib/vellum_ai/types/function_call_enum.rb +5 -0
  72. data/lib/vellum_ai/types/function_call_variable_value.rb +51 -0
  73. data/lib/vellum_ai/types/generate_error_response.rb +45 -0
  74. data/lib/vellum_ai/types/generate_options_request.rb +50 -0
  75. data/lib/vellum_ai/types/generate_request.rb +60 -0
  76. data/lib/vellum_ai/types/generate_response.rb +49 -0
  77. data/lib/vellum_ai/types/generate_result.rb +62 -0
  78. data/lib/vellum_ai/types/generate_result_data.rb +49 -0
  79. data/lib/vellum_ai/types/generate_result_error.rb +45 -0
  80. data/lib/vellum_ai/types/generate_stream_response.rb +51 -0
  81. data/lib/vellum_ai/types/generate_stream_result.rb +67 -0
  82. data/lib/vellum_ai/types/generate_stream_result_data.rb +56 -0
  83. data/lib/vellum_ai/types/image_chat_message_content.rb +52 -0
  84. data/lib/vellum_ai/types/image_chat_message_content_request.rb +52 -0
  85. data/lib/vellum_ai/types/image_enum.rb +5 -0
  86. data/lib/vellum_ai/types/indexing_state_enum.rb +12 -0
  87. data/lib/vellum_ai/types/initiated_enum.rb +5 -0
  88. data/lib/vellum_ai/types/initiated_execute_prompt_event.rb +57 -0
  89. data/lib/vellum_ai/types/initiated_prompt_execution_meta.rb +68 -0
  90. data/lib/vellum_ai/types/initiated_workflow_node_result_event.rb +90 -0
  91. data/lib/vellum_ai/types/json_enum.rb +5 -0
  92. data/lib/vellum_ai/types/json_input_request.rb +51 -0
  93. data/lib/vellum_ai/types/json_variable_value.rb +45 -0
  94. data/lib/vellum_ai/types/logical_operator.rb +25 -0
  95. data/lib/vellum_ai/types/logprobs_enum.rb +6 -0
  96. data/lib/vellum_ai/types/metadata_filter_config_request.rb +85 -0
  97. data/lib/vellum_ai/types/metadata_filter_rule_combinator.rb +6 -0
  98. data/lib/vellum_ai/types/metadata_filter_rule_request.rb +84 -0
  99. data/lib/vellum_ai/types/model_version_build_config.rb +66 -0
  100. data/lib/vellum_ai/types/model_version_exec_config.rb +90 -0
  101. data/lib/vellum_ai/types/model_version_exec_config_parameters.rb +98 -0
  102. data/lib/vellum_ai/types/model_version_read.rb +133 -0
  103. data/lib/vellum_ai/types/model_version_read_status_enum.rb +11 -0
  104. data/lib/vellum_ai/types/model_version_sandbox_snapshot.rb +61 -0
  105. data/lib/vellum_ai/types/named_test_case_chat_history_variable_value_request.rb +54 -0
  106. data/lib/vellum_ai/types/named_test_case_error_variable_value_request.rb +56 -0
  107. data/lib/vellum_ai/types/named_test_case_json_variable_value_request.rb +50 -0
  108. data/lib/vellum_ai/types/named_test_case_number_variable_value_request.rb +50 -0
  109. data/lib/vellum_ai/types/named_test_case_search_results_variable_value_request.rb +54 -0
  110. data/lib/vellum_ai/types/named_test_case_string_variable_value_request.rb +50 -0
  111. data/lib/vellum_ai/types/named_test_case_variable_value_request.rb +142 -0
  112. data/lib/vellum_ai/types/node_input_compiled_chat_history_value.rb +59 -0
  113. data/lib/vellum_ai/types/node_input_compiled_error_value.rb +61 -0
  114. data/lib/vellum_ai/types/node_input_compiled_json_value.rb +55 -0
  115. data/lib/vellum_ai/types/node_input_compiled_number_value.rb +55 -0
  116. data/lib/vellum_ai/types/node_input_compiled_search_results_value.rb +59 -0
  117. data/lib/vellum_ai/types/node_input_compiled_string_value.rb +55 -0
  118. data/lib/vellum_ai/types/node_input_variable_compiled_value.rb +142 -0
  119. data/lib/vellum_ai/types/node_output_compiled_chat_history_value.rb +54 -0
  120. data/lib/vellum_ai/types/node_output_compiled_error_value.rb +56 -0
  121. data/lib/vellum_ai/types/node_output_compiled_json_value.rb +50 -0
  122. data/lib/vellum_ai/types/node_output_compiled_number_value.rb +50 -0
  123. data/lib/vellum_ai/types/node_output_compiled_search_results_value.rb +54 -0
  124. data/lib/vellum_ai/types/node_output_compiled_string_value.rb +50 -0
  125. data/lib/vellum_ai/types/node_output_compiled_value.rb +142 -0
  126. data/lib/vellum_ai/types/normalized_log_probs.rb +54 -0
  127. data/lib/vellum_ai/types/normalized_token_log_probs.rb +61 -0
  128. data/lib/vellum_ai/types/number_enum.rb +5 -0
  129. data/lib/vellum_ai/types/paginated_slim_deployment_read_list.rb +64 -0
  130. data/lib/vellum_ai/types/paginated_slim_document_list.rb +64 -0
  131. data/lib/vellum_ai/types/paginated_slim_workflow_deployment_list.rb +64 -0
  132. data/lib/vellum_ai/types/processing_failure_reason_enum.rb +9 -0
  133. data/lib/vellum_ai/types/processing_state_enum.rb +11 -0
  134. data/lib/vellum_ai/types/prompt_deployment_expand_meta_request_request.rb +74 -0
  135. data/lib/vellum_ai/types/prompt_deployment_input_request.rb +103 -0
  136. data/lib/vellum_ai/types/prompt_execution_meta.rb +76 -0
  137. data/lib/vellum_ai/types/prompt_node_result.rb +52 -0
  138. data/lib/vellum_ai/types/prompt_node_result_data.rb +55 -0
  139. data/lib/vellum_ai/types/prompt_output.rb +116 -0
  140. data/lib/vellum_ai/types/prompt_template_block.rb +62 -0
  141. data/lib/vellum_ai/types/prompt_template_block_data.rb +54 -0
  142. data/lib/vellum_ai/types/prompt_template_block_data_request.rb +54 -0
  143. data/lib/vellum_ai/types/prompt_template_block_properties.rb +104 -0
  144. data/lib/vellum_ai/types/prompt_template_block_properties_request.rb +104 -0
  145. data/lib/vellum_ai/types/prompt_template_block_request.rb +62 -0
  146. data/lib/vellum_ai/types/provider_enum.rb +20 -0
  147. data/lib/vellum_ai/types/raw_prompt_execution_overrides_request.rb +55 -0
  148. data/lib/vellum_ai/types/register_prompt_error_response.rb +45 -0
  149. data/lib/vellum_ai/types/register_prompt_model_parameters_request.rb +98 -0
  150. data/lib/vellum_ai/types/register_prompt_prompt.rb +50 -0
  151. data/lib/vellum_ai/types/register_prompt_prompt_info_request.rb +60 -0
  152. data/lib/vellum_ai/types/register_prompt_response.rb +110 -0
  153. data/lib/vellum_ai/types/registered_prompt_deployment.rb +55 -0
  154. data/lib/vellum_ai/types/registered_prompt_input_variable_request.rb +56 -0
  155. data/lib/vellum_ai/types/registered_prompt_model_version.rb +50 -0
  156. data/lib/vellum_ai/types/registered_prompt_sandbox.rb +50 -0
  157. data/lib/vellum_ai/types/registered_prompt_sandbox_snapshot.rb +45 -0
  158. data/lib/vellum_ai/types/rejected_enum.rb +5 -0
  159. data/lib/vellum_ai/types/rejected_execute_prompt_event.rb +68 -0
  160. data/lib/vellum_ai/types/rejected_execute_prompt_response.rb +73 -0
  161. data/lib/vellum_ai/types/rejected_execute_workflow_workflow_result_event.rb +63 -0
  162. data/lib/vellum_ai/types/rejected_function_call.rb +62 -0
  163. data/lib/vellum_ai/types/rejected_prompt_execution_meta.rb +52 -0
  164. data/lib/vellum_ai/types/rejected_workflow_node_result_event.rb +92 -0
  165. data/lib/vellum_ai/types/sandbox_scenario.rb +59 -0
  166. data/lib/vellum_ai/types/scenario_input.rb +70 -0
  167. data/lib/vellum_ai/types/scenario_input_request.rb +70 -0
  168. data/lib/vellum_ai/types/scenario_input_type_enum.rb +6 -0
  169. data/lib/vellum_ai/types/search_error_response.rb +45 -0
  170. data/lib/vellum_ai/types/search_filters_request.rb +56 -0
  171. data/lib/vellum_ai/types/search_node_result.rb +52 -0
  172. data/lib/vellum_ai/types/search_node_result_data.rb +70 -0
  173. data/lib/vellum_ai/types/search_request_options_request.rb +79 -0
  174. data/lib/vellum_ai/types/search_response.rb +49 -0
  175. data/lib/vellum_ai/types/search_result.rb +66 -0
  176. data/lib/vellum_ai/types/search_result_document.rb +60 -0
  177. data/lib/vellum_ai/types/search_result_document_request.rb +55 -0
  178. data/lib/vellum_ai/types/search_result_merging_request.rb +45 -0
  179. data/lib/vellum_ai/types/search_result_request.rb +66 -0
  180. data/lib/vellum_ai/types/search_results_enum.rb +5 -0
  181. data/lib/vellum_ai/types/search_weights_request.rb +50 -0
  182. data/lib/vellum_ai/types/slim_deployment_read.rb +109 -0
  183. data/lib/vellum_ai/types/slim_document.rb +126 -0
  184. data/lib/vellum_ai/types/slim_workflow_deployment.rb +118 -0
  185. data/lib/vellum_ai/types/streaming_enum.rb +5 -0
  186. data/lib/vellum_ai/types/streaming_execute_prompt_event.rb +85 -0
  187. data/lib/vellum_ai/types/streaming_prompt_execution_meta.rb +46 -0
  188. data/lib/vellum_ai/types/streaming_workflow_node_result_event.rb +99 -0
  189. data/lib/vellum_ai/types/string_chat_message_content.rb +46 -0
  190. data/lib/vellum_ai/types/string_chat_message_content_request.rb +46 -0
  191. data/lib/vellum_ai/types/string_enum.rb +5 -0
  192. data/lib/vellum_ai/types/string_input_request.rb +51 -0
  193. data/lib/vellum_ai/types/string_variable_value.rb +45 -0
  194. data/lib/vellum_ai/types/submit_completion_actual_request.rb +67 -0
  195. data/lib/vellum_ai/types/submit_completion_actuals_error_response.rb +45 -0
  196. data/lib/vellum_ai/types/submit_workflow_execution_actual_request.rb +103 -0
  197. data/lib/vellum_ai/types/templating_node_chat_history_result.rb +54 -0
  198. data/lib/vellum_ai/types/templating_node_error_result.rb +56 -0
  199. data/lib/vellum_ai/types/templating_node_json_result.rb +50 -0
  200. data/lib/vellum_ai/types/templating_node_number_result.rb +50 -0
  201. data/lib/vellum_ai/types/templating_node_result.rb +52 -0
  202. data/lib/vellum_ai/types/templating_node_result_data.rb +51 -0
  203. data/lib/vellum_ai/types/templating_node_result_output.rb +142 -0
  204. data/lib/vellum_ai/types/templating_node_search_results_result.rb +54 -0
  205. data/lib/vellum_ai/types/templating_node_string_result.rb +50 -0
  206. data/lib/vellum_ai/types/terminal_node_chat_history_result.rb +59 -0
  207. data/lib/vellum_ai/types/terminal_node_error_result.rb +61 -0
  208. data/lib/vellum_ai/types/terminal_node_json_result.rb +55 -0
  209. data/lib/vellum_ai/types/terminal_node_number_result.rb +55 -0
  210. data/lib/vellum_ai/types/terminal_node_result.rb +52 -0
  211. data/lib/vellum_ai/types/terminal_node_result_data.rb +51 -0
  212. data/lib/vellum_ai/types/terminal_node_result_output.rb +142 -0
  213. data/lib/vellum_ai/types/terminal_node_search_results_result.rb +59 -0
  214. data/lib/vellum_ai/types/terminal_node_string_result.rb +55 -0
  215. data/lib/vellum_ai/types/test_case_chat_history_variable_value.rb +54 -0
  216. data/lib/vellum_ai/types/test_case_error_variable_value.rb +56 -0
  217. data/lib/vellum_ai/types/test_case_json_variable_value.rb +50 -0
  218. data/lib/vellum_ai/types/test_case_number_variable_value.rb +50 -0
  219. data/lib/vellum_ai/types/test_case_search_results_variable_value.rb +54 -0
  220. data/lib/vellum_ai/types/test_case_string_variable_value.rb +50 -0
  221. data/lib/vellum_ai/types/test_case_variable_value.rb +142 -0
  222. data/lib/vellum_ai/types/test_suite_test_case.rb +68 -0
  223. data/lib/vellum_ai/types/upload_document_error_response.rb +45 -0
  224. data/lib/vellum_ai/types/upload_document_response.rb +45 -0
  225. data/lib/vellum_ai/types/vellum_error.rb +51 -0
  226. data/lib/vellum_ai/types/vellum_error_code_enum.rb +10 -0
  227. data/lib/vellum_ai/types/vellum_error_request.rb +51 -0
  228. data/lib/vellum_ai/types/vellum_image.rb +50 -0
  229. data/lib/vellum_ai/types/vellum_image_request.rb +50 -0
  230. data/lib/vellum_ai/types/vellum_variable.rb +56 -0
  231. data/lib/vellum_ai/types/vellum_variable_type.rb +16 -0
  232. data/lib/vellum_ai/types/workflow_event_error.rb +51 -0
  233. data/lib/vellum_ai/types/workflow_execution_actual_chat_history_request.rb +77 -0
  234. data/lib/vellum_ai/types/workflow_execution_actual_json_request.rb +73 -0
  235. data/lib/vellum_ai/types/workflow_execution_actual_string_request.rb +73 -0
  236. data/lib/vellum_ai/types/workflow_execution_event_error_code.rb +13 -0
  237. data/lib/vellum_ai/types/workflow_execution_event_type.rb +6 -0
  238. data/lib/vellum_ai/types/workflow_execution_node_result_event.rb +68 -0
  239. data/lib/vellum_ai/types/workflow_execution_workflow_result_event.rb +68 -0
  240. data/lib/vellum_ai/types/workflow_node_result_data.rb +155 -0
  241. data/lib/vellum_ai/types/workflow_node_result_event.rb +116 -0
  242. data/lib/vellum_ai/types/workflow_node_result_event_state.rb +11 -0
  243. data/lib/vellum_ai/types/workflow_output.rb +168 -0
  244. data/lib/vellum_ai/types/workflow_output_chat_history.rb +60 -0
  245. data/lib/vellum_ai/types/workflow_output_error.rb +62 -0
  246. data/lib/vellum_ai/types/workflow_output_function_call.rb +62 -0
  247. data/lib/vellum_ai/types/workflow_output_image.rb +62 -0
  248. data/lib/vellum_ai/types/workflow_output_json.rb +56 -0
  249. data/lib/vellum_ai/types/workflow_output_number.rb +56 -0
  250. data/lib/vellum_ai/types/workflow_output_search_results.rb +60 -0
  251. data/lib/vellum_ai/types/workflow_output_string.rb +56 -0
  252. data/lib/vellum_ai/types/workflow_request_chat_history_input_request.rb +54 -0
  253. data/lib/vellum_ai/types/workflow_request_input_request.rb +116 -0
  254. data/lib/vellum_ai/types/workflow_request_json_input_request.rb +50 -0
  255. data/lib/vellum_ai/types/workflow_request_number_input_request.rb +50 -0
  256. data/lib/vellum_ai/types/workflow_request_string_input_request.rb +50 -0
  257. data/lib/vellum_ai/types/workflow_result_event.rb +95 -0
  258. data/lib/vellum_ai/types/workflow_result_event_output_data.rb +142 -0
  259. data/lib/vellum_ai/types/workflow_result_event_output_data_chat_history.rb +83 -0
  260. data/lib/vellum_ai/types/workflow_result_event_output_data_error.rb +85 -0
  261. data/lib/vellum_ai/types/workflow_result_event_output_data_json.rb +79 -0
  262. data/lib/vellum_ai/types/workflow_result_event_output_data_number.rb +79 -0
  263. data/lib/vellum_ai/types/workflow_result_event_output_data_search_results.rb +83 -0
  264. data/lib/vellum_ai/types/workflow_result_event_output_data_string.rb +79 -0
  265. data/lib/vellum_ai/types/workflow_stream_event.rb +90 -0
  266. data/lib/vellum_ai/workflow_deployments/client.rb +82 -0
  267. data/lib/vellum_ai/workflow_deployments/types/workflow_deployments_list_request_status.rb +8 -0
  268. data/lib/vellum_ai.rb +476 -0
  269. metadata +381 -0
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "indexing_state_enum"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class DocumentDocumentToDocumentIndex
8
+ attr_reader :id, :document_index_id, :indexing_state, :additional_properties
9
+
10
+ # @param id [String] Vellum-generated ID that uniquely identifies this link.
11
+ # @param document_index_id [String] Vellum-generated ID that uniquely identifies the index this document is included in.
12
+ # @param indexing_state [INDEXING_STATE_ENUM] An enum value representing where this document is along its indexing lifecycle for this index.
13
+ # - `AWAITING_PROCESSING` - Awaiting Processing
14
+ # - `QUEUED` - Queued
15
+ # - `INDEXING` - Indexing
16
+ # - `INDEXED` - Indexed
17
+ # - `FAILED` - Failed
18
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
19
+ # @return [DocumentDocumentToDocumentIndex]
20
+ def initialize(id:, document_index_id:, indexing_state: nil, additional_properties: nil)
21
+ # @type [String] Vellum-generated ID that uniquely identifies this link.
22
+ @id = id
23
+ # @type [String] Vellum-generated ID that uniquely identifies the index this document is included in.
24
+ @document_index_id = document_index_id
25
+ # @type [INDEXING_STATE_ENUM] An enum value representing where this document is along its indexing lifecycle for this index.
26
+ # - `AWAITING_PROCESSING` - Awaiting Processing
27
+ # - `QUEUED` - Queued
28
+ # - `INDEXING` - Indexing
29
+ # - `INDEXED` - Indexed
30
+ # - `FAILED` - Failed
31
+ @indexing_state = indexing_state
32
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
33
+ @additional_properties = additional_properties
34
+ end
35
+
36
+ # Deserialize a JSON object to an instance of DocumentDocumentToDocumentIndex
37
+ #
38
+ # @param json_object [JSON]
39
+ # @return [DocumentDocumentToDocumentIndex]
40
+ def self.from_json(json_object:)
41
+ struct = JSON.parse(json_object, object_class: OpenStruct)
42
+ parsed_json = JSON.parse(json_object)
43
+ id = struct.id
44
+ document_index_id = struct.document_index_id
45
+ indexing_state = INDEXING_STATE_ENUM.key(parsed_json["indexing_state"]) || parsed_json["indexing_state"]
46
+ new(id: id, document_index_id: document_index_id, indexing_state: indexing_state, additional_properties: struct)
47
+ end
48
+
49
+ # Serialize an instance of DocumentDocumentToDocumentIndex to a JSON object
50
+ #
51
+ # @return [JSON]
52
+ def to_json(*_args)
53
+ {
54
+ "id": @id,
55
+ "document_index_id": @document_index_id,
56
+ "indexing_state": INDEXING_STATE_ENUM[@indexing_state] || @indexing_state
57
+ }.to_json
58
+ end
59
+
60
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
61
+ #
62
+ # @param obj [Object]
63
+ # @return [Void]
64
+ def self.validate_raw(obj:)
65
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
66
+ obj.document_index_id.is_a?(String) != false || raise("Passed value for field obj.document_index_id is not the expected type, validation failed.")
67
+ obj.indexing_state&.is_a?(INDEXING_STATE_ENUM) != false || raise("Passed value for field obj.indexing_state is not the expected type, validation failed.")
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require_relative "entity_status"
5
+ require_relative "environment_enum"
6
+ require "json"
7
+
8
+ module Vellum
9
+ class DocumentIndexRead
10
+ attr_reader :id, :created, :label, :name, :status, :environment, :indexing_config, :additional_properties
11
+
12
+ # @param id [String]
13
+ # @param created [DateTime]
14
+ # @param label [String] A human-readable label for the document index
15
+ # @param name [String] A name that uniquely identifies this index within its workspace
16
+ # @param status [ENTITY_STATUS] The current status of the document index
17
+ # - `ACTIVE` - Active
18
+ # - `ARCHIVED` - Archived
19
+ # @param environment [ENVIRONMENT_ENUM] The environment this document index is used in
20
+ # - `DEVELOPMENT` - Development
21
+ # - `STAGING` - Staging
22
+ # - `PRODUCTION` - Production
23
+ # @param indexing_config [Hash{String => String}] Configuration representing how documents should be indexed
24
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25
+ # @return [DocumentIndexRead]
26
+ def initialize(id:, created:, label:, name:, indexing_config:, status: nil, environment: nil,
27
+ additional_properties: nil)
28
+ # @type [String]
29
+ @id = id
30
+ # @type [DateTime]
31
+ @created = created
32
+ # @type [String] A human-readable label for the document index
33
+ @label = label
34
+ # @type [String] A name that uniquely identifies this index within its workspace
35
+ @name = name
36
+ # @type [ENTITY_STATUS] The current status of the document index
37
+ # - `ACTIVE` - Active
38
+ # - `ARCHIVED` - Archived
39
+ @status = status
40
+ # @type [ENVIRONMENT_ENUM] The environment this document index is used in
41
+ # - `DEVELOPMENT` - Development
42
+ # - `STAGING` - Staging
43
+ # - `PRODUCTION` - Production
44
+ @environment = environment
45
+ # @type [Hash{String => String}] Configuration representing how documents should be indexed
46
+ @indexing_config = indexing_config
47
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
48
+ @additional_properties = additional_properties
49
+ end
50
+
51
+ # Deserialize a JSON object to an instance of DocumentIndexRead
52
+ #
53
+ # @param json_object [JSON]
54
+ # @return [DocumentIndexRead]
55
+ def self.from_json(json_object:)
56
+ struct = JSON.parse(json_object, object_class: OpenStruct)
57
+ parsed_json = JSON.parse(json_object)
58
+ id = struct.id
59
+ created = DateTime.parse(parsed_json["created"])
60
+ label = struct.label
61
+ name = struct.name
62
+ status = ENTITY_STATUS.key(parsed_json["status"]) || parsed_json["status"]
63
+ environment = ENVIRONMENT_ENUM.key(parsed_json["environment"]) || parsed_json["environment"]
64
+ indexing_config = struct.indexing_config
65
+ new(id: id, created: created, label: label, name: name, status: status, environment: environment,
66
+ indexing_config: indexing_config, additional_properties: struct)
67
+ end
68
+
69
+ # Serialize an instance of DocumentIndexRead to a JSON object
70
+ #
71
+ # @return [JSON]
72
+ def to_json(*_args)
73
+ {
74
+ "id": @id,
75
+ "created": @created,
76
+ "label": @label,
77
+ "name": @name,
78
+ "status": ENTITY_STATUS[@status] || @status,
79
+ "environment": ENVIRONMENT_ENUM[@environment] || @environment,
80
+ "indexing_config": @indexing_config
81
+ }.to_json
82
+ end
83
+
84
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
85
+ #
86
+ # @param obj [Object]
87
+ # @return [Void]
88
+ def self.validate_raw(obj:)
89
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
90
+ obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
91
+ obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
92
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
93
+ obj.status&.is_a?(ENTITY_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
94
+ obj.environment&.is_a?(ENVIRONMENT_ENUM) != false || raise("Passed value for field obj.environment is not the expected type, validation failed.")
95
+ obj.indexing_config.is_a?(Hash) != false || raise("Passed value for field obj.indexing_config is not the expected type, validation failed.")
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require_relative "processing_state_enum"
5
+ require_relative "document_status"
6
+ require_relative "document_document_to_document_index"
7
+ require "json"
8
+
9
+ module Vellum
10
+ class DocumentRead
11
+ attr_reader :id, :external_id, :last_uploaded_at, :label, :processing_state, :status, :original_file_url,
12
+ :processed_file_url, :document_to_document_indexes, :metadata, :additional_properties
13
+
14
+ # @param id [String]
15
+ # @param external_id [String] The unique id of this document as it exists in the user's system.
16
+ # @param last_uploaded_at [DateTime]
17
+ # @param label [String] A human-readable label for the document. Defaults to the originally uploaded file's file name.
18
+ # @param processing_state [PROCESSING_STATE_ENUM] The current processing state of the document
19
+ # - `QUEUED` - Queued
20
+ # - `PROCESSING` - Processing
21
+ # - `PROCESSED` - Processed
22
+ # - `FAILED` - Failed
23
+ # @param status [DOCUMENT_STATUS] The current status of the document
24
+ # - `ACTIVE` - Active
25
+ # @param original_file_url [String]
26
+ # @param processed_file_url [String]
27
+ # @param document_to_document_indexes [Array<DocumentDocumentToDocumentIndex>]
28
+ # @param metadata [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [DocumentRead]
31
+ def initialize(id:, last_uploaded_at:, label:, document_to_document_indexes:, external_id: nil, processing_state: nil, status: nil,
32
+ original_file_url: nil, processed_file_url: nil, metadata: nil, additional_properties: nil)
33
+ # @type [String]
34
+ @id = id
35
+ # @type [String] The unique id of this document as it exists in the user's system.
36
+ @external_id = external_id
37
+ # @type [DateTime]
38
+ @last_uploaded_at = last_uploaded_at
39
+ # @type [String] A human-readable label for the document. Defaults to the originally uploaded file's file name.
40
+ @label = label
41
+ # @type [PROCESSING_STATE_ENUM] The current processing state of the document
42
+ # - `QUEUED` - Queued
43
+ # - `PROCESSING` - Processing
44
+ # - `PROCESSED` - Processed
45
+ # - `FAILED` - Failed
46
+ @processing_state = processing_state
47
+ # @type [DOCUMENT_STATUS] The current status of the document
48
+ # - `ACTIVE` - Active
49
+ @status = status
50
+ # @type [String]
51
+ @original_file_url = original_file_url
52
+ # @type [String]
53
+ @processed_file_url = processed_file_url
54
+ # @type [Array<DocumentDocumentToDocumentIndex>]
55
+ @document_to_document_indexes = document_to_document_indexes
56
+ # @type [Hash{String => String}] A previously supplied JSON object containing metadata that can be filtered on when searching.
57
+ @metadata = metadata
58
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
59
+ @additional_properties = additional_properties
60
+ end
61
+
62
+ # Deserialize a JSON object to an instance of DocumentRead
63
+ #
64
+ # @param json_object [JSON]
65
+ # @return [DocumentRead]
66
+ def self.from_json(json_object:)
67
+ struct = JSON.parse(json_object, object_class: OpenStruct)
68
+ parsed_json = JSON.parse(json_object)
69
+ id = struct.id
70
+ external_id = struct.external_id
71
+ last_uploaded_at = DateTime.parse(parsed_json["last_uploaded_at"])
72
+ label = struct.label
73
+ processing_state = PROCESSING_STATE_ENUM.key(parsed_json["processing_state"]) || parsed_json["processing_state"]
74
+ status = struct.status
75
+ original_file_url = struct.original_file_url
76
+ processed_file_url = struct.processed_file_url
77
+ document_to_document_indexes = parsed_json["document_to_document_indexes"].map do |v|
78
+ v = v.to_json
79
+ DocumentDocumentToDocumentIndex.from_json(json_object: v)
80
+ end
81
+ metadata = struct.metadata
82
+ new(id: id, external_id: external_id, last_uploaded_at: last_uploaded_at, label: label,
83
+ processing_state: processing_state, status: status, original_file_url: original_file_url, processed_file_url: processed_file_url, document_to_document_indexes: document_to_document_indexes, metadata: metadata, additional_properties: struct)
84
+ end
85
+
86
+ # Serialize an instance of DocumentRead to a JSON object
87
+ #
88
+ # @return [JSON]
89
+ def to_json(*_args)
90
+ {
91
+ "id": @id,
92
+ "external_id": @external_id,
93
+ "last_uploaded_at": @last_uploaded_at,
94
+ "label": @label,
95
+ "processing_state": PROCESSING_STATE_ENUM[@processing_state] || @processing_state,
96
+ "status": @status,
97
+ "original_file_url": @original_file_url,
98
+ "processed_file_url": @processed_file_url,
99
+ "document_to_document_indexes": @document_to_document_indexes,
100
+ "metadata": @metadata
101
+ }.to_json
102
+ end
103
+
104
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
105
+ #
106
+ # @param obj [Object]
107
+ # @return [Void]
108
+ def self.validate_raw(obj:)
109
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
110
+ obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
111
+ obj.last_uploaded_at.is_a?(DateTime) != false || raise("Passed value for field obj.last_uploaded_at is not the expected type, validation failed.")
112
+ obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
113
+ obj.processing_state&.is_a?(PROCESSING_STATE_ENUM) != false || raise("Passed value for field obj.processing_state is not the expected type, validation failed.")
114
+ obj.status&.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
115
+ obj.original_file_url&.is_a?(String) != false || raise("Passed value for field obj.original_file_url is not the expected type, validation failed.")
116
+ obj.processed_file_url&.is_a?(String) != false || raise("Passed value for field obj.processed_file_url is not the expected type, validation failed.")
117
+ obj.document_to_document_indexes.is_a?(Array) != false || raise("Passed value for field obj.document_to_document_indexes is not the expected type, validation failed.")
118
+ obj.metadata&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vellum
4
+ DOCUMENT_STATUS = String
5
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "finish_reason_enum"
4
+ require_relative "normalized_log_probs"
5
+ require_relative "vellum_variable_type"
6
+ require "json"
7
+
8
+ module Vellum
9
+ class EnrichedNormalizedCompletion
10
+ attr_reader :id, :external_id, :text, :finish_reason, :logprobs, :model_version_id, :prompt_version_id, :type,
11
+ :deployment_release_tag, :model_name, :additional_properties
12
+
13
+ # @param id [String] The Vellum-generated ID of the completion.
14
+ # @param external_id [String] The external ID that was originally provided along with the generation request, which uniquely identifies this generation in an external system.
15
+ # @param text [String] The text generated by the LLM.
16
+ # @param finish_reason [FINISH_REASON_ENUM] The reason the generation finished.
17
+ # - `LENGTH` - LENGTH
18
+ # - `STOP` - STOP
19
+ # - `UNKNOWN` - UNKNOWN
20
+ # @param logprobs [NormalizedLogProbs] The logprobs of the completion. Only present if specified in the original request options.
21
+ # @param model_version_id [String] The ID of the model version used to generate this completion.
22
+ # @param prompt_version_id [String]
23
+ # @param type [VELLUM_VARIABLE_TYPE]
24
+ # @param deployment_release_tag [String]
25
+ # @param model_name [String]
26
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
27
+ # @return [EnrichedNormalizedCompletion]
28
+ def initialize(id:, text:, model_version_id:, prompt_version_id:, deployment_release_tag:, model_name:,
29
+ external_id: nil, finish_reason: nil, logprobs: nil, type: nil, additional_properties: nil)
30
+ # @type [String] The Vellum-generated ID of the completion.
31
+ @id = id
32
+ # @type [String] The external ID that was originally provided along with the generation request, which uniquely identifies this generation in an external system.
33
+ @external_id = external_id
34
+ # @type [String] The text generated by the LLM.
35
+ @text = text
36
+ # @type [FINISH_REASON_ENUM] The reason the generation finished.
37
+ # - `LENGTH` - LENGTH
38
+ # - `STOP` - STOP
39
+ # - `UNKNOWN` - UNKNOWN
40
+ @finish_reason = finish_reason
41
+ # @type [NormalizedLogProbs] The logprobs of the completion. Only present if specified in the original request options.
42
+ @logprobs = logprobs
43
+ # @type [String] The ID of the model version used to generate this completion.
44
+ @model_version_id = model_version_id
45
+ # @type [String]
46
+ @prompt_version_id = prompt_version_id
47
+ # @type [VELLUM_VARIABLE_TYPE]
48
+ @type = type
49
+ # @type [String]
50
+ @deployment_release_tag = deployment_release_tag
51
+ # @type [String]
52
+ @model_name = model_name
53
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
54
+ @additional_properties = additional_properties
55
+ end
56
+
57
+ # Deserialize a JSON object to an instance of EnrichedNormalizedCompletion
58
+ #
59
+ # @param json_object [JSON]
60
+ # @return [EnrichedNormalizedCompletion]
61
+ def self.from_json(json_object:)
62
+ struct = JSON.parse(json_object, object_class: OpenStruct)
63
+ parsed_json = JSON.parse(json_object)
64
+ id = struct.id
65
+ external_id = struct.external_id
66
+ text = struct.text
67
+ finish_reason = FINISH_REASON_ENUM.key(parsed_json["finish_reason"]) || parsed_json["finish_reason"]
68
+ if parsed_json["logprobs"].nil?
69
+ logprobs = nil
70
+ else
71
+ logprobs = parsed_json["logprobs"].to_json
72
+ logprobs = NormalizedLogProbs.from_json(json_object: logprobs)
73
+ end
74
+ model_version_id = struct.model_version_id
75
+ prompt_version_id = struct.prompt_version_id
76
+ type = VELLUM_VARIABLE_TYPE.key(parsed_json["type"]) || parsed_json["type"]
77
+ deployment_release_tag = struct.deployment_release_tag
78
+ model_name = struct.model_name
79
+ new(id: id, external_id: external_id, text: text, finish_reason: finish_reason, logprobs: logprobs,
80
+ model_version_id: model_version_id, prompt_version_id: prompt_version_id, type: type, deployment_release_tag: deployment_release_tag, model_name: model_name, additional_properties: struct)
81
+ end
82
+
83
+ # Serialize an instance of EnrichedNormalizedCompletion to a JSON object
84
+ #
85
+ # @return [JSON]
86
+ def to_json(*_args)
87
+ {
88
+ "id": @id,
89
+ "external_id": @external_id,
90
+ "text": @text,
91
+ "finish_reason": FINISH_REASON_ENUM[@finish_reason] || @finish_reason,
92
+ "logprobs": @logprobs,
93
+ "model_version_id": @model_version_id,
94
+ "prompt_version_id": @prompt_version_id,
95
+ "type": VELLUM_VARIABLE_TYPE[@type] || @type,
96
+ "deployment_release_tag": @deployment_release_tag,
97
+ "model_name": @model_name
98
+ }.to_json
99
+ end
100
+
101
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
102
+ #
103
+ # @param obj [Object]
104
+ # @return [Void]
105
+ def self.validate_raw(obj:)
106
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
107
+ obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
108
+ obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
109
+ obj.finish_reason&.is_a?(FINISH_REASON_ENUM) != false || raise("Passed value for field obj.finish_reason is not the expected type, validation failed.")
110
+ obj.logprobs.nil? || NormalizedLogProbs.validate_raw(obj: obj.logprobs)
111
+ obj.model_version_id.is_a?(String) != false || raise("Passed value for field obj.model_version_id is not the expected type, validation failed.")
112
+ obj.prompt_version_id.is_a?(String) != false || raise("Passed value for field obj.prompt_version_id is not the expected type, validation failed.")
113
+ obj.type&.is_a?(VELLUM_VARIABLE_TYPE) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
114
+ obj.deployment_release_tag.is_a?(String) != false || raise("Passed value for field obj.deployment_release_tag is not the expected type, validation failed.")
115
+ obj.model_name.is_a?(String) != false || raise("Passed value for field obj.model_name is not the expected type, validation failed.")
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vellum
4
+ # @type [ENTITY_STATUS]
5
+ ENTITY_STATUS = { active: "ACTIVE", archived: "ARCHIVED" }.freeze
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vellum
4
+ # @type [ENVIRONMENT_ENUM]
5
+ ENVIRONMENT_ENUM = { development: "DEVELOPMENT", staging: "STAGING", production: "PRODUCTION" }.freeze
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vellum
4
+ ERROR_ENUM = String
5
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "vellum_error"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class ErrorVariableValue
8
+ attr_reader :value, :additional_properties
9
+
10
+ # @param value [VellumError]
11
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
+ # @return [ErrorVariableValue]
13
+ def initialize(value: nil, additional_properties: nil)
14
+ # @type [VellumError]
15
+ @value = value
16
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
17
+ @additional_properties = additional_properties
18
+ end
19
+
20
+ # Deserialize a JSON object to an instance of ErrorVariableValue
21
+ #
22
+ # @param json_object [JSON]
23
+ # @return [ErrorVariableValue]
24
+ def self.from_json(json_object:)
25
+ struct = JSON.parse(json_object, object_class: OpenStruct)
26
+ parsed_json = JSON.parse(json_object)
27
+ if parsed_json["value"].nil?
28
+ value = nil
29
+ else
30
+ value = parsed_json["value"].to_json
31
+ value = VellumError.from_json(json_object: value)
32
+ end
33
+ new(value: value, additional_properties: struct)
34
+ end
35
+
36
+ # Serialize an instance of ErrorVariableValue to a JSON object
37
+ #
38
+ # @return [JSON]
39
+ def to_json(*_args)
40
+ { "value": @value }.to_json
41
+ end
42
+
43
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
44
+ #
45
+ # @param obj [Object]
46
+ # @return [Void]
47
+ def self.validate_raw(obj:)
48
+ obj.value.nil? || VellumError.validate_raw(obj: obj.value)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Vellum
6
+ class ExecutePromptApiErrorResponse
7
+ attr_reader :detail, :additional_properties
8
+
9
+ # @param detail [String] Details about why the request failed.
10
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
11
+ # @return [ExecutePromptApiErrorResponse]
12
+ def initialize(detail:, additional_properties: nil)
13
+ # @type [String] Details about why the request failed.
14
+ @detail = detail
15
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
16
+ @additional_properties = additional_properties
17
+ end
18
+
19
+ # Deserialize a JSON object to an instance of ExecutePromptApiErrorResponse
20
+ #
21
+ # @param json_object [JSON]
22
+ # @return [ExecutePromptApiErrorResponse]
23
+ def self.from_json(json_object:)
24
+ struct = JSON.parse(json_object, object_class: OpenStruct)
25
+ JSON.parse(json_object)
26
+ detail = struct.detail
27
+ new(detail: detail, additional_properties: struct)
28
+ end
29
+
30
+ # Serialize an instance of ExecutePromptApiErrorResponse to a JSON object
31
+ #
32
+ # @return [JSON]
33
+ def to_json(*_args)
34
+ { "detail": @detail }.to_json
35
+ end
36
+
37
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
38
+ #
39
+ # @param obj [Object]
40
+ # @return [Void]
41
+ def self.validate_raw(obj:)
42
+ obj.detail.is_a?(String) != false || raise("Passed value for field obj.detail is not the expected type, validation failed.")
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "initiated_execute_prompt_event"
5
+ require_relative "streaming_execute_prompt_event"
6
+ require_relative "fulfilled_execute_prompt_event"
7
+ require_relative "rejected_execute_prompt_event"
8
+
9
+ module Vellum
10
+ class ExecutePromptEvent
11
+ attr_reader :member, :discriminant
12
+
13
+ private_class_method :new
14
+ alias kind_of? is_a?
15
+ # @param member [Object]
16
+ # @param discriminant [String]
17
+ # @return [ExecutePromptEvent]
18
+ def initialize(member:, discriminant:)
19
+ # @type [Object]
20
+ @member = member
21
+ # @type [String]
22
+ @discriminant = discriminant
23
+ end
24
+
25
+ # Deserialize a JSON object to an instance of ExecutePromptEvent
26
+ #
27
+ # @param json_object [JSON]
28
+ # @return [ExecutePromptEvent]
29
+ def self.from_json(json_object:)
30
+ struct = JSON.parse(json_object, object_class: OpenStruct)
31
+ member = case struct.state
32
+ when "INITIATED"
33
+ InitiatedExecutePromptEvent.from_json(json_object: json_object)
34
+ when "STREAMING"
35
+ StreamingExecutePromptEvent.from_json(json_object: json_object)
36
+ when "FULFILLED"
37
+ FulfilledExecutePromptEvent.from_json(json_object: json_object)
38
+ when "REJECTED"
39
+ RejectedExecutePromptEvent.from_json(json_object: json_object)
40
+ else
41
+ InitiatedExecutePromptEvent.from_json(json_object: json_object)
42
+ end
43
+ new(member: member, discriminant: struct.state)
44
+ end
45
+
46
+ # For Union Types, to_json functionality is delegated to the wrapped member.
47
+ #
48
+ # @return [JSON]
49
+ def to_json(*_args)
50
+ case @discriminant
51
+ when "INITIATED"
52
+ { **@member.to_json, state: @discriminant }.to_json
53
+ when "STREAMING"
54
+ { **@member.to_json, state: @discriminant }.to_json
55
+ when "FULFILLED"
56
+ { **@member.to_json, state: @discriminant }.to_json
57
+ when "REJECTED"
58
+ { **@member.to_json, state: @discriminant }.to_json
59
+ else
60
+ { "state": @discriminant, value: @member }.to_json
61
+ end
62
+ @member.to_json
63
+ end
64
+
65
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
66
+ #
67
+ # @param obj [Object]
68
+ # @return [Void]
69
+ def self.validate_raw(obj:)
70
+ case obj.state
71
+ when "INITIATED"
72
+ InitiatedExecutePromptEvent.validate_raw(obj: obj)
73
+ when "STREAMING"
74
+ StreamingExecutePromptEvent.validate_raw(obj: obj)
75
+ when "FULFILLED"
76
+ FulfilledExecutePromptEvent.validate_raw(obj: obj)
77
+ when "REJECTED"
78
+ RejectedExecutePromptEvent.validate_raw(obj: obj)
79
+ else
80
+ raise("Passed value matched no type within the union, validation failed.")
81
+ end
82
+ end
83
+
84
+ # For Union Types, is_a? functionality is delegated to the wrapped member.
85
+ #
86
+ # @param obj [Object]
87
+ # @return [Boolean]
88
+ def is_a?(obj)
89
+ @member.is_a?(obj)
90
+ end
91
+
92
+ # @param member [InitiatedExecutePromptEvent]
93
+ # @return [ExecutePromptEvent]
94
+ def self.initiated(member:)
95
+ new(member: member, discriminant: "INITIATED")
96
+ end
97
+
98
+ # @param member [StreamingExecutePromptEvent]
99
+ # @return [ExecutePromptEvent]
100
+ def self.streaming(member:)
101
+ new(member: member, discriminant: "STREAMING")
102
+ end
103
+
104
+ # @param member [FulfilledExecutePromptEvent]
105
+ # @return [ExecutePromptEvent]
106
+ def self.fulfilled(member:)
107
+ new(member: member, discriminant: "FULFILLED")
108
+ end
109
+
110
+ # @param member [RejectedExecutePromptEvent]
111
+ # @return [ExecutePromptEvent]
112
+ def self.rejected(member:)
113
+ new(member: member, discriminant: "REJECTED")
114
+ end
115
+ end
116
+ end