llama-cloud 0.1.41__py3-none-any.whl → 1.0.0b4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (714) hide show
  1. llama_cloud/__init__.py +101 -816
  2. llama_cloud/_base_client.py +2124 -0
  3. llama_cloud/_client.py +795 -0
  4. llama_cloud/_compat.py +219 -0
  5. llama_cloud/_constants.py +14 -0
  6. llama_cloud/_exceptions.py +108 -0
  7. llama_cloud/_files.py +127 -0
  8. llama_cloud/_models.py +872 -0
  9. llama_cloud/_polling.py +182 -0
  10. llama_cloud/_qs.py +150 -0
  11. llama_cloud/_resource.py +43 -0
  12. llama_cloud/_response.py +832 -0
  13. llama_cloud/_streaming.py +333 -0
  14. llama_cloud/_types.py +270 -0
  15. llama_cloud/_utils/__init__.py +64 -0
  16. llama_cloud/_utils/_compat.py +45 -0
  17. llama_cloud/_utils/_datetime_parse.py +136 -0
  18. llama_cloud/_utils/_logs.py +25 -0
  19. llama_cloud/_utils/_proxy.py +65 -0
  20. llama_cloud/_utils/_reflection.py +42 -0
  21. llama_cloud/_utils/_resources_proxy.py +24 -0
  22. llama_cloud/_utils/_streams.py +12 -0
  23. llama_cloud/_utils/_sync.py +58 -0
  24. llama_cloud/_utils/_transform.py +457 -0
  25. llama_cloud/_utils/_typing.py +156 -0
  26. llama_cloud/_utils/_utils.py +421 -0
  27. llama_cloud/_version.py +4 -0
  28. llama_cloud/lib/__init__.py +0 -0
  29. llama_cloud/lib/index/__init__.py +13 -0
  30. llama_cloud/lib/index/api_utils.py +300 -0
  31. llama_cloud/lib/index/base.py +1041 -0
  32. llama_cloud/lib/index/composite_retriever.py +272 -0
  33. llama_cloud/lib/index/retriever.py +233 -0
  34. llama_cloud/pagination.py +465 -0
  35. llama_cloud/py.typed +0 -0
  36. llama_cloud/resources/__init__.py +136 -107
  37. llama_cloud/resources/beta/__init__.py +102 -1
  38. llama_cloud/resources/beta/agent_data.py +1041 -0
  39. llama_cloud/resources/beta/batch/__init__.py +33 -0
  40. llama_cloud/resources/beta/batch/batch.py +664 -0
  41. llama_cloud/resources/beta/batch/job_items.py +348 -0
  42. llama_cloud/resources/beta/beta.py +262 -0
  43. llama_cloud/resources/beta/directories/__init__.py +33 -0
  44. llama_cloud/resources/beta/directories/directories.py +719 -0
  45. llama_cloud/resources/beta/directories/files.py +913 -0
  46. llama_cloud/resources/beta/parse_configurations.py +743 -0
  47. llama_cloud/resources/beta/sheets.py +1130 -0
  48. llama_cloud/resources/beta/split.py +917 -0
  49. llama_cloud/resources/classifier/__init__.py +32 -1
  50. llama_cloud/resources/classifier/classifier.py +588 -0
  51. llama_cloud/resources/classifier/jobs.py +563 -0
  52. llama_cloud/resources/data_sinks.py +579 -0
  53. llama_cloud/resources/data_sources.py +651 -0
  54. llama_cloud/resources/extraction/__init__.py +61 -0
  55. llama_cloud/resources/extraction/extraction.py +609 -0
  56. llama_cloud/resources/extraction/extraction_agents/__init__.py +33 -0
  57. llama_cloud/resources/extraction/extraction_agents/extraction_agents.py +633 -0
  58. llama_cloud/resources/extraction/extraction_agents/schema.py +308 -0
  59. llama_cloud/resources/extraction/jobs.py +1106 -0
  60. llama_cloud/resources/extraction/runs.py +498 -0
  61. llama_cloud/resources/files.py +784 -0
  62. llama_cloud/resources/parsing.py +1296 -0
  63. llama_cloud/resources/pipelines/__init__.py +98 -24
  64. llama_cloud/resources/pipelines/data_sources.py +529 -0
  65. llama_cloud/resources/pipelines/documents.py +810 -0
  66. llama_cloud/resources/pipelines/files.py +682 -0
  67. llama_cloud/resources/pipelines/images.py +513 -0
  68. llama_cloud/resources/pipelines/metadata.py +265 -0
  69. llama_cloud/resources/pipelines/pipelines.py +1525 -0
  70. llama_cloud/resources/pipelines/sync.py +243 -0
  71. llama_cloud/resources/projects.py +276 -0
  72. llama_cloud/resources/retrievers/__init__.py +32 -1
  73. llama_cloud/resources/retrievers/retriever.py +238 -0
  74. llama_cloud/resources/retrievers/retrievers.py +920 -0
  75. llama_cloud/types/__init__.py +171 -721
  76. llama_cloud/types/advanced_mode_transform_config.py +102 -38
  77. llama_cloud/types/advanced_mode_transform_config_param.py +102 -0
  78. llama_cloud/types/auto_transform_config.py +11 -25
  79. llama_cloud/types/auto_transform_config_param.py +17 -0
  80. llama_cloud/types/azure_openai_embedding.py +62 -0
  81. llama_cloud/types/azure_openai_embedding_config.py +17 -0
  82. llama_cloud/types/azure_openai_embedding_config_param.py +17 -0
  83. llama_cloud/types/azure_openai_embedding_param.py +61 -0
  84. llama_cloud/types/b_box.py +37 -0
  85. llama_cloud/types/bedrock_embedding.py +49 -46
  86. llama_cloud/types/bedrock_embedding_config.py +10 -27
  87. llama_cloud/types/bedrock_embedding_config_param.py +17 -0
  88. llama_cloud/types/bedrock_embedding_param.py +48 -0
  89. llama_cloud/types/beta/__init__.py +59 -0
  90. llama_cloud/types/beta/agent_data.py +26 -0
  91. llama_cloud/types/beta/agent_data_agent_data_params.py +20 -0
  92. llama_cloud/types/beta/agent_data_aggregate_params.py +79 -0
  93. llama_cloud/types/beta/agent_data_aggregate_response.py +17 -0
  94. llama_cloud/types/beta/agent_data_delete_by_query_params.py +43 -0
  95. llama_cloud/types/beta/agent_data_delete_by_query_response.py +11 -0
  96. llama_cloud/types/beta/agent_data_delete_params.py +14 -0
  97. llama_cloud/types/beta/agent_data_delete_response.py +8 -0
  98. llama_cloud/types/beta/agent_data_get_params.py +14 -0
  99. llama_cloud/types/beta/agent_data_search_params.py +69 -0
  100. llama_cloud/types/beta/agent_data_update_params.py +16 -0
  101. llama_cloud/types/beta/batch/__init__.py +12 -0
  102. llama_cloud/types/beta/batch/job_item_get_processing_results_params.py +17 -0
  103. llama_cloud/types/beta/batch/job_item_get_processing_results_response.py +409 -0
  104. llama_cloud/types/beta/batch/job_item_list_params.py +23 -0
  105. llama_cloud/types/beta/batch/job_item_list_response.py +42 -0
  106. llama_cloud/types/beta/batch_cancel_params.py +21 -0
  107. llama_cloud/types/beta/batch_cancel_response.py +23 -0
  108. llama_cloud/types/beta/batch_create_params.py +399 -0
  109. llama_cloud/types/beta/batch_create_response.py +63 -0
  110. llama_cloud/types/beta/batch_get_status_params.py +14 -0
  111. llama_cloud/types/beta/batch_get_status_response.py +73 -0
  112. llama_cloud/types/beta/batch_list_params.py +29 -0
  113. llama_cloud/types/beta/batch_list_response.py +63 -0
  114. llama_cloud/types/beta/directories/__init__.py +15 -0
  115. llama_cloud/types/beta/directories/file_add_params.py +26 -0
  116. llama_cloud/types/beta/directories/file_add_response.py +42 -0
  117. llama_cloud/types/beta/directories/file_delete_params.py +16 -0
  118. llama_cloud/types/beta/directories/file_get_params.py +16 -0
  119. llama_cloud/types/beta/directories/file_get_response.py +42 -0
  120. llama_cloud/types/beta/directories/file_list_params.py +28 -0
  121. llama_cloud/types/beta/directories/file_list_response.py +42 -0
  122. llama_cloud/types/beta/directories/file_update_params.py +27 -0
  123. llama_cloud/types/beta/directories/file_update_response.py +42 -0
  124. llama_cloud/types/beta/directories/file_upload_params.py +24 -0
  125. llama_cloud/types/beta/directories/file_upload_response.py +42 -0
  126. llama_cloud/types/beta/directory_create_params.py +23 -0
  127. llama_cloud/types/beta/directory_create_response.py +36 -0
  128. llama_cloud/types/beta/directory_delete_params.py +14 -0
  129. llama_cloud/types/beta/directory_get_params.py +14 -0
  130. llama_cloud/types/beta/directory_get_response.py +36 -0
  131. llama_cloud/types/beta/directory_list_params.py +24 -0
  132. llama_cloud/types/beta/directory_list_response.py +36 -0
  133. llama_cloud/types/beta/directory_update_params.py +20 -0
  134. llama_cloud/types/beta/directory_update_response.py +36 -0
  135. llama_cloud/types/beta/parse_configuration.py +40 -0
  136. llama_cloud/types/beta/parse_configuration_create_params.py +34 -0
  137. llama_cloud/types/beta/parse_configuration_delete_params.py +14 -0
  138. llama_cloud/types/beta/parse_configuration_get_params.py +14 -0
  139. llama_cloud/types/beta/parse_configuration_list_params.py +24 -0
  140. llama_cloud/types/beta/parse_configuration_query_response.py +28 -0
  141. llama_cloud/types/beta/parse_configuration_update_params.py +22 -0
  142. llama_cloud/types/beta/sheet_create_params.py +22 -0
  143. llama_cloud/types/beta/sheet_delete_job_params.py +14 -0
  144. llama_cloud/types/beta/sheet_get_params.py +16 -0
  145. llama_cloud/types/beta/sheet_get_result_table_params.py +20 -0
  146. llama_cloud/types/beta/sheet_list_params.py +20 -0
  147. llama_cloud/types/beta/sheets_job.py +88 -0
  148. llama_cloud/types/beta/sheets_parsing_config.py +49 -0
  149. llama_cloud/types/beta/sheets_parsing_config_param.py +51 -0
  150. llama_cloud/types/beta/split_category.py +17 -0
  151. llama_cloud/types/beta/split_category_param.py +18 -0
  152. llama_cloud/types/beta/split_create_params.py +36 -0
  153. llama_cloud/types/beta/split_create_response.py +48 -0
  154. llama_cloud/types/beta/split_document_input.py +15 -0
  155. llama_cloud/types/beta/split_document_input_param.py +17 -0
  156. llama_cloud/types/beta/split_get_params.py +14 -0
  157. llama_cloud/types/beta/split_get_response.py +48 -0
  158. llama_cloud/types/beta/split_list_params.py +18 -0
  159. llama_cloud/types/beta/split_list_response.py +48 -0
  160. llama_cloud/types/beta/split_result_response.py +15 -0
  161. llama_cloud/types/beta/split_segment_response.py +20 -0
  162. llama_cloud/types/classifier/__init__.py +15 -0
  163. llama_cloud/types/classifier/classifier_rule.py +25 -0
  164. llama_cloud/types/classifier/classifier_rule_param.py +27 -0
  165. llama_cloud/types/classifier/classify_job.py +51 -0
  166. llama_cloud/types/classifier/classify_job_param.py +53 -0
  167. llama_cloud/types/classifier/classify_parsing_configuration.py +21 -0
  168. llama_cloud/types/classifier/classify_parsing_configuration_param.py +23 -0
  169. llama_cloud/types/classifier/job_create_params.py +30 -0
  170. llama_cloud/types/classifier/job_get_params.py +14 -0
  171. llama_cloud/types/classifier/job_get_results_params.py +14 -0
  172. llama_cloud/types/classifier/job_get_results_response.py +66 -0
  173. llama_cloud/types/classifier/job_list_params.py +18 -0
  174. llama_cloud/types/cohere_embedding.py +37 -40
  175. llama_cloud/types/cohere_embedding_config.py +10 -27
  176. llama_cloud/types/cohere_embedding_config_param.py +17 -0
  177. llama_cloud/types/cohere_embedding_param.py +36 -0
  178. llama_cloud/types/composite_retrieval_mode.py +4 -18
  179. llama_cloud/types/composite_retrieval_result.py +52 -37
  180. llama_cloud/types/data_sink.py +46 -39
  181. llama_cloud/types/data_sink_create_param.py +41 -0
  182. llama_cloud/types/data_sink_create_params.py +44 -0
  183. llama_cloud/types/data_sink_list_params.py +14 -0
  184. llama_cloud/types/data_sink_list_response.py +10 -0
  185. llama_cloud/types/data_sink_update_params.py +40 -0
  186. llama_cloud/types/data_source.py +67 -39
  187. llama_cloud/types/data_source_create_params.py +65 -0
  188. llama_cloud/types/data_source_list_params.py +14 -0
  189. llama_cloud/types/data_source_list_response.py +10 -0
  190. llama_cloud/types/data_source_reader_version_metadata.py +8 -27
  191. llama_cloud/types/data_source_update_params.py +61 -0
  192. llama_cloud/types/extraction/__init__.py +25 -0
  193. llama_cloud/types/extraction/extract_agent.py +41 -0
  194. llama_cloud/types/extraction/extract_config.py +118 -0
  195. llama_cloud/types/extraction/extract_config_param.py +118 -0
  196. llama_cloud/types/extraction/extract_job.py +32 -0
  197. llama_cloud/types/extraction/extract_run.py +64 -0
  198. llama_cloud/types/extraction/extraction_agent_create_params.py +25 -0
  199. llama_cloud/types/extraction/extraction_agent_list_params.py +17 -0
  200. llama_cloud/types/extraction/extraction_agent_list_response.py +10 -0
  201. llama_cloud/types/extraction/extraction_agent_update_params.py +18 -0
  202. llama_cloud/types/extraction/extraction_agents/__init__.py +8 -0
  203. llama_cloud/types/extraction/extraction_agents/schema_generate_schema_params.py +23 -0
  204. llama_cloud/types/extraction/extraction_agents/schema_generate_schema_response.py +14 -0
  205. llama_cloud/types/extraction/extraction_agents/schema_validate_schema_params.py +12 -0
  206. llama_cloud/types/extraction/extraction_agents/schema_validate_schema_response.py +13 -0
  207. llama_cloud/types/extraction/job_create_params.py +38 -0
  208. llama_cloud/types/extraction/job_file_params.py +29 -0
  209. llama_cloud/types/extraction/job_get_result_params.py +14 -0
  210. llama_cloud/types/extraction/job_get_result_response.py +27 -0
  211. llama_cloud/types/extraction/job_list_params.py +11 -0
  212. llama_cloud/types/extraction/job_list_response.py +10 -0
  213. llama_cloud/types/extraction/run_delete_params.py +14 -0
  214. llama_cloud/types/extraction/run_get_by_job_params.py +14 -0
  215. llama_cloud/types/extraction/run_get_params.py +14 -0
  216. llama_cloud/types/extraction/run_list_params.py +15 -0
  217. llama_cloud/types/extraction/webhook_configuration.py +43 -0
  218. llama_cloud/types/extraction/webhook_configuration_param.py +43 -0
  219. llama_cloud/types/extraction_run_params.py +45 -0
  220. llama_cloud/types/fail_page_mode.py +4 -26
  221. llama_cloud/types/file.py +48 -40
  222. llama_cloud/types/file_create_params.py +28 -0
  223. llama_cloud/types/file_create_response.py +38 -0
  224. llama_cloud/types/file_delete_params.py +14 -0
  225. llama_cloud/types/file_get_params.py +16 -0
  226. llama_cloud/types/file_list_params.py +40 -0
  227. llama_cloud/types/file_list_response.py +38 -0
  228. llama_cloud/types/file_query_params.py +61 -0
  229. llama_cloud/types/file_query_response.py +47 -27
  230. llama_cloud/types/gemini_embedding.py +40 -39
  231. llama_cloud/types/gemini_embedding_config.py +10 -27
  232. llama_cloud/types/gemini_embedding_config_param.py +17 -0
  233. llama_cloud/types/gemini_embedding_param.py +39 -0
  234. llama_cloud/types/hugging_face_inference_api_embedding.py +62 -46
  235. llama_cloud/types/hugging_face_inference_api_embedding_config.py +11 -28
  236. llama_cloud/types/hugging_face_inference_api_embedding_config_param.py +17 -0
  237. llama_cloud/types/hugging_face_inference_api_embedding_param.py +60 -0
  238. llama_cloud/types/list_item.py +48 -0
  239. llama_cloud/types/llama_parse_parameters.py +251 -130
  240. llama_cloud/types/llama_parse_parameters_param.py +261 -0
  241. llama_cloud/types/llama_parse_supported_file_extensions.py +84 -310
  242. llama_cloud/types/managed_ingestion_status_response.py +39 -37
  243. llama_cloud/types/message_role.py +4 -46
  244. llama_cloud/types/metadata_filters.py +45 -29
  245. llama_cloud/types/metadata_filters_param.py +58 -0
  246. llama_cloud/types/openai_embedding.py +56 -0
  247. llama_cloud/types/openai_embedding_config.py +17 -0
  248. llama_cloud/types/openai_embedding_config_param.py +17 -0
  249. llama_cloud/types/openai_embedding_param.py +55 -0
  250. llama_cloud/types/page_figure_node_with_score.py +32 -29
  251. llama_cloud/types/page_screenshot_node_with_score.py +23 -29
  252. llama_cloud/types/parsing_create_params.py +586 -0
  253. llama_cloud/types/parsing_create_response.py +33 -0
  254. llama_cloud/types/parsing_get_params.py +27 -0
  255. llama_cloud/types/parsing_get_response.py +364 -0
  256. llama_cloud/types/parsing_languages.py +94 -0
  257. llama_cloud/types/parsing_list_params.py +23 -0
  258. llama_cloud/types/parsing_list_response.py +33 -0
  259. llama_cloud/types/parsing_mode.py +13 -46
  260. llama_cloud/types/parsing_upload_file_params.py +14 -0
  261. llama_cloud/types/parsing_upload_file_response.py +33 -0
  262. llama_cloud/types/pipeline.py +180 -62
  263. llama_cloud/types/pipeline_create_params.py +95 -0
  264. llama_cloud/types/pipeline_get_status_params.py +12 -0
  265. llama_cloud/types/pipeline_list_params.py +23 -0
  266. llama_cloud/types/pipeline_list_response.py +12 -0
  267. llama_cloud/types/pipeline_metadata_config.py +9 -30
  268. llama_cloud/types/pipeline_metadata_config_param.py +17 -0
  269. llama_cloud/types/pipeline_retrieve_params.py +74 -0
  270. llama_cloud/types/pipeline_retrieve_response.py +63 -0
  271. llama_cloud/types/pipeline_type.py +4 -18
  272. llama_cloud/types/pipeline_update_params.py +90 -0
  273. llama_cloud/types/pipeline_upsert_params.py +95 -0
  274. llama_cloud/types/pipelines/__init__.py +38 -0
  275. llama_cloud/types/pipelines/cloud_document.py +29 -0
  276. llama_cloud/types/pipelines/cloud_document_create_param.py +30 -0
  277. llama_cloud/types/pipelines/data_source_get_data_sources_response.py +10 -0
  278. llama_cloud/types/pipelines/data_source_sync_params.py +16 -0
  279. llama_cloud/types/pipelines/data_source_update_data_sources_params.py +25 -0
  280. llama_cloud/types/pipelines/data_source_update_data_sources_response.py +10 -0
  281. llama_cloud/types/pipelines/data_source_update_params.py +15 -0
  282. llama_cloud/types/pipelines/document_create_params.py +14 -0
  283. llama_cloud/types/pipelines/document_create_response.py +10 -0
  284. llama_cloud/types/pipelines/document_get_chunks_response.py +10 -0
  285. llama_cloud/types/pipelines/document_list_params.py +22 -0
  286. llama_cloud/types/pipelines/document_upsert_params.py +14 -0
  287. llama_cloud/types/pipelines/document_upsert_response.py +10 -0
  288. llama_cloud/types/pipelines/file_create_params.py +22 -0
  289. llama_cloud/types/pipelines/file_create_response.py +10 -0
  290. llama_cloud/types/pipelines/file_get_status_counts_params.py +14 -0
  291. llama_cloud/types/pipelines/file_get_status_counts_response.py +24 -0
  292. llama_cloud/types/pipelines/file_list_params.py +22 -0
  293. llama_cloud/types/pipelines/file_update_params.py +15 -0
  294. llama_cloud/types/pipelines/image_get_page_figure_params.py +18 -0
  295. llama_cloud/types/pipelines/image_get_page_screenshot_params.py +16 -0
  296. llama_cloud/types/pipelines/image_list_page_figures_params.py +14 -0
  297. llama_cloud/types/pipelines/image_list_page_figures_response.py +34 -0
  298. llama_cloud/types/pipelines/image_list_page_screenshots_params.py +14 -0
  299. llama_cloud/types/pipelines/image_list_page_screenshots_response.py +25 -0
  300. llama_cloud/types/pipelines/metadata_create_params.py +13 -0
  301. llama_cloud/types/pipelines/metadata_create_response.py +8 -0
  302. llama_cloud/types/pipelines/pipeline_data_source.py +96 -0
  303. llama_cloud/types/pipelines/pipeline_file.py +70 -0
  304. llama_cloud/types/pipelines/text_node.py +89 -0
  305. llama_cloud/types/preset_retrieval_params.py +61 -49
  306. llama_cloud/types/preset_retrieval_params_param.py +71 -0
  307. llama_cloud/types/presigned_url.py +13 -29
  308. llama_cloud/types/project.py +24 -36
  309. llama_cloud/types/project_get_params.py +12 -0
  310. llama_cloud/types/project_list_params.py +14 -0
  311. llama_cloud/types/project_list_response.py +10 -0
  312. llama_cloud/types/re_rank_config_param.py +18 -0
  313. llama_cloud/types/retrieval_mode.py +4 -26
  314. llama_cloud/types/retriever.py +31 -38
  315. llama_cloud/types/retriever_create_params.py +26 -0
  316. llama_cloud/types/retriever_get_params.py +14 -0
  317. llama_cloud/types/retriever_list_params.py +16 -0
  318. llama_cloud/types/retriever_list_response.py +12 -0
  319. llama_cloud/types/retriever_pipeline.py +26 -34
  320. llama_cloud/types/retriever_pipeline_param.py +28 -0
  321. llama_cloud/types/retriever_search_params.py +38 -0
  322. llama_cloud/types/retriever_update_params.py +19 -0
  323. llama_cloud/types/retriever_upsert_params.py +26 -0
  324. llama_cloud/types/retrievers/__init__.py +5 -0
  325. llama_cloud/types/retrievers/retriever_search_params.py +32 -0
  326. llama_cloud/types/shared/__init__.py +21 -0
  327. llama_cloud/types/shared/cloud_astra_db_vector_store.py +39 -0
  328. llama_cloud/types/shared/cloud_az_storage_blob_data_source.py +34 -0
  329. llama_cloud/types/shared/cloud_azure_ai_search_vector_store.py +30 -0
  330. llama_cloud/types/shared/cloud_box_data_source.py +31 -0
  331. llama_cloud/types/shared/cloud_confluence_data_source.py +53 -0
  332. llama_cloud/types/shared/cloud_jira_data_source.py +30 -0
  333. llama_cloud/types/shared/cloud_jira_data_source_v2.py +49 -0
  334. llama_cloud/types/shared/cloud_milvus_vector_store.py +21 -0
  335. llama_cloud/types/shared/cloud_mongodb_atlas_vector_search.py +36 -0
  336. llama_cloud/types/shared/cloud_notion_page_data_source.py +19 -0
  337. llama_cloud/types/shared/cloud_one_drive_data_source.py +32 -0
  338. llama_cloud/types/shared/cloud_pinecone_vector_store.py +32 -0
  339. llama_cloud/types/shared/cloud_postgres_vector_store.py +35 -0
  340. llama_cloud/types/shared/cloud_qdrant_vector_store.py +35 -0
  341. llama_cloud/types/shared/cloud_s3_data_source.py +28 -0
  342. llama_cloud/types/shared/cloud_sharepoint_data_source.py +55 -0
  343. llama_cloud/types/shared/cloud_slack_data_source.py +31 -0
  344. llama_cloud/types/shared/failure_handling_config.py +16 -0
  345. llama_cloud/types/shared/pg_vector_hnsw_settings.py +27 -0
  346. llama_cloud/types/shared_params/__init__.py +21 -0
  347. llama_cloud/types/shared_params/cloud_astra_db_vector_store.py +42 -0
  348. llama_cloud/types/shared_params/cloud_az_storage_blob_data_source.py +41 -0
  349. llama_cloud/types/shared_params/cloud_azure_ai_search_vector_store.py +34 -0
  350. llama_cloud/types/shared_params/cloud_box_data_source.py +40 -0
  351. llama_cloud/types/shared_params/cloud_confluence_data_source.py +58 -0
  352. llama_cloud/types/shared_params/cloud_jira_data_source.py +34 -0
  353. llama_cloud/types/shared_params/cloud_jira_data_source_v2.py +54 -0
  354. llama_cloud/types/shared_params/cloud_milvus_vector_store.py +24 -0
  355. llama_cloud/types/shared_params/cloud_mongodb_atlas_vector_search.py +39 -0
  356. llama_cloud/types/shared_params/cloud_notion_page_data_source.py +23 -0
  357. llama_cloud/types/shared_params/cloud_one_drive_data_source.py +37 -0
  358. llama_cloud/types/shared_params/cloud_pinecone_vector_store.py +35 -0
  359. llama_cloud/types/shared_params/cloud_postgres_vector_store.py +39 -0
  360. llama_cloud/types/shared_params/cloud_qdrant_vector_store.py +37 -0
  361. llama_cloud/types/shared_params/cloud_s3_data_source.py +32 -0
  362. llama_cloud/types/shared_params/cloud_sharepoint_data_source.py +60 -0
  363. llama_cloud/types/shared_params/cloud_slack_data_source.py +35 -0
  364. llama_cloud/types/shared_params/failure_handling_config.py +16 -0
  365. llama_cloud/types/shared_params/pg_vector_hnsw_settings.py +26 -0
  366. llama_cloud/types/sparse_model_config.py +16 -30
  367. llama_cloud/types/sparse_model_config_param.py +25 -0
  368. llama_cloud/types/status_enum.py +4 -34
  369. llama_cloud/types/vertex_ai_embedding_config.py +10 -27
  370. llama_cloud/types/vertex_ai_embedding_config_param.py +17 -0
  371. llama_cloud/types/vertex_text_embedding.py +47 -45
  372. llama_cloud/types/vertex_text_embedding_param.py +45 -0
  373. llama_cloud-1.0.0b4.dist-info/METADATA +546 -0
  374. llama_cloud-1.0.0b4.dist-info/RECORD +376 -0
  375. {llama_cloud-0.1.41.dist-info → llama_cloud-1.0.0b4.dist-info}/WHEEL +1 -1
  376. llama_cloud-1.0.0b4.dist-info/licenses/LICENSE +7 -0
  377. llama_cloud/client.py +0 -108
  378. llama_cloud/core/__init__.py +0 -17
  379. llama_cloud/core/api_error.py +0 -15
  380. llama_cloud/core/client_wrapper.py +0 -51
  381. llama_cloud/core/datetime_utils.py +0 -28
  382. llama_cloud/core/jsonable_encoder.py +0 -106
  383. llama_cloud/core/remove_none_from_dict.py +0 -11
  384. llama_cloud/environment.py +0 -7
  385. llama_cloud/errors/__init__.py +0 -5
  386. llama_cloud/errors/unprocessable_entity_error.py +0 -9
  387. llama_cloud/resources/admin/__init__.py +0 -2
  388. llama_cloud/resources/admin/client.py +0 -196
  389. llama_cloud/resources/agent_deployments/__init__.py +0 -2
  390. llama_cloud/resources/agent_deployments/client.py +0 -160
  391. llama_cloud/resources/alpha/__init__.py +0 -2
  392. llama_cloud/resources/alpha/client.py +0 -112
  393. llama_cloud/resources/beta/client.py +0 -2664
  394. llama_cloud/resources/chat_apps/__init__.py +0 -2
  395. llama_cloud/resources/chat_apps/client.py +0 -616
  396. llama_cloud/resources/classifier/client.py +0 -444
  397. llama_cloud/resources/data_sinks/__init__.py +0 -5
  398. llama_cloud/resources/data_sinks/client.py +0 -535
  399. llama_cloud/resources/data_sinks/types/__init__.py +0 -5
  400. llama_cloud/resources/data_sinks/types/data_sink_update_component.py +0 -22
  401. llama_cloud/resources/data_sources/__init__.py +0 -5
  402. llama_cloud/resources/data_sources/client.py +0 -548
  403. llama_cloud/resources/data_sources/types/__init__.py +0 -6
  404. llama_cloud/resources/data_sources/types/data_source_update_component.py +0 -28
  405. llama_cloud/resources/data_sources/types/data_source_update_custom_metadata_value.py +0 -7
  406. llama_cloud/resources/embedding_model_configs/__init__.py +0 -23
  407. llama_cloud/resources/embedding_model_configs/client.py +0 -420
  408. llama_cloud/resources/embedding_model_configs/types/__init__.py +0 -23
  409. llama_cloud/resources/embedding_model_configs/types/embedding_model_config_create_embedding_config.py +0 -89
  410. llama_cloud/resources/evals/__init__.py +0 -2
  411. llama_cloud/resources/evals/client.py +0 -85
  412. llama_cloud/resources/files/__init__.py +0 -5
  413. llama_cloud/resources/files/client.py +0 -1454
  414. llama_cloud/resources/files/types/__init__.py +0 -5
  415. llama_cloud/resources/files/types/file_create_from_url_resource_info_value.py +0 -7
  416. llama_cloud/resources/jobs/__init__.py +0 -2
  417. llama_cloud/resources/jobs/client.py +0 -164
  418. llama_cloud/resources/llama_extract/__init__.py +0 -27
  419. llama_cloud/resources/llama_extract/client.py +0 -2082
  420. llama_cloud/resources/llama_extract/types/__init__.py +0 -25
  421. llama_cloud/resources/llama_extract/types/extract_agent_create_data_schema.py +0 -9
  422. llama_cloud/resources/llama_extract/types/extract_agent_create_data_schema_zero_value.py +0 -7
  423. llama_cloud/resources/llama_extract/types/extract_agent_update_data_schema.py +0 -9
  424. llama_cloud/resources/llama_extract/types/extract_agent_update_data_schema_zero_value.py +0 -7
  425. llama_cloud/resources/llama_extract/types/extract_job_create_batch_data_schema_override.py +0 -9
  426. llama_cloud/resources/llama_extract/types/extract_job_create_batch_data_schema_override_zero_value.py +0 -7
  427. llama_cloud/resources/llama_extract/types/extract_schema_validate_request_data_schema.py +0 -9
  428. llama_cloud/resources/llama_extract/types/extract_schema_validate_request_data_schema_zero_value.py +0 -7
  429. llama_cloud/resources/llama_extract/types/extract_stateless_request_data_schema.py +0 -9
  430. llama_cloud/resources/llama_extract/types/extract_stateless_request_data_schema_zero_value.py +0 -7
  431. llama_cloud/resources/organizations/__init__.py +0 -2
  432. llama_cloud/resources/organizations/client.py +0 -1448
  433. llama_cloud/resources/parsing/__init__.py +0 -2
  434. llama_cloud/resources/parsing/client.py +0 -2392
  435. llama_cloud/resources/pipelines/client.py +0 -3436
  436. llama_cloud/resources/pipelines/types/__init__.py +0 -29
  437. llama_cloud/resources/pipelines/types/pipeline_file_update_custom_metadata_value.py +0 -7
  438. llama_cloud/resources/pipelines/types/pipeline_update_embedding_config.py +0 -89
  439. llama_cloud/resources/pipelines/types/pipeline_update_transform_config.py +0 -8
  440. llama_cloud/resources/pipelines/types/retrieval_params_search_filters_inference_schema_value.py +0 -7
  441. llama_cloud/resources/projects/__init__.py +0 -2
  442. llama_cloud/resources/projects/client.py +0 -636
  443. llama_cloud/resources/retrievers/client.py +0 -837
  444. llama_cloud/resources/users/__init__.py +0 -2
  445. llama_cloud/resources/users/client.py +0 -155
  446. llama_cloud/types/advanced_mode_transform_config_chunking_config.py +0 -67
  447. llama_cloud/types/advanced_mode_transform_config_segmentation_config.py +0 -45
  448. llama_cloud/types/agent_data.py +0 -40
  449. llama_cloud/types/agent_deployment_list.py +0 -32
  450. llama_cloud/types/agent_deployment_summary.py +0 -39
  451. llama_cloud/types/aggregate_group.py +0 -37
  452. llama_cloud/types/azure_open_ai_embedding.py +0 -49
  453. llama_cloud/types/azure_open_ai_embedding_config.py +0 -34
  454. llama_cloud/types/base_plan.py +0 -53
  455. llama_cloud/types/base_plan_metronome_plan_type.py +0 -17
  456. llama_cloud/types/base_plan_name.py +0 -57
  457. llama_cloud/types/base_plan_plan_frequency.py +0 -25
  458. llama_cloud/types/batch.py +0 -47
  459. llama_cloud/types/batch_item.py +0 -40
  460. llama_cloud/types/batch_paginated_list.py +0 -35
  461. llama_cloud/types/batch_public_output.py +0 -36
  462. llama_cloud/types/billing_period.py +0 -32
  463. llama_cloud/types/box_auth_mechanism.py +0 -17
  464. llama_cloud/types/character_chunking_config.py +0 -32
  465. llama_cloud/types/chat_app.py +0 -46
  466. llama_cloud/types/chat_app_response.py +0 -43
  467. llama_cloud/types/chat_data.py +0 -35
  468. llama_cloud/types/chat_message.py +0 -43
  469. llama_cloud/types/chunk_mode.py +0 -29
  470. llama_cloud/types/classification_result.py +0 -39
  471. llama_cloud/types/classifier_rule.py +0 -43
  472. llama_cloud/types/classify_job.py +0 -47
  473. llama_cloud/types/classify_job_results.py +0 -38
  474. llama_cloud/types/classify_parsing_configuration.py +0 -38
  475. llama_cloud/types/cloud_astra_db_vector_store.py +0 -51
  476. llama_cloud/types/cloud_az_storage_blob_data_source.py +0 -41
  477. llama_cloud/types/cloud_azure_ai_search_vector_store.py +0 -45
  478. llama_cloud/types/cloud_box_data_source.py +0 -42
  479. llama_cloud/types/cloud_confluence_data_source.py +0 -59
  480. llama_cloud/types/cloud_document.py +0 -40
  481. llama_cloud/types/cloud_document_create.py +0 -40
  482. llama_cloud/types/cloud_jira_data_source.py +0 -42
  483. llama_cloud/types/cloud_jira_data_source_v_2.py +0 -52
  484. llama_cloud/types/cloud_jira_data_source_v_2_api_version.py +0 -21
  485. llama_cloud/types/cloud_milvus_vector_store.py +0 -40
  486. llama_cloud/types/cloud_mongo_db_atlas_vector_search.py +0 -52
  487. llama_cloud/types/cloud_notion_page_data_source.py +0 -35
  488. llama_cloud/types/cloud_one_drive_data_source.py +0 -39
  489. llama_cloud/types/cloud_pinecone_vector_store.py +0 -49
  490. llama_cloud/types/cloud_postgres_vector_store.py +0 -44
  491. llama_cloud/types/cloud_qdrant_vector_store.py +0 -51
  492. llama_cloud/types/cloud_s_3_data_source.py +0 -39
  493. llama_cloud/types/cloud_sharepoint_data_source.py +0 -42
  494. llama_cloud/types/cloud_slack_data_source.py +0 -39
  495. llama_cloud/types/composite_retrieved_text_node.py +0 -42
  496. llama_cloud/types/composite_retrieved_text_node_with_score.py +0 -34
  497. llama_cloud/types/configurable_data_sink_names.py +0 -41
  498. llama_cloud/types/configurable_data_source_names.py +0 -57
  499. llama_cloud/types/credit_type.py +0 -32
  500. llama_cloud/types/data_sink_component.py +0 -22
  501. llama_cloud/types/data_sink_create.py +0 -39
  502. llama_cloud/types/data_sink_create_component.py +0 -22
  503. llama_cloud/types/data_source_component.py +0 -28
  504. llama_cloud/types/data_source_create.py +0 -41
  505. llama_cloud/types/data_source_create_component.py +0 -28
  506. llama_cloud/types/data_source_create_custom_metadata_value.py +0 -7
  507. llama_cloud/types/data_source_custom_metadata_value.py +0 -7
  508. llama_cloud/types/data_source_reader_version_metadata_reader_version.py +0 -25
  509. llama_cloud/types/data_source_update_dispatcher_config.py +0 -38
  510. llama_cloud/types/delete_params.py +0 -39
  511. llama_cloud/types/document_chunk_mode.py +0 -17
  512. llama_cloud/types/document_ingestion_job_params.py +0 -43
  513. llama_cloud/types/element_segmentation_config.py +0 -29
  514. llama_cloud/types/embedding_model_config.py +0 -43
  515. llama_cloud/types/embedding_model_config_embedding_config.py +0 -89
  516. llama_cloud/types/embedding_model_config_update.py +0 -33
  517. llama_cloud/types/embedding_model_config_update_embedding_config.py +0 -89
  518. llama_cloud/types/eval_execution_params.py +0 -41
  519. llama_cloud/types/extract_agent.py +0 -48
  520. llama_cloud/types/extract_agent_data_schema_value.py +0 -5
  521. llama_cloud/types/extract_config.py +0 -66
  522. llama_cloud/types/extract_config_priority.py +0 -29
  523. llama_cloud/types/extract_job.py +0 -38
  524. llama_cloud/types/extract_job_create.py +0 -46
  525. llama_cloud/types/extract_job_create_data_schema_override.py +0 -9
  526. llama_cloud/types/extract_job_create_data_schema_override_zero_value.py +0 -7
  527. llama_cloud/types/extract_job_create_priority.py +0 -29
  528. llama_cloud/types/extract_mode.py +0 -29
  529. llama_cloud/types/extract_models.py +0 -53
  530. llama_cloud/types/extract_resultset.py +0 -42
  531. llama_cloud/types/extract_resultset_data.py +0 -11
  532. llama_cloud/types/extract_resultset_data_item_value.py +0 -7
  533. llama_cloud/types/extract_resultset_data_zero_value.py +0 -7
  534. llama_cloud/types/extract_resultset_extraction_metadata_value.py +0 -7
  535. llama_cloud/types/extract_run.py +0 -55
  536. llama_cloud/types/extract_run_data.py +0 -11
  537. llama_cloud/types/extract_run_data_item_value.py +0 -5
  538. llama_cloud/types/extract_run_data_schema_value.py +0 -5
  539. llama_cloud/types/extract_run_data_zero_value.py +0 -5
  540. llama_cloud/types/extract_run_extraction_metadata_value.py +0 -7
  541. llama_cloud/types/extract_schema_generate_response.py +0 -38
  542. llama_cloud/types/extract_schema_generate_response_data_schema_value.py +0 -7
  543. llama_cloud/types/extract_schema_validate_response.py +0 -32
  544. llama_cloud/types/extract_schema_validate_response_data_schema_value.py +0 -7
  545. llama_cloud/types/extract_state.py +0 -29
  546. llama_cloud/types/extract_target.py +0 -17
  547. llama_cloud/types/failure_handling_config.py +0 -37
  548. llama_cloud/types/file_classification.py +0 -41
  549. llama_cloud/types/file_count_by_status_response.py +0 -37
  550. llama_cloud/types/file_create.py +0 -41
  551. llama_cloud/types/file_create_permission_info_value.py +0 -7
  552. llama_cloud/types/file_create_resource_info_value.py +0 -5
  553. llama_cloud/types/file_data.py +0 -36
  554. llama_cloud/types/file_filter.py +0 -40
  555. llama_cloud/types/file_id_presigned_url.py +0 -38
  556. llama_cloud/types/file_parse_public.py +0 -36
  557. llama_cloud/types/file_permission_info_value.py +0 -5
  558. llama_cloud/types/file_resource_info_value.py +0 -5
  559. llama_cloud/types/file_store_info_response.py +0 -34
  560. llama_cloud/types/file_store_info_response_status.py +0 -25
  561. llama_cloud/types/filter_condition.py +0 -29
  562. llama_cloud/types/filter_operation.py +0 -46
  563. llama_cloud/types/filter_operation_eq.py +0 -6
  564. llama_cloud/types/filter_operation_gt.py +0 -6
  565. llama_cloud/types/filter_operation_gte.py +0 -6
  566. llama_cloud/types/filter_operation_includes_item.py +0 -6
  567. llama_cloud/types/filter_operation_lt.py +0 -6
  568. llama_cloud/types/filter_operation_lte.py +0 -6
  569. llama_cloud/types/filter_operator.py +0 -73
  570. llama_cloud/types/free_credits_usage.py +0 -34
  571. llama_cloud/types/http_validation_error.py +0 -32
  572. llama_cloud/types/hugging_face_inference_api_embedding_token.py +0 -5
  573. llama_cloud/types/ingestion_error_response.py +0 -34
  574. llama_cloud/types/input_message.py +0 -40
  575. llama_cloud/types/job_name_mapping.py +0 -49
  576. llama_cloud/types/job_names.py +0 -81
  577. llama_cloud/types/job_record.py +0 -58
  578. llama_cloud/types/job_record_parameters.py +0 -111
  579. llama_cloud/types/job_record_with_usage_metrics.py +0 -36
  580. llama_cloud/types/l_lama_parse_transform_config.py +0 -37
  581. llama_cloud/types/legacy_parse_job_config.py +0 -207
  582. llama_cloud/types/license_info_response.py +0 -34
  583. llama_cloud/types/llama_extract_feature_availability.py +0 -34
  584. llama_cloud/types/llama_extract_mode_availability.py +0 -38
  585. llama_cloud/types/llama_extract_mode_availability_status.py +0 -17
  586. llama_cloud/types/llama_extract_settings.py +0 -67
  587. llama_cloud/types/llama_parse_parameters_priority.py +0 -29
  588. llama_cloud/types/llm_model_data.py +0 -38
  589. llama_cloud/types/llm_parameters.py +0 -39
  590. llama_cloud/types/load_files_job_config.py +0 -35
  591. llama_cloud/types/managed_ingestion_status.py +0 -41
  592. llama_cloud/types/managed_open_ai_embedding.py +0 -36
  593. llama_cloud/types/managed_open_ai_embedding_config.py +0 -34
  594. llama_cloud/types/message_annotation.py +0 -33
  595. llama_cloud/types/metadata_filter.py +0 -44
  596. llama_cloud/types/metadata_filter_value.py +0 -5
  597. llama_cloud/types/metadata_filters_filters_item.py +0 -8
  598. llama_cloud/types/multimodal_parse_resolution.py +0 -17
  599. llama_cloud/types/node_relationship.py +0 -44
  600. llama_cloud/types/none_chunking_config.py +0 -29
  601. llama_cloud/types/none_segmentation_config.py +0 -29
  602. llama_cloud/types/object_type.py +0 -33
  603. llama_cloud/types/open_ai_embedding.py +0 -47
  604. llama_cloud/types/open_ai_embedding_config.py +0 -34
  605. llama_cloud/types/organization.py +0 -43
  606. llama_cloud/types/organization_create.py +0 -35
  607. llama_cloud/types/page_figure_metadata.py +0 -37
  608. llama_cloud/types/page_screenshot_metadata.py +0 -34
  609. llama_cloud/types/page_segmentation_config.py +0 -31
  610. llama_cloud/types/paginated_extract_runs_response.py +0 -39
  611. llama_cloud/types/paginated_jobs_history_with_metrics.py +0 -35
  612. llama_cloud/types/paginated_list_cloud_documents_response.py +0 -35
  613. llama_cloud/types/paginated_list_pipeline_files_response.py +0 -35
  614. llama_cloud/types/paginated_response_agent_data.py +0 -34
  615. llama_cloud/types/paginated_response_aggregate_group.py +0 -34
  616. llama_cloud/types/paginated_response_classify_job.py +0 -34
  617. llama_cloud/types/paginated_response_quota_configuration.py +0 -36
  618. llama_cloud/types/parse_configuration.py +0 -44
  619. llama_cloud/types/parse_configuration_create.py +0 -41
  620. llama_cloud/types/parse_configuration_filter.py +0 -40
  621. llama_cloud/types/parse_configuration_query_response.py +0 -38
  622. llama_cloud/types/parse_job_config.py +0 -149
  623. llama_cloud/types/parse_job_config_priority.py +0 -29
  624. llama_cloud/types/parse_plan_level.py +0 -21
  625. llama_cloud/types/parser_languages.py +0 -361
  626. llama_cloud/types/parsing_history_item.py +0 -39
  627. llama_cloud/types/parsing_job.py +0 -35
  628. llama_cloud/types/parsing_job_json_result.py +0 -32
  629. llama_cloud/types/parsing_job_markdown_result.py +0 -32
  630. llama_cloud/types/parsing_job_structured_result.py +0 -32
  631. llama_cloud/types/parsing_job_text_result.py +0 -32
  632. llama_cloud/types/partition_names.py +0 -45
  633. llama_cloud/types/permission.py +0 -40
  634. llama_cloud/types/pg_vector_distance_method.py +0 -43
  635. llama_cloud/types/pg_vector_hnsw_settings.py +0 -45
  636. llama_cloud/types/pg_vector_vector_type.py +0 -35
  637. llama_cloud/types/pipeline_configuration_hashes.py +0 -37
  638. llama_cloud/types/pipeline_create.py +0 -65
  639. llama_cloud/types/pipeline_create_embedding_config.py +0 -89
  640. llama_cloud/types/pipeline_create_transform_config.py +0 -8
  641. llama_cloud/types/pipeline_data_source.py +0 -55
  642. llama_cloud/types/pipeline_data_source_component.py +0 -28
  643. llama_cloud/types/pipeline_data_source_create.py +0 -36
  644. llama_cloud/types/pipeline_data_source_custom_metadata_value.py +0 -7
  645. llama_cloud/types/pipeline_data_source_status.py +0 -33
  646. llama_cloud/types/pipeline_deployment.py +0 -37
  647. llama_cloud/types/pipeline_embedding_config.py +0 -100
  648. llama_cloud/types/pipeline_file.py +0 -58
  649. llama_cloud/types/pipeline_file_config_hash_value.py +0 -5
  650. llama_cloud/types/pipeline_file_create.py +0 -37
  651. llama_cloud/types/pipeline_file_create_custom_metadata_value.py +0 -7
  652. llama_cloud/types/pipeline_file_custom_metadata_value.py +0 -7
  653. llama_cloud/types/pipeline_file_permission_info_value.py +0 -7
  654. llama_cloud/types/pipeline_file_resource_info_value.py +0 -7
  655. llama_cloud/types/pipeline_file_status.py +0 -33
  656. llama_cloud/types/pipeline_file_update_dispatcher_config.py +0 -38
  657. llama_cloud/types/pipeline_file_updater_config.py +0 -44
  658. llama_cloud/types/pipeline_managed_ingestion_job_params.py +0 -37
  659. llama_cloud/types/pipeline_status.py +0 -17
  660. llama_cloud/types/pipeline_transform_config.py +0 -31
  661. llama_cloud/types/plan_limits.py +0 -53
  662. llama_cloud/types/playground_session.py +0 -51
  663. llama_cloud/types/pooling.py +0 -29
  664. llama_cloud/types/preset_composite_retrieval_params.py +0 -37
  665. llama_cloud/types/preset_retrieval_params_search_filters_inference_schema_value.py +0 -7
  666. llama_cloud/types/project_create.py +0 -35
  667. llama_cloud/types/prompt_conf.py +0 -38
  668. llama_cloud/types/public_model_name.py +0 -97
  669. llama_cloud/types/quota_configuration.py +0 -53
  670. llama_cloud/types/quota_configuration_configuration_type.py +0 -33
  671. llama_cloud/types/quota_configuration_status.py +0 -21
  672. llama_cloud/types/quota_rate_limit_configuration_value.py +0 -38
  673. llama_cloud/types/quota_rate_limit_configuration_value_denominator_units.py +0 -29
  674. llama_cloud/types/re_rank_config.py +0 -35
  675. llama_cloud/types/re_ranker_type.py +0 -41
  676. llama_cloud/types/recurring_credit_grant.py +0 -44
  677. llama_cloud/types/related_node_info.py +0 -36
  678. llama_cloud/types/related_node_info_node_type.py +0 -7
  679. llama_cloud/types/retrieve_results.py +0 -56
  680. llama_cloud/types/retriever_create.py +0 -37
  681. llama_cloud/types/role.py +0 -40
  682. llama_cloud/types/schema_generation_availability.py +0 -33
  683. llama_cloud/types/schema_generation_availability_status.py +0 -17
  684. llama_cloud/types/schema_relax_mode.py +0 -25
  685. llama_cloud/types/semantic_chunking_config.py +0 -32
  686. llama_cloud/types/sentence_chunking_config.py +0 -34
  687. llama_cloud/types/sparse_model_type.py +0 -33
  688. llama_cloud/types/struct_mode.py +0 -33
  689. llama_cloud/types/struct_parse_conf.py +0 -63
  690. llama_cloud/types/supported_llm_model.py +0 -40
  691. llama_cloud/types/supported_llm_model_names.py +0 -69
  692. llama_cloud/types/text_node.py +0 -67
  693. llama_cloud/types/text_node_relationships_value.py +0 -7
  694. llama_cloud/types/text_node_with_score.py +0 -39
  695. llama_cloud/types/token_chunking_config.py +0 -33
  696. llama_cloud/types/update_user_response.py +0 -33
  697. llama_cloud/types/usage_and_plan.py +0 -34
  698. llama_cloud/types/usage_metric_response.py +0 -34
  699. llama_cloud/types/usage_response.py +0 -43
  700. llama_cloud/types/usage_response_active_alerts_item.py +0 -37
  701. llama_cloud/types/user_job_record.py +0 -32
  702. llama_cloud/types/user_organization.py +0 -47
  703. llama_cloud/types/user_organization_create.py +0 -38
  704. llama_cloud/types/user_organization_delete.py +0 -37
  705. llama_cloud/types/user_organization_role.py +0 -42
  706. llama_cloud/types/user_summary.py +0 -38
  707. llama_cloud/types/validation_error.py +0 -34
  708. llama_cloud/types/validation_error_loc_item.py +0 -5
  709. llama_cloud/types/vertex_embedding_mode.py +0 -38
  710. llama_cloud/types/webhook_configuration.py +0 -39
  711. llama_cloud/types/webhook_configuration_webhook_events_item.py +0 -57
  712. llama_cloud-0.1.41.dist-info/LICENSE +0 -21
  713. llama_cloud-0.1.41.dist-info/METADATA +0 -106
  714. llama_cloud-0.1.41.dist-info/RECORD +0 -385
llama_cloud/_models.py ADDED
@@ -0,0 +1,872 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import inspect
5
+ import weakref
6
+ from typing import (
7
+ IO,
8
+ TYPE_CHECKING,
9
+ Any,
10
+ Type,
11
+ Union,
12
+ Generic,
13
+ TypeVar,
14
+ Callable,
15
+ Iterable,
16
+ Optional,
17
+ AsyncIterable,
18
+ cast,
19
+ )
20
+ from datetime import date, datetime
21
+ from typing_extensions import (
22
+ List,
23
+ Unpack,
24
+ Literal,
25
+ ClassVar,
26
+ Protocol,
27
+ Required,
28
+ ParamSpec,
29
+ TypedDict,
30
+ TypeGuard,
31
+ final,
32
+ override,
33
+ runtime_checkable,
34
+ )
35
+
36
+ import pydantic
37
+ from pydantic.fields import FieldInfo
38
+
39
+ from ._types import (
40
+ Body,
41
+ IncEx,
42
+ Query,
43
+ ModelT,
44
+ Headers,
45
+ Timeout,
46
+ NotGiven,
47
+ AnyMapping,
48
+ HttpxRequestFiles,
49
+ )
50
+ from ._utils import (
51
+ PropertyInfo,
52
+ is_list,
53
+ is_given,
54
+ json_safe,
55
+ lru_cache,
56
+ is_mapping,
57
+ parse_date,
58
+ coerce_boolean,
59
+ parse_datetime,
60
+ strip_not_given,
61
+ extract_type_arg,
62
+ is_annotated_type,
63
+ is_type_alias_type,
64
+ strip_annotated_type,
65
+ )
66
+ from ._compat import (
67
+ PYDANTIC_V1,
68
+ ConfigDict,
69
+ GenericModel as BaseGenericModel,
70
+ get_args,
71
+ is_union,
72
+ parse_obj,
73
+ get_origin,
74
+ is_literal_type,
75
+ get_model_config,
76
+ get_model_fields,
77
+ field_get_default,
78
+ )
79
+ from ._constants import RAW_RESPONSE_HEADER
80
+
81
+ if TYPE_CHECKING:
82
+ from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema
83
+
84
+ __all__ = ["BaseModel", "GenericModel"]
85
+
86
+ _T = TypeVar("_T")
87
+ _BaseModelT = TypeVar("_BaseModelT", bound="BaseModel")
88
+
89
+ P = ParamSpec("P")
90
+
91
+
92
+ @runtime_checkable
93
+ class _ConfigProtocol(Protocol):
94
+ allow_population_by_field_name: bool
95
+
96
+
97
+ class BaseModel(pydantic.BaseModel):
98
+ if PYDANTIC_V1:
99
+
100
+ @property
101
+ @override
102
+ def model_fields_set(self) -> set[str]:
103
+ # a forwards-compat shim for pydantic v2
104
+ return self.__fields_set__ # type: ignore
105
+
106
+ class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
107
+ extra: Any = pydantic.Extra.allow # type: ignore
108
+ else:
109
+ model_config: ClassVar[ConfigDict] = ConfigDict(
110
+ extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true"))
111
+ )
112
+
113
+ def to_dict(
114
+ self,
115
+ *,
116
+ mode: Literal["json", "python"] = "python",
117
+ use_api_names: bool = True,
118
+ exclude_unset: bool = True,
119
+ exclude_defaults: bool = False,
120
+ exclude_none: bool = False,
121
+ warnings: bool = True,
122
+ ) -> dict[str, object]:
123
+ """Recursively generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
124
+
125
+ By default, fields that were not set by the API will not be included,
126
+ and keys will match the API response, *not* the property names from the model.
127
+
128
+ For example, if the API responds with `"fooBar": true` but we've defined a `foo_bar: bool` property,
129
+ the output will use the `"fooBar"` key (unless `use_api_names=False` is passed).
130
+
131
+ Args:
132
+ mode:
133
+ If mode is 'json', the dictionary will only contain JSON serializable types. e.g. `datetime` will be turned into a string, `"2024-3-22T18:11:19.117000Z"`.
134
+ If mode is 'python', the dictionary may contain any Python objects. e.g. `datetime(2024, 3, 22)`
135
+
136
+ use_api_names: Whether to use the key that the API responded with or the property name. Defaults to `True`.
137
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
138
+ exclude_defaults: Whether to exclude fields that are set to their default value from the output.
139
+ exclude_none: Whether to exclude fields that have a value of `None` from the output.
140
+ warnings: Whether to log warnings when invalid fields are encountered. This is only supported in Pydantic v2.
141
+ """
142
+ return self.model_dump(
143
+ mode=mode,
144
+ by_alias=use_api_names,
145
+ exclude_unset=exclude_unset,
146
+ exclude_defaults=exclude_defaults,
147
+ exclude_none=exclude_none,
148
+ warnings=warnings,
149
+ )
150
+
151
+ def to_json(
152
+ self,
153
+ *,
154
+ indent: int | None = 2,
155
+ use_api_names: bool = True,
156
+ exclude_unset: bool = True,
157
+ exclude_defaults: bool = False,
158
+ exclude_none: bool = False,
159
+ warnings: bool = True,
160
+ ) -> str:
161
+ """Generates a JSON string representing this model as it would be received from or sent to the API (but with indentation).
162
+
163
+ By default, fields that were not set by the API will not be included,
164
+ and keys will match the API response, *not* the property names from the model.
165
+
166
+ For example, if the API responds with `"fooBar": true` but we've defined a `foo_bar: bool` property,
167
+ the output will use the `"fooBar"` key (unless `use_api_names=False` is passed).
168
+
169
+ Args:
170
+ indent: Indentation to use in the JSON output. If `None` is passed, the output will be compact. Defaults to `2`
171
+ use_api_names: Whether to use the key that the API responded with or the property name. Defaults to `True`.
172
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
173
+ exclude_defaults: Whether to exclude fields that have the default value.
174
+ exclude_none: Whether to exclude fields that have a value of `None`.
175
+ warnings: Whether to show any warnings that occurred during serialization. This is only supported in Pydantic v2.
176
+ """
177
+ return self.model_dump_json(
178
+ indent=indent,
179
+ by_alias=use_api_names,
180
+ exclude_unset=exclude_unset,
181
+ exclude_defaults=exclude_defaults,
182
+ exclude_none=exclude_none,
183
+ warnings=warnings,
184
+ )
185
+
186
+ @override
187
+ def __str__(self) -> str:
188
+ # mypy complains about an invalid self arg
189
+ return f"{self.__repr_name__()}({self.__repr_str__(', ')})" # type: ignore[misc]
190
+
191
+ # Override the 'construct' method in a way that supports recursive parsing without validation.
192
+ # Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
193
+ @classmethod
194
+ @override
195
+ def construct( # pyright: ignore[reportIncompatibleMethodOverride]
196
+ __cls: Type[ModelT],
197
+ _fields_set: set[str] | None = None,
198
+ **values: object,
199
+ ) -> ModelT:
200
+ m = __cls.__new__(__cls)
201
+ fields_values: dict[str, object] = {}
202
+
203
+ config = get_model_config(__cls)
204
+ populate_by_name = (
205
+ config.allow_population_by_field_name
206
+ if isinstance(config, _ConfigProtocol)
207
+ else config.get("populate_by_name")
208
+ )
209
+
210
+ if _fields_set is None:
211
+ _fields_set = set()
212
+
213
+ model_fields = get_model_fields(__cls)
214
+ for name, field in model_fields.items():
215
+ key = field.alias
216
+ if key is None or (key not in values and populate_by_name):
217
+ key = name
218
+
219
+ if key in values:
220
+ fields_values[name] = _construct_field(value=values[key], field=field, key=key)
221
+ _fields_set.add(name)
222
+ else:
223
+ fields_values[name] = field_get_default(field)
224
+
225
+ extra_field_type = _get_extra_fields_type(__cls)
226
+
227
+ _extra = {}
228
+ for key, value in values.items():
229
+ if key not in model_fields:
230
+ parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
231
+
232
+ if PYDANTIC_V1:
233
+ _fields_set.add(key)
234
+ fields_values[key] = parsed
235
+ else:
236
+ _extra[key] = parsed
237
+
238
+ object.__setattr__(m, "__dict__", fields_values)
239
+
240
+ if PYDANTIC_V1:
241
+ # init_private_attributes() does not exist in v2
242
+ m._init_private_attributes() # type: ignore
243
+
244
+ # copied from Pydantic v1's `construct()` method
245
+ object.__setattr__(m, "__fields_set__", _fields_set)
246
+ else:
247
+ # these properties are copied from Pydantic's `model_construct()` method
248
+ object.__setattr__(m, "__pydantic_private__", None)
249
+ object.__setattr__(m, "__pydantic_extra__", _extra)
250
+ object.__setattr__(m, "__pydantic_fields_set__", _fields_set)
251
+
252
+ return m
253
+
254
+ if not TYPE_CHECKING:
255
+ # type checkers incorrectly complain about this assignment
256
+ # because the type signatures are technically different
257
+ # although not in practice
258
+ model_construct = construct
259
+
260
+ if PYDANTIC_V1:
261
+ # we define aliases for some of the new pydantic v2 methods so
262
+ # that we can just document these methods without having to specify
263
+ # a specific pydantic version as some users may not know which
264
+ # pydantic version they are currently using
265
+
266
+ @override
267
+ def model_dump(
268
+ self,
269
+ *,
270
+ mode: Literal["json", "python"] | str = "python",
271
+ include: IncEx | None = None,
272
+ exclude: IncEx | None = None,
273
+ context: Any | None = None,
274
+ by_alias: bool | None = None,
275
+ exclude_unset: bool = False,
276
+ exclude_defaults: bool = False,
277
+ exclude_none: bool = False,
278
+ exclude_computed_fields: bool = False,
279
+ round_trip: bool = False,
280
+ warnings: bool | Literal["none", "warn", "error"] = True,
281
+ fallback: Callable[[Any], Any] | None = None,
282
+ serialize_as_any: bool = False,
283
+ ) -> dict[str, Any]:
284
+ """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
285
+
286
+ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
287
+
288
+ Args:
289
+ mode: The mode in which `to_python` should run.
290
+ If mode is 'json', the output will only contain JSON serializable types.
291
+ If mode is 'python', the output may contain non-JSON-serializable Python objects.
292
+ include: A set of fields to include in the output.
293
+ exclude: A set of fields to exclude from the output.
294
+ context: Additional context to pass to the serializer.
295
+ by_alias: Whether to use the field's alias in the dictionary key if defined.
296
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
297
+ exclude_defaults: Whether to exclude fields that are set to their default value.
298
+ exclude_none: Whether to exclude fields that have a value of `None`.
299
+ exclude_computed_fields: Whether to exclude computed fields.
300
+ While this can be useful for round-tripping, it is usually recommended to use the dedicated
301
+ `round_trip` parameter instead.
302
+ round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
303
+ warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors,
304
+ "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].
305
+ fallback: A function to call when an unknown value is encountered. If not provided,
306
+ a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.
307
+ serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
308
+
309
+ Returns:
310
+ A dictionary representation of the model.
311
+ """
312
+ if mode not in {"json", "python"}:
313
+ raise ValueError("mode must be either 'json' or 'python'")
314
+ if round_trip != False:
315
+ raise ValueError("round_trip is only supported in Pydantic v2")
316
+ if warnings != True:
317
+ raise ValueError("warnings is only supported in Pydantic v2")
318
+ if context is not None:
319
+ raise ValueError("context is only supported in Pydantic v2")
320
+ if serialize_as_any != False:
321
+ raise ValueError("serialize_as_any is only supported in Pydantic v2")
322
+ if fallback is not None:
323
+ raise ValueError("fallback is only supported in Pydantic v2")
324
+ if exclude_computed_fields != False:
325
+ raise ValueError("exclude_computed_fields is only supported in Pydantic v2")
326
+ dumped = super().dict( # pyright: ignore[reportDeprecated]
327
+ include=include,
328
+ exclude=exclude,
329
+ by_alias=by_alias if by_alias is not None else False,
330
+ exclude_unset=exclude_unset,
331
+ exclude_defaults=exclude_defaults,
332
+ exclude_none=exclude_none,
333
+ )
334
+
335
+ return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped
336
+
337
+ @override
338
+ def model_dump_json(
339
+ self,
340
+ *,
341
+ indent: int | None = None,
342
+ ensure_ascii: bool = False,
343
+ include: IncEx | None = None,
344
+ exclude: IncEx | None = None,
345
+ context: Any | None = None,
346
+ by_alias: bool | None = None,
347
+ exclude_unset: bool = False,
348
+ exclude_defaults: bool = False,
349
+ exclude_none: bool = False,
350
+ exclude_computed_fields: bool = False,
351
+ round_trip: bool = False,
352
+ warnings: bool | Literal["none", "warn", "error"] = True,
353
+ fallback: Callable[[Any], Any] | None = None,
354
+ serialize_as_any: bool = False,
355
+ ) -> str:
356
+ """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
357
+
358
+ Generates a JSON representation of the model using Pydantic's `to_json` method.
359
+
360
+ Args:
361
+ indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
362
+ include: Field(s) to include in the JSON output. Can take either a string or set of strings.
363
+ exclude: Field(s) to exclude from the JSON output. Can take either a string or set of strings.
364
+ by_alias: Whether to serialize using field aliases.
365
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
366
+ exclude_defaults: Whether to exclude fields that have the default value.
367
+ exclude_none: Whether to exclude fields that have a value of `None`.
368
+ round_trip: Whether to use serialization/deserialization between JSON and class instance.
369
+ warnings: Whether to show any warnings that occurred during serialization.
370
+
371
+ Returns:
372
+ A JSON string representation of the model.
373
+ """
374
+ if round_trip != False:
375
+ raise ValueError("round_trip is only supported in Pydantic v2")
376
+ if warnings != True:
377
+ raise ValueError("warnings is only supported in Pydantic v2")
378
+ if context is not None:
379
+ raise ValueError("context is only supported in Pydantic v2")
380
+ if serialize_as_any != False:
381
+ raise ValueError("serialize_as_any is only supported in Pydantic v2")
382
+ if fallback is not None:
383
+ raise ValueError("fallback is only supported in Pydantic v2")
384
+ if ensure_ascii != False:
385
+ raise ValueError("ensure_ascii is only supported in Pydantic v2")
386
+ if exclude_computed_fields != False:
387
+ raise ValueError("exclude_computed_fields is only supported in Pydantic v2")
388
+ return super().json( # type: ignore[reportDeprecated]
389
+ indent=indent,
390
+ include=include,
391
+ exclude=exclude,
392
+ by_alias=by_alias if by_alias is not None else False,
393
+ exclude_unset=exclude_unset,
394
+ exclude_defaults=exclude_defaults,
395
+ exclude_none=exclude_none,
396
+ )
397
+
398
+
399
+ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
400
+ if value is None:
401
+ return field_get_default(field)
402
+
403
+ if PYDANTIC_V1:
404
+ type_ = cast(type, field.outer_type_) # type: ignore
405
+ else:
406
+ type_ = field.annotation # type: ignore
407
+
408
+ if type_ is None:
409
+ raise RuntimeError(f"Unexpected field type is None for {key}")
410
+
411
+ return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
412
+
413
+
414
+ def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
415
+ if PYDANTIC_V1:
416
+ # TODO
417
+ return None
418
+
419
+ schema = cls.__pydantic_core_schema__
420
+ if schema["type"] == "model":
421
+ fields = schema["schema"]
422
+ if fields["type"] == "model-fields":
423
+ extras = fields.get("extras_schema")
424
+ if extras and "cls" in extras:
425
+ # mypy can't narrow the type
426
+ return extras["cls"] # type: ignore[no-any-return]
427
+
428
+ return None
429
+
430
+
431
+ def is_basemodel(type_: type) -> bool:
432
+ """Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
433
+ if is_union(type_):
434
+ for variant in get_args(type_):
435
+ if is_basemodel(variant):
436
+ return True
437
+
438
+ return False
439
+
440
+ return is_basemodel_type(type_)
441
+
442
+
443
+ def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericModel]]:
444
+ origin = get_origin(type_) or type_
445
+ if not inspect.isclass(origin):
446
+ return False
447
+ return issubclass(origin, BaseModel) or issubclass(origin, GenericModel)
448
+
449
+
450
+ def build(
451
+ base_model_cls: Callable[P, _BaseModelT],
452
+ *args: P.args,
453
+ **kwargs: P.kwargs,
454
+ ) -> _BaseModelT:
455
+ """Construct a BaseModel class without validation.
456
+
457
+ This is useful for cases where you need to instantiate a `BaseModel`
458
+ from an API response as this provides type-safe params which isn't supported
459
+ by helpers like `construct_type()`.
460
+
461
+ ```py
462
+ build(MyModel, my_field_a="foo", my_field_b=123)
463
+ ```
464
+ """
465
+ if args:
466
+ raise TypeError(
467
+ "Received positional arguments which are not supported; Keyword arguments must be used instead",
468
+ )
469
+
470
+ return cast(_BaseModelT, construct_type(type_=base_model_cls, value=kwargs))
471
+
472
+
473
+ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:
474
+ """Loose coercion to the expected type with construction of nested values.
475
+
476
+ Note: the returned value from this function is not guaranteed to match the
477
+ given type.
478
+ """
479
+ return cast(_T, construct_type(value=value, type_=type_))
480
+
481
+
482
+ def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object:
483
+ """Loose coercion to the expected type with construction of nested values.
484
+
485
+ If the given value does not match the expected type then it is returned as-is.
486
+ """
487
+
488
+ # store a reference to the original type we were given before we extract any inner
489
+ # types so that we can properly resolve forward references in `TypeAliasType` annotations
490
+ original_type = None
491
+
492
+ # we allow `object` as the input type because otherwise, passing things like
493
+ # `Literal['value']` will be reported as a type error by type checkers
494
+ type_ = cast("type[object]", type_)
495
+ if is_type_alias_type(type_):
496
+ original_type = type_ # type: ignore[unreachable]
497
+ type_ = type_.__value__ # type: ignore[unreachable]
498
+
499
+ # unwrap `Annotated[T, ...]` -> `T`
500
+ if metadata is not None and len(metadata) > 0:
501
+ meta: tuple[Any, ...] = tuple(metadata)
502
+ elif is_annotated_type(type_):
503
+ meta = get_args(type_)[1:]
504
+ type_ = extract_type_arg(type_, 0)
505
+ else:
506
+ meta = tuple()
507
+
508
+ # we need to use the origin class for any types that are subscripted generics
509
+ # e.g. Dict[str, object]
510
+ origin = get_origin(type_) or type_
511
+ args = get_args(type_)
512
+
513
+ if is_union(origin):
514
+ try:
515
+ return validate_type(type_=cast("type[object]", original_type or type_), value=value)
516
+ except Exception:
517
+ pass
518
+
519
+ # if the type is a discriminated union then we want to construct the right variant
520
+ # in the union, even if the data doesn't match exactly, otherwise we'd break code
521
+ # that relies on the constructed class types, e.g.
522
+ #
523
+ # class FooType:
524
+ # kind: Literal['foo']
525
+ # value: str
526
+ #
527
+ # class BarType:
528
+ # kind: Literal['bar']
529
+ # value: int
530
+ #
531
+ # without this block, if the data we get is something like `{'kind': 'bar', 'value': 'foo'}` then
532
+ # we'd end up constructing `FooType` when it should be `BarType`.
533
+ discriminator = _build_discriminated_union_meta(union=type_, meta_annotations=meta)
534
+ if discriminator and is_mapping(value):
535
+ variant_value = value.get(discriminator.field_alias_from or discriminator.field_name)
536
+ if variant_value and isinstance(variant_value, str):
537
+ variant_type = discriminator.mapping.get(variant_value)
538
+ if variant_type:
539
+ return construct_type(type_=variant_type, value=value)
540
+
541
+ # if the data is not valid, use the first variant that doesn't fail while deserializing
542
+ for variant in args:
543
+ try:
544
+ return construct_type(value=value, type_=variant)
545
+ except Exception:
546
+ continue
547
+
548
+ raise RuntimeError(f"Could not convert data into a valid instance of {type_}")
549
+
550
+ if origin == dict:
551
+ if not is_mapping(value):
552
+ return value
553
+
554
+ _, items_type = get_args(type_) # Dict[_, items_type]
555
+ return {key: construct_type(value=item, type_=items_type) for key, item in value.items()}
556
+
557
+ if (
558
+ not is_literal_type(type_)
559
+ and inspect.isclass(origin)
560
+ and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel))
561
+ ):
562
+ if is_list(value):
563
+ return [cast(Any, type_).construct(**entry) if is_mapping(entry) else entry for entry in value]
564
+
565
+ if is_mapping(value):
566
+ if issubclass(type_, BaseModel):
567
+ return type_.construct(**value) # type: ignore[arg-type]
568
+
569
+ return cast(Any, type_).construct(**value)
570
+
571
+ if origin == list:
572
+ if not is_list(value):
573
+ return value
574
+
575
+ inner_type = args[0] # List[inner_type]
576
+ return [construct_type(value=entry, type_=inner_type) for entry in value]
577
+
578
+ if origin == float:
579
+ if isinstance(value, int):
580
+ coerced = float(value)
581
+ if coerced != value:
582
+ return value
583
+ return coerced
584
+
585
+ return value
586
+
587
+ if type_ == datetime:
588
+ try:
589
+ return parse_datetime(value) # type: ignore
590
+ except Exception:
591
+ return value
592
+
593
+ if type_ == date:
594
+ try:
595
+ return parse_date(value) # type: ignore
596
+ except Exception:
597
+ return value
598
+
599
+ return value
600
+
601
+
602
+ @runtime_checkable
603
+ class CachedDiscriminatorType(Protocol):
604
+ __discriminator__: DiscriminatorDetails
605
+
606
+
607
+ DISCRIMINATOR_CACHE: weakref.WeakKeyDictionary[type, DiscriminatorDetails] = weakref.WeakKeyDictionary()
608
+
609
+
610
+ class DiscriminatorDetails:
611
+ field_name: str
612
+ """The name of the discriminator field in the variant class, e.g.
613
+
614
+ ```py
615
+ class Foo(BaseModel):
616
+ type: Literal['foo']
617
+ ```
618
+
619
+ Will result in field_name='type'
620
+ """
621
+
622
+ field_alias_from: str | None
623
+ """The name of the discriminator field in the API response, e.g.
624
+
625
+ ```py
626
+ class Foo(BaseModel):
627
+ type: Literal['foo'] = Field(alias='type_from_api')
628
+ ```
629
+
630
+ Will result in field_alias_from='type_from_api'
631
+ """
632
+
633
+ mapping: dict[str, type]
634
+ """Mapping of discriminator value to variant type, e.g.
635
+
636
+ {'foo': FooVariant, 'bar': BarVariant}
637
+ """
638
+
639
+ def __init__(
640
+ self,
641
+ *,
642
+ mapping: dict[str, type],
643
+ discriminator_field: str,
644
+ discriminator_alias: str | None,
645
+ ) -> None:
646
+ self.mapping = mapping
647
+ self.field_name = discriminator_field
648
+ self.field_alias_from = discriminator_alias
649
+
650
+
651
+ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, ...]) -> DiscriminatorDetails | None:
652
+ cached = DISCRIMINATOR_CACHE.get(union)
653
+ if cached is not None:
654
+ return cached
655
+
656
+ discriminator_field_name: str | None = None
657
+
658
+ for annotation in meta_annotations:
659
+ if isinstance(annotation, PropertyInfo) and annotation.discriminator is not None:
660
+ discriminator_field_name = annotation.discriminator
661
+ break
662
+
663
+ if not discriminator_field_name:
664
+ return None
665
+
666
+ mapping: dict[str, type] = {}
667
+ discriminator_alias: str | None = None
668
+
669
+ for variant in get_args(union):
670
+ variant = strip_annotated_type(variant)
671
+ if is_basemodel_type(variant):
672
+ if PYDANTIC_V1:
673
+ field_info = cast("dict[str, FieldInfo]", variant.__fields__).get(discriminator_field_name) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
674
+ if not field_info:
675
+ continue
676
+
677
+ # Note: if one variant defines an alias then they all should
678
+ discriminator_alias = field_info.alias
679
+
680
+ if (annotation := getattr(field_info, "annotation", None)) and is_literal_type(annotation):
681
+ for entry in get_args(annotation):
682
+ if isinstance(entry, str):
683
+ mapping[entry] = variant
684
+ else:
685
+ field = _extract_field_schema_pv2(variant, discriminator_field_name)
686
+ if not field:
687
+ continue
688
+
689
+ # Note: if one variant defines an alias then they all should
690
+ discriminator_alias = field.get("serialization_alias")
691
+
692
+ field_schema = field["schema"]
693
+
694
+ if field_schema["type"] == "literal":
695
+ for entry in cast("LiteralSchema", field_schema)["expected"]:
696
+ if isinstance(entry, str):
697
+ mapping[entry] = variant
698
+
699
+ if not mapping:
700
+ return None
701
+
702
+ details = DiscriminatorDetails(
703
+ mapping=mapping,
704
+ discriminator_field=discriminator_field_name,
705
+ discriminator_alias=discriminator_alias,
706
+ )
707
+ DISCRIMINATOR_CACHE.setdefault(union, details)
708
+ return details
709
+
710
+
711
+ def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None:
712
+ schema = model.__pydantic_core_schema__
713
+ if schema["type"] == "definitions":
714
+ schema = schema["schema"]
715
+
716
+ if schema["type"] != "model":
717
+ return None
718
+
719
+ schema = cast("ModelSchema", schema)
720
+ fields_schema = schema["schema"]
721
+ if fields_schema["type"] != "model-fields":
722
+ return None
723
+
724
+ fields_schema = cast("ModelFieldsSchema", fields_schema)
725
+ field = fields_schema["fields"].get(field_name)
726
+ if not field:
727
+ return None
728
+
729
+ return cast("ModelField", field) # pyright: ignore[reportUnnecessaryCast]
730
+
731
+
732
+ def validate_type(*, type_: type[_T], value: object) -> _T:
733
+ """Strict validation that the given value matches the expected type"""
734
+ if inspect.isclass(type_) and issubclass(type_, pydantic.BaseModel):
735
+ return cast(_T, parse_obj(type_, value))
736
+
737
+ return cast(_T, _validate_non_model_type(type_=type_, value=value))
738
+
739
+
740
+ def set_pydantic_config(typ: Any, config: pydantic.ConfigDict) -> None:
741
+ """Add a pydantic config for the given type.
742
+
743
+ Note: this is a no-op on Pydantic v1.
744
+ """
745
+ setattr(typ, "__pydantic_config__", config) # noqa: B010
746
+
747
+
748
+ # our use of subclassing here causes weirdness for type checkers,
749
+ # so we just pretend that we don't subclass
750
+ if TYPE_CHECKING:
751
+ GenericModel = BaseModel
752
+ else:
753
+
754
+ class GenericModel(BaseGenericModel, BaseModel):
755
+ pass
756
+
757
+
758
+ if not PYDANTIC_V1:
759
+ from pydantic import TypeAdapter as _TypeAdapter
760
+
761
+ _CachedTypeAdapter = cast("TypeAdapter[object]", lru_cache(maxsize=None)(_TypeAdapter))
762
+
763
+ if TYPE_CHECKING:
764
+ from pydantic import TypeAdapter
765
+ else:
766
+ TypeAdapter = _CachedTypeAdapter
767
+
768
+ def _validate_non_model_type(*, type_: type[_T], value: object) -> _T:
769
+ return TypeAdapter(type_).validate_python(value)
770
+
771
+ elif not TYPE_CHECKING: # TODO: condition is weird
772
+
773
+ class RootModel(GenericModel, Generic[_T]):
774
+ """Used as a placeholder to easily convert runtime types to a Pydantic format
775
+ to provide validation.
776
+
777
+ For example:
778
+ ```py
779
+ validated = RootModel[int](__root__="5").__root__
780
+ # validated: 5
781
+ ```
782
+ """
783
+
784
+ __root__: _T
785
+
786
+ def _validate_non_model_type(*, type_: type[_T], value: object) -> _T:
787
+ model = _create_pydantic_model(type_).validate(value)
788
+ return cast(_T, model.__root__)
789
+
790
+ def _create_pydantic_model(type_: _T) -> Type[RootModel[_T]]:
791
+ return RootModel[type_] # type: ignore
792
+
793
+
794
+ class FinalRequestOptionsInput(TypedDict, total=False):
795
+ method: Required[str]
796
+ url: Required[str]
797
+ params: Query
798
+ headers: Headers
799
+ max_retries: int
800
+ timeout: float | Timeout | None
801
+ files: HttpxRequestFiles | None
802
+ idempotency_key: str
803
+ content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None]
804
+ json_data: Body
805
+ extra_json: AnyMapping
806
+ follow_redirects: bool
807
+
808
+
809
+ @final
810
+ class FinalRequestOptions(pydantic.BaseModel):
811
+ method: str
812
+ url: str
813
+ params: Query = {}
814
+ headers: Union[Headers, NotGiven] = NotGiven()
815
+ max_retries: Union[int, NotGiven] = NotGiven()
816
+ timeout: Union[float, Timeout, None, NotGiven] = NotGiven()
817
+ files: Union[HttpxRequestFiles, None] = None
818
+ idempotency_key: Union[str, None] = None
819
+ post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
820
+ follow_redirects: Union[bool, None] = None
821
+
822
+ content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None
823
+ # It should be noted that we cannot use `json` here as that would override
824
+ # a BaseModel method in an incompatible fashion.
825
+ json_data: Union[Body, None] = None
826
+ extra_json: Union[AnyMapping, None] = None
827
+
828
+ if PYDANTIC_V1:
829
+
830
+ class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
831
+ arbitrary_types_allowed: bool = True
832
+ else:
833
+ model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True)
834
+
835
+ def get_max_retries(self, max_retries: int) -> int:
836
+ if isinstance(self.max_retries, NotGiven):
837
+ return max_retries
838
+ return self.max_retries
839
+
840
+ def _strip_raw_response_header(self) -> None:
841
+ if not is_given(self.headers):
842
+ return
843
+
844
+ if self.headers.get(RAW_RESPONSE_HEADER):
845
+ self.headers = {**self.headers}
846
+ self.headers.pop(RAW_RESPONSE_HEADER)
847
+
848
+ # override the `construct` method so that we can run custom transformations.
849
+ # this is necessary as we don't want to do any actual runtime type checking
850
+ # (which means we can't use validators) but we do want to ensure that `NotGiven`
851
+ # values are not present
852
+ #
853
+ # type ignore required because we're adding explicit types to `**values`
854
+ @classmethod
855
+ def construct( # type: ignore
856
+ cls,
857
+ _fields_set: set[str] | None = None,
858
+ **values: Unpack[FinalRequestOptionsInput],
859
+ ) -> FinalRequestOptions:
860
+ kwargs: dict[str, Any] = {
861
+ # we unconditionally call `strip_not_given` on any value
862
+ # as it will just ignore any non-mapping types
863
+ key: strip_not_given(value)
864
+ for key, value in values.items()
865
+ }
866
+ if PYDANTIC_V1:
867
+ return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated]
868
+ return super().model_construct(_fields_set, **kwargs)
869
+
870
+ if not TYPE_CHECKING:
871
+ # type checkers incorrectly complain about this assignment
872
+ model_construct = construct