ants-platform-sdk 3.7.0__tar.gz

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 (358) hide show
  1. ants_platform_sdk-3.7.0/LICENSE +21 -0
  2. ants_platform_sdk-3.7.0/PKG-INFO +48 -0
  3. ants_platform_sdk-3.7.0/README.md +22 -0
  4. ants_platform_sdk-3.7.0/ants_platform/__init__.py +52 -0
  5. ants_platform_sdk-3.7.0/ants_platform/_client/attributes.py +360 -0
  6. ants_platform_sdk-3.7.0/ants_platform/_client/client.py +3245 -0
  7. ants_platform_sdk-3.7.0/ants_platform/_client/constants.py +63 -0
  8. ants_platform_sdk-3.7.0/ants_platform/_client/datasets.py +183 -0
  9. ants_platform_sdk-3.7.0/ants_platform/_client/environment_variables.py +140 -0
  10. ants_platform_sdk-3.7.0/ants_platform/_client/get_client.py +134 -0
  11. ants_platform_sdk-3.7.0/ants_platform/_client/observe.py +530 -0
  12. ants_platform_sdk-3.7.0/ants_platform/_client/resource_manager.py +448 -0
  13. ants_platform_sdk-3.7.0/ants_platform/_client/span.py +2042 -0
  14. ants_platform_sdk-3.7.0/ants_platform/_client/span_processor.py +154 -0
  15. ants_platform_sdk-3.7.0/ants_platform/_client/utils.py +60 -0
  16. ants_platform_sdk-3.7.0/ants_platform/_crewai_bootstrap.py +47 -0
  17. ants_platform_sdk-3.7.0/ants_platform/_task_manager/media_manager.py +310 -0
  18. ants_platform_sdk-3.7.0/ants_platform/_task_manager/media_upload_consumer.py +44 -0
  19. ants_platform_sdk-3.7.0/ants_platform/_task_manager/media_upload_queue.py +12 -0
  20. ants_platform_sdk-3.7.0/ants_platform/_task_manager/score_ingestion_consumer.py +180 -0
  21. ants_platform_sdk-3.7.0/ants_platform/_utils/__init__.py +22 -0
  22. ants_platform_sdk-3.7.0/ants_platform/_utils/environment.py +34 -0
  23. ants_platform_sdk-3.7.0/ants_platform/_utils/error_logging.py +48 -0
  24. ants_platform_sdk-3.7.0/ants_platform/_utils/parse_error.py +101 -0
  25. ants_platform_sdk-3.7.0/ants_platform/_utils/prompt_cache.py +191 -0
  26. ants_platform_sdk-3.7.0/ants_platform/_utils/request.py +140 -0
  27. ants_platform_sdk-3.7.0/ants_platform/_utils/serializer.py +190 -0
  28. ants_platform_sdk-3.7.0/ants_platform/api/__init__.py +445 -0
  29. ants_platform_sdk-3.7.0/ants_platform/api/client.py +248 -0
  30. ants_platform_sdk-3.7.0/ants_platform/api/core/__init__.py +30 -0
  31. ants_platform_sdk-3.7.0/ants_platform/api/core/api_error.py +17 -0
  32. ants_platform_sdk-3.7.0/ants_platform/api/core/client_wrapper.py +120 -0
  33. ants_platform_sdk-3.7.0/ants_platform/api/core/datetime_utils.py +30 -0
  34. ants_platform_sdk-3.7.0/ants_platform/api/core/file.py +43 -0
  35. ants_platform_sdk-3.7.0/ants_platform/api/core/http_client.py +550 -0
  36. ants_platform_sdk-3.7.0/ants_platform/api/core/jsonable_encoder.py +108 -0
  37. ants_platform_sdk-3.7.0/ants_platform/api/core/pydantic_utilities.py +28 -0
  38. ants_platform_sdk-3.7.0/ants_platform/api/core/query_encoder.py +39 -0
  39. ants_platform_sdk-3.7.0/ants_platform/api/core/remove_none_from_dict.py +11 -0
  40. ants_platform_sdk-3.7.0/ants_platform/api/core/request_options.py +32 -0
  41. ants_platform_sdk-3.7.0/ants_platform/api/resources/__init__.py +459 -0
  42. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/__init__.py +33 -0
  43. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/client.py +1642 -0
  44. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/__init__.py +35 -0
  45. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/annotation_queue.py +49 -0
  46. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/annotation_queue_assignment_request.py +44 -0
  47. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/annotation_queue_item.py +55 -0
  48. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/annotation_queue_object_type.py +21 -0
  49. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/annotation_queue_status.py +21 -0
  50. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/create_annotation_queue_assignment_response.py +46 -0
  51. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/create_annotation_queue_item_request.py +51 -0
  52. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/create_annotation_queue_request.py +46 -0
  53. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/delete_annotation_queue_assignment_response.py +42 -0
  54. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/delete_annotation_queue_item_response.py +43 -0
  55. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/paginated_annotation_queue_items.py +45 -0
  56. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/paginated_annotation_queues.py +45 -0
  57. ants_platform_sdk-3.7.0/ants_platform/api/resources/annotation_queues/types/update_annotation_queue_item_request.py +43 -0
  58. ants_platform_sdk-3.7.0/ants_platform/api/resources/comments/__init__.py +5 -0
  59. ants_platform_sdk-3.7.0/ants_platform/api/resources/comments/client.py +520 -0
  60. ants_platform_sdk-3.7.0/ants_platform/api/resources/comments/types/__init__.py +7 -0
  61. ants_platform_sdk-3.7.0/ants_platform/api/resources/comments/types/create_comment_request.py +69 -0
  62. ants_platform_sdk-3.7.0/ants_platform/api/resources/comments/types/create_comment_response.py +45 -0
  63. ants_platform_sdk-3.7.0/ants_platform/api/resources/comments/types/get_comments_response.py +45 -0
  64. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/__init__.py +103 -0
  65. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/errors/__init__.py +15 -0
  66. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/errors/access_denied_error.py +10 -0
  67. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/errors/error.py +10 -0
  68. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/errors/method_not_allowed_error.py +10 -0
  69. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/errors/not_found_error.py +10 -0
  70. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/errors/unauthorized_error.py +10 -0
  71. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/__init__.py +83 -0
  72. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/base_score.py +79 -0
  73. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/base_score_v_1.py +73 -0
  74. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/boolean_score.py +53 -0
  75. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/boolean_score_v_1.py +53 -0
  76. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/categorical_score.py +53 -0
  77. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/categorical_score_v_1.py +53 -0
  78. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/comment.py +54 -0
  79. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/comment_object_type.py +29 -0
  80. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/config_category.py +43 -0
  81. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/create_score_value.py +5 -0
  82. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/dataset.py +50 -0
  83. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/dataset_item.py +61 -0
  84. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/dataset_run.py +82 -0
  85. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/dataset_run_item.py +53 -0
  86. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/dataset_run_with_items.py +48 -0
  87. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/dataset_status.py +21 -0
  88. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/map_value.py +10 -0
  89. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/model.py +112 -0
  90. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/model_price.py +42 -0
  91. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/model_usage_unit.py +41 -0
  92. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/numeric_score.py +48 -0
  93. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/numeric_score_v_1.py +48 -0
  94. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/observation.py +164 -0
  95. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/observation_level.py +29 -0
  96. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/observations_view.py +116 -0
  97. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/score.py +207 -0
  98. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/score_config.py +82 -0
  99. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/score_data_type.py +25 -0
  100. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/score_source.py +25 -0
  101. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/score_v_1.py +189 -0
  102. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/session.py +50 -0
  103. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/session_with_traces.py +46 -0
  104. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/trace.py +109 -0
  105. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/trace_with_details.py +68 -0
  106. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/trace_with_full_details.py +70 -0
  107. ants_platform_sdk-3.7.0/ants_platform/api/resources/commons/types/usage.py +84 -0
  108. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_items/__init__.py +13 -0
  109. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_items/client.py +640 -0
  110. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_items/types/__init__.py +11 -0
  111. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_items/types/create_dataset_item_request.py +65 -0
  112. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_items/types/delete_dataset_item_response.py +45 -0
  113. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_items/types/paginated_dataset_items.py +45 -0
  114. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_run_items/__init__.py +5 -0
  115. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_run_items/client.py +366 -0
  116. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_run_items/types/__init__.py +6 -0
  117. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_run_items/types/create_dataset_run_item_request.py +64 -0
  118. ants_platform_sdk-3.7.0/ants_platform/api/resources/dataset_run_items/types/paginated_dataset_run_items.py +45 -0
  119. ants_platform_sdk-3.7.0/ants_platform/api/resources/datasets/__init__.py +15 -0
  120. ants_platform_sdk-3.7.0/ants_platform/api/resources/datasets/client.py +942 -0
  121. ants_platform_sdk-3.7.0/ants_platform/api/resources/datasets/types/__init__.py +13 -0
  122. ants_platform_sdk-3.7.0/ants_platform/api/resources/datasets/types/create_dataset_request.py +44 -0
  123. ants_platform_sdk-3.7.0/ants_platform/api/resources/datasets/types/delete_dataset_run_response.py +42 -0
  124. ants_platform_sdk-3.7.0/ants_platform/api/resources/datasets/types/paginated_dataset_runs.py +45 -0
  125. ants_platform_sdk-3.7.0/ants_platform/api/resources/datasets/types/paginated_datasets.py +45 -0
  126. ants_platform_sdk-3.7.0/ants_platform/api/resources/health/__init__.py +6 -0
  127. ants_platform_sdk-3.7.0/ants_platform/api/resources/health/client.py +154 -0
  128. ants_platform_sdk-3.7.0/ants_platform/api/resources/health/errors/__init__.py +5 -0
  129. ants_platform_sdk-3.7.0/ants_platform/api/resources/health/errors/service_unavailable_error.py +8 -0
  130. ants_platform_sdk-3.7.0/ants_platform/api/resources/health/types/__init__.py +5 -0
  131. ants_platform_sdk-3.7.0/ants_platform/api/resources/health/types/health_response.py +58 -0
  132. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/__init__.py +91 -0
  133. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/client.py +260 -0
  134. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/__init__.py +91 -0
  135. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/base_event.py +55 -0
  136. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/create_event_body.py +45 -0
  137. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/create_event_event.py +46 -0
  138. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/create_generation_body.py +67 -0
  139. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/create_generation_event.py +46 -0
  140. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/create_observation_event.py +46 -0
  141. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/create_span_body.py +47 -0
  142. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/create_span_event.py +46 -0
  143. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/ingestion_error.py +45 -0
  144. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/ingestion_event.py +422 -0
  145. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/ingestion_response.py +45 -0
  146. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/ingestion_success.py +43 -0
  147. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/ingestion_usage.py +8 -0
  148. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/observation_body.py +77 -0
  149. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/observation_type.py +53 -0
  150. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/open_ai_completion_usage_schema.py +54 -0
  151. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/open_ai_response_usage_schema.py +52 -0
  152. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/open_ai_usage.py +56 -0
  153. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/optional_observation_body.py +61 -0
  154. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/score_body.py +88 -0
  155. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/score_event.py +46 -0
  156. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/sdk_log_body.py +42 -0
  157. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/sdk_log_event.py +46 -0
  158. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/trace_body.py +61 -0
  159. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/trace_event.py +46 -0
  160. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/update_event_body.py +45 -0
  161. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/update_generation_body.py +67 -0
  162. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/update_generation_event.py +46 -0
  163. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/update_observation_event.py +46 -0
  164. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/update_span_body.py +47 -0
  165. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/update_span_event.py +46 -0
  166. ants_platform_sdk-3.7.0/ants_platform/api/resources/ingestion/types/usage_details.py +10 -0
  167. ants_platform_sdk-3.7.0/ants_platform/api/resources/llm_connections/__init__.py +15 -0
  168. ants_platform_sdk-3.7.0/ants_platform/api/resources/llm_connections/client.py +340 -0
  169. ants_platform_sdk-3.7.0/ants_platform/api/resources/llm_connections/types/__init__.py +13 -0
  170. ants_platform_sdk-3.7.0/ants_platform/api/resources/llm_connections/types/llm_adapter.py +37 -0
  171. ants_platform_sdk-3.7.0/ants_platform/api/resources/llm_connections/types/llm_connection.py +85 -0
  172. ants_platform_sdk-3.7.0/ants_platform/api/resources/llm_connections/types/paginated_llm_connections.py +45 -0
  173. ants_platform_sdk-3.7.0/ants_platform/api/resources/llm_connections/types/upsert_llm_connection_request.py +88 -0
  174. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/__init__.py +17 -0
  175. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/client.py +505 -0
  176. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/types/__init__.py +15 -0
  177. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/types/get_media_response.py +72 -0
  178. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/types/get_media_upload_url_request.py +71 -0
  179. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/types/get_media_upload_url_response.py +54 -0
  180. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/types/media_content_type.py +133 -0
  181. ants_platform_sdk-3.7.0/ants_platform/api/resources/media/types/patch_media_body.py +66 -0
  182. ants_platform_sdk-3.7.0/ants_platform/api/resources/metrics/__init__.py +5 -0
  183. ants_platform_sdk-3.7.0/ants_platform/api/resources/metrics/client.py +245 -0
  184. ants_platform_sdk-3.7.0/ants_platform/api/resources/metrics/types/__init__.py +5 -0
  185. ants_platform_sdk-3.7.0/ants_platform/api/resources/metrics/types/metrics_response.py +47 -0
  186. ants_platform_sdk-3.7.0/ants_platform/api/resources/models/__init__.py +5 -0
  187. ants_platform_sdk-3.7.0/ants_platform/api/resources/models/client.py +607 -0
  188. ants_platform_sdk-3.7.0/ants_platform/api/resources/models/types/__init__.py +6 -0
  189. ants_platform_sdk-3.7.0/ants_platform/api/resources/models/types/create_model_request.py +100 -0
  190. ants_platform_sdk-3.7.0/ants_platform/api/resources/models/types/paginated_models.py +45 -0
  191. ants_platform_sdk-3.7.0/ants_platform/api/resources/observations/__init__.py +5 -0
  192. ants_platform_sdk-3.7.0/ants_platform/api/resources/observations/client.py +428 -0
  193. ants_platform_sdk-3.7.0/ants_platform/api/resources/observations/types/__init__.py +6 -0
  194. ants_platform_sdk-3.7.0/ants_platform/api/resources/observations/types/observations.py +45 -0
  195. ants_platform_sdk-3.7.0/ants_platform/api/resources/observations/types/observations_views.py +45 -0
  196. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/__init__.py +19 -0
  197. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/client.py +750 -0
  198. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/types/__init__.py +17 -0
  199. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/types/membership_request.py +46 -0
  200. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/types/membership_response.py +48 -0
  201. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/types/membership_role.py +29 -0
  202. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/types/memberships_response.py +43 -0
  203. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/types/organization_project.py +48 -0
  204. ants_platform_sdk-3.7.0/ants_platform/api/resources/organizations/types/organization_projects_response.py +43 -0
  205. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/__init__.py +21 -0
  206. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/client.py +1090 -0
  207. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/__init__.py +19 -0
  208. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/api_key_deletion_response.py +46 -0
  209. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/api_key_list.py +49 -0
  210. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/api_key_response.py +53 -0
  211. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/api_key_summary.py +58 -0
  212. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/project.py +56 -0
  213. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/project_deletion_response.py +43 -0
  214. ants_platform_sdk-3.7.0/ants_platform/api/resources/projects/types/projects.py +43 -0
  215. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompt_version/__init__.py +2 -0
  216. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompt_version/client.py +197 -0
  217. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/__init__.py +43 -0
  218. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/client.py +585 -0
  219. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/__init__.py +43 -0
  220. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/base_prompt.py +69 -0
  221. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/chat_message.py +43 -0
  222. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/chat_message_with_placeholders.py +87 -0
  223. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/chat_prompt.py +46 -0
  224. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/create_chat_prompt_request.py +63 -0
  225. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/create_prompt_request.py +103 -0
  226. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/create_text_prompt_request.py +62 -0
  227. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/placeholder_message.py +42 -0
  228. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/prompt.py +111 -0
  229. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/prompt_meta.py +52 -0
  230. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/prompt_meta_list_response.py +45 -0
  231. ants_platform_sdk-3.7.0/ants_platform/api/resources/prompts/types/text_prompt.py +45 -0
  232. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/__init__.py +41 -0
  233. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/client.py +1042 -0
  234. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/__init__.py +39 -0
  235. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/authentication_scheme.py +48 -0
  236. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/bulk_config.py +46 -0
  237. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/empty_response.py +44 -0
  238. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/filter_config.py +45 -0
  239. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/resource_meta.py +45 -0
  240. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/resource_type.py +55 -0
  241. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/resource_types_response.py +47 -0
  242. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/schema_extension.py +45 -0
  243. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/schema_resource.py +47 -0
  244. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/schemas_response.py +47 -0
  245. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/scim_email.py +44 -0
  246. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/scim_feature_support.py +42 -0
  247. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/scim_name.py +42 -0
  248. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/scim_user.py +52 -0
  249. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/scim_users_list_response.py +49 -0
  250. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/service_provider_config.py +60 -0
  251. ants_platform_sdk-3.7.0/ants_platform/api/resources/scim/types/user_meta.py +48 -0
  252. ants_platform_sdk-3.7.0/ants_platform/api/resources/score/__init__.py +5 -0
  253. ants_platform_sdk-3.7.0/ants_platform/api/resources/score/client.py +322 -0
  254. ants_platform_sdk-3.7.0/ants_platform/api/resources/score/types/__init__.py +6 -0
  255. ants_platform_sdk-3.7.0/ants_platform/api/resources/score/types/create_score_request.py +92 -0
  256. ants_platform_sdk-3.7.0/ants_platform/api/resources/score/types/create_score_response.py +45 -0
  257. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_configs/__init__.py +5 -0
  258. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_configs/client.py +473 -0
  259. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_configs/types/__init__.py +6 -0
  260. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_configs/types/create_score_config_request.py +72 -0
  261. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_configs/types/score_configs.py +45 -0
  262. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/__init__.py +25 -0
  263. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/client.py +463 -0
  264. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/types/__init__.py +25 -0
  265. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/types/get_scores_response.py +45 -0
  266. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/types/get_scores_response_data.py +215 -0
  267. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/types/get_scores_response_data_boolean.py +46 -0
  268. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/types/get_scores_response_data_categorical.py +46 -0
  269. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/types/get_scores_response_data_numeric.py +46 -0
  270. ants_platform_sdk-3.7.0/ants_platform/api/resources/score_v_2/types/get_scores_response_trace_data.py +57 -0
  271. ants_platform_sdk-3.7.0/ants_platform/api/resources/sessions/__init__.py +5 -0
  272. ants_platform_sdk-3.7.0/ants_platform/api/resources/sessions/client.py +367 -0
  273. ants_platform_sdk-3.7.0/ants_platform/api/resources/sessions/types/__init__.py +5 -0
  274. ants_platform_sdk-3.7.0/ants_platform/api/resources/sessions/types/paginated_sessions.py +45 -0
  275. ants_platform_sdk-3.7.0/ants_platform/api/resources/trace/__init__.py +5 -0
  276. ants_platform_sdk-3.7.0/ants_platform/api/resources/trace/client.py +725 -0
  277. ants_platform_sdk-3.7.0/ants_platform/api/resources/trace/types/__init__.py +7 -0
  278. ants_platform_sdk-3.7.0/ants_platform/api/resources/trace/types/delete_trace_response.py +42 -0
  279. ants_platform_sdk-3.7.0/ants_platform/api/resources/trace/types/sort.py +42 -0
  280. ants_platform_sdk-3.7.0/ants_platform/api/resources/trace/types/traces.py +45 -0
  281. ants_platform_sdk-3.7.0/ants_platform/api/resources/utils/__init__.py +5 -0
  282. ants_platform_sdk-3.7.0/ants_platform/api/resources/utils/resources/__init__.py +6 -0
  283. ants_platform_sdk-3.7.0/ants_platform/api/resources/utils/resources/pagination/__init__.py +5 -0
  284. ants_platform_sdk-3.7.0/ants_platform/api/resources/utils/resources/pagination/types/__init__.py +5 -0
  285. ants_platform_sdk-3.7.0/ants_platform/api/resources/utils/resources/pagination/types/meta_response.py +62 -0
  286. ants_platform_sdk-3.7.0/ants_platform/api/tests/utils/test_http_client.py +59 -0
  287. ants_platform_sdk-3.7.0/ants_platform/api/tests/utils/test_query_encoding.py +19 -0
  288. ants_platform_sdk-3.7.0/ants_platform/cli/__init__.py +1 -0
  289. ants_platform_sdk-3.7.0/ants_platform/cli/onboard.py +203 -0
  290. ants_platform_sdk-3.7.0/ants_platform/crewai/__init__.py +3 -0
  291. ants_platform_sdk-3.7.0/ants_platform/crewai/event_listener.py +1132 -0
  292. ants_platform_sdk-3.7.0/ants_platform/guardrails/__init__.py +84 -0
  293. ants_platform_sdk-3.7.0/ants_platform/guardrails/_tracing.py +288 -0
  294. ants_platform_sdk-3.7.0/ants_platform/guardrails/client.py +426 -0
  295. ants_platform_sdk-3.7.0/ants_platform/guardrails/errors.py +51 -0
  296. ants_platform_sdk-3.7.0/ants_platform/guardrails/frameworks.py +158 -0
  297. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/__init__.py +7 -0
  298. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/_guardrail_utils.py +135 -0
  299. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/_tool_calls.py +82 -0
  300. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/anthropic.py +210 -0
  301. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/bedrock.py +212 -0
  302. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/google_genai.py +252 -0
  303. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/openai_provider.py +222 -0
  304. ants_platform_sdk-3.7.0/ants_platform/guardrails/providers/vertex.py +261 -0
  305. ants_platform_sdk-3.7.0/ants_platform/guardrails/tool_rules.py +375 -0
  306. ants_platform_sdk-3.7.0/ants_platform/guardrails/tools.py +425 -0
  307. ants_platform_sdk-3.7.0/ants_platform/guardrails/types.py +82 -0
  308. ants_platform_sdk-3.7.0/ants_platform/langchain/CallbackHandler.py +1381 -0
  309. ants_platform_sdk-3.7.0/ants_platform/langchain/__init__.py +5 -0
  310. ants_platform_sdk-3.7.0/ants_platform/langchain/utils.py +212 -0
  311. ants_platform_sdk-3.7.0/ants_platform/logger.py +28 -0
  312. ants_platform_sdk-3.7.0/ants_platform/media.py +342 -0
  313. ants_platform_sdk-3.7.0/ants_platform/model.py +494 -0
  314. ants_platform_sdk-3.7.0/ants_platform/openai.py +1341 -0
  315. ants_platform_sdk-3.7.0/ants_platform/py.typed +0 -0
  316. ants_platform_sdk-3.7.0/ants_platform/types.py +86 -0
  317. ants_platform_sdk-3.7.0/ants_platform/version.py +3 -0
  318. ants_platform_sdk-3.7.0/ants_platform_crewai.pth +1 -0
  319. ants_platform_sdk-3.7.0/ants_platform_sdk.egg-info/PKG-INFO +48 -0
  320. ants_platform_sdk-3.7.0/ants_platform_sdk.egg-info/SOURCES.txt +356 -0
  321. ants_platform_sdk-3.7.0/ants_platform_sdk.egg-info/dependency_links.txt +1 -0
  322. ants_platform_sdk-3.7.0/ants_platform_sdk.egg-info/entry_points.txt +2 -0
  323. ants_platform_sdk-3.7.0/ants_platform_sdk.egg-info/requires.txt +21 -0
  324. ants_platform_sdk-3.7.0/ants_platform_sdk.egg-info/top_level.txt +1 -0
  325. ants_platform_sdk-3.7.0/pyproject.toml +160 -0
  326. ants_platform_sdk-3.7.0/setup.cfg +4 -0
  327. ants_platform_sdk-3.7.0/setup.py +14 -0
  328. ants_platform_sdk-3.7.0/tests/test_additional_headers_simple.py +183 -0
  329. ants_platform_sdk-3.7.0/tests/test_agent_complete.py +355 -0
  330. ants_platform_sdk-3.7.0/tests/test_core_sdk.py +2022 -0
  331. ants_platform_sdk-3.7.0/tests/test_crewai_event_listener.py +1163 -0
  332. ants_platform_sdk-3.7.0/tests/test_datasets.py +420 -0
  333. ants_platform_sdk-3.7.0/tests/test_decorators.py +1688 -0
  334. ants_platform_sdk-3.7.0/tests/test_deprecation.py +119 -0
  335. ants_platform_sdk-3.7.0/tests/test_error_logging.py +66 -0
  336. ants_platform_sdk-3.7.0/tests/test_error_parsing.py +77 -0
  337. ants_platform_sdk-3.7.0/tests/test_guardrail_frameworks.py +136 -0
  338. ants_platform_sdk-3.7.0/tests/test_guardrail_provider_enforce.py +25 -0
  339. ants_platform_sdk-3.7.0/tests/test_guardrail_provider_utils.py +33 -0
  340. ants_platform_sdk-3.7.0/tests/test_guardrail_redaction.py +373 -0
  341. ants_platform_sdk-3.7.0/tests/test_guardrail_redaction_live.py +95 -0
  342. ants_platform_sdk-3.7.0/tests/test_guardrail_redaction_providers.py +356 -0
  343. ants_platform_sdk-3.7.0/tests/test_guardrail_tool_rules.py +822 -0
  344. ants_platform_sdk-3.7.0/tests/test_guardrail_tools.py +372 -0
  345. ants_platform_sdk-3.7.0/tests/test_guardrail_warning.py +380 -0
  346. ants_platform_sdk-3.7.0/tests/test_json.py +130 -0
  347. ants_platform_sdk-3.7.0/tests/test_langchain.py +1434 -0
  348. ants_platform_sdk-3.7.0/tests/test_langchain_agent_attribution.py +212 -0
  349. ants_platform_sdk-3.7.0/tests/test_langchain_integration.py +984 -0
  350. ants_platform_sdk-3.7.0/tests/test_logger.py +36 -0
  351. ants_platform_sdk-3.7.0/tests/test_media.py +167 -0
  352. ants_platform_sdk-3.7.0/tests/test_openai.py +1515 -0
  353. ants_platform_sdk-3.7.0/tests/test_openai_gateway_join.py +519 -0
  354. ants_platform_sdk-3.7.0/tests/test_otel.py +3061 -0
  355. ants_platform_sdk-3.7.0/tests/test_prompt.py +1412 -0
  356. ants_platform_sdk-3.7.0/tests/test_prompt_atexit.py +119 -0
  357. ants_platform_sdk-3.7.0/tests/test_prompt_compilation.py +852 -0
  358. ants_platform_sdk-3.7.0/tests/test_serializer.py +176 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Finto Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: ants-platform-sdk
3
+ Version: 3.7.0
4
+ Summary: A client library for accessing ants-platform
5
+ License: MIT
6
+ Requires-Python: <4.0,>=3.9
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: httpx<1.0,>=0.15.4
10
+ Requires-Dist: pydantic<3.0,>=1.10.7
11
+ Requires-Dist: backoff>=1.10.0
12
+ Requires-Dist: wrapt<2.0,>=1.14
13
+ Requires-Dist: packaging<26.0,>=23.2
14
+ Requires-Dist: requests<3,>=2
15
+ Requires-Dist: opentelemetry-api<2.0,>=1.33.1
16
+ Requires-Dist: opentelemetry-sdk<2.0,>=1.33.1
17
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0,>=1.33.1
18
+ Requires-Dist: regex>=2023.0.0
19
+ Provides-Extra: openai
20
+ Requires-Dist: openai>=0.27.8; extra == "openai"
21
+ Provides-Extra: langchain
22
+ Requires-Dist: langchain>=0.0.309; extra == "langchain"
23
+ Provides-Extra: crewai
24
+ Requires-Dist: crewai>=0.80.0; (python_version >= "3.10" and python_version < "3.14") and extra == "crewai"
25
+ Dynamic: license-file
26
+
27
+ <div align="center">
28
+ <img src="./static/logo.png" alt="ANTS Platform" width="120">
29
+ <h1>Ants Platform Python SDK</h1>
30
+ </div>
31
+
32
+ [![MIT License](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](https://opensource.org/licenses/MIT)
33
+ [![PyPI Version](https://img.shields.io/pypi/v/ants-platform-sdk.svg?style=flat-square&label=pypi+ants-platform-sdk)](https://pypi.org/project/ants-platform-sdk/)
34
+
35
+ ## Installation
36
+
37
+ > [!IMPORTANT]
38
+ > This is the Ants Platform Python SDK, a custom observability platform built on top of modern LLM infrastructure.
39
+
40
+ ```
41
+ pip install ants-platform-sdk
42
+ ```
43
+
44
+ From 3.7.0 the package is published as `ants-platform-sdk`; the import stays `import ants_platform`. If you used the old `ants-platform` package, remove it first: `pip uninstall ants-platform && pip install ants-platform-sdk`.
45
+
46
+ ## Docs
47
+
48
+ Please see our [docs](https://agenticants.ai/docs) for detailed information on this SDK.
@@ -0,0 +1,22 @@
1
+ <div align="center">
2
+ <img src="./static/logo.png" alt="ANTS Platform" width="120">
3
+ <h1>Ants Platform Python SDK</h1>
4
+ </div>
5
+
6
+ [![MIT License](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](https://opensource.org/licenses/MIT)
7
+ [![PyPI Version](https://img.shields.io/pypi/v/ants-platform-sdk.svg?style=flat-square&label=pypi+ants-platform-sdk)](https://pypi.org/project/ants-platform-sdk/)
8
+
9
+ ## Installation
10
+
11
+ > [!IMPORTANT]
12
+ > This is the Ants Platform Python SDK, a custom observability platform built on top of modern LLM infrastructure.
13
+
14
+ ```
15
+ pip install ants-platform-sdk
16
+ ```
17
+
18
+ From 3.7.0 the package is published as `ants-platform-sdk`; the import stays `import ants_platform`. If you used the old `ants-platform` package, remove it first: `pip uninstall ants-platform && pip install ants-platform-sdk`.
19
+
20
+ ## Docs
21
+
22
+ Please see our [docs](https://agenticants.ai/docs) for detailed information on this SDK.
@@ -0,0 +1,52 @@
1
+ """.. include:: ../README.md"""
2
+
3
+ from ._client import client as _client_module
4
+ from ._client.attributes import AntsPlatformOtelSpanAttributes
5
+ from ._client.constants import ObservationTypeLiteral
6
+ from ._client.get_client import get_client
7
+ from ._client.observe import observe
8
+ from ._client.span import (
9
+ AntsPlatformEvent,
10
+ AntsPlatformGeneration,
11
+ AntsPlatformSpan,
12
+ AntsPlatformAgent,
13
+ AntsPlatformTool,
14
+ AntsPlatformChain,
15
+ AntsPlatformEmbedding,
16
+ AntsPlatformEvaluator,
17
+ AntsPlatformRetriever,
18
+ AntsPlatformGuardrail,
19
+ )
20
+
21
+ AntsPlatform = _client_module.AntsPlatform
22
+
23
+ # Guardrails (available as ants_platform.guardrails or top-level imports)
24
+ from .guardrails import ( # noqa: E402
25
+ AntsGuardrailsClient,
26
+ GuardrailViolationError,
27
+ GuardrailResult,
28
+ Violation,
29
+ )
30
+
31
+ __all__ = [
32
+ "AntsPlatform",
33
+ "get_client",
34
+ "observe",
35
+ "ObservationTypeLiteral",
36
+ "AntsPlatformSpan",
37
+ "AntsPlatformGeneration",
38
+ "AntsPlatformEvent",
39
+ "AntsPlatformOtelSpanAttributes",
40
+ "AntsPlatformAgent",
41
+ "AntsPlatformTool",
42
+ "AntsPlatformChain",
43
+ "AntsPlatformEmbedding",
44
+ "AntsPlatformEvaluator",
45
+ "AntsPlatformRetriever",
46
+ "AntsPlatformGuardrail",
47
+ # Guardrails
48
+ "AntsGuardrailsClient",
49
+ "GuardrailViolationError",
50
+ "GuardrailResult",
51
+ "Violation",
52
+ ]
@@ -0,0 +1,360 @@
1
+ """Span attribute management for AntsPlatform OpenTelemetry integration.
2
+
3
+ This module defines constants and functions for managing OpenTelemetry span attributes
4
+ used by AntsPlatform. It provides a structured approach to creating and manipulating
5
+ attributes for different span types (trace, span, generation) while ensuring consistency.
6
+
7
+ The module includes:
8
+ - Attribute name constants organized by category
9
+ - Functions to create attribute dictionaries for different entity types
10
+ - Utilities for serializing and processing attribute values
11
+ """
12
+
13
+ import hashlib
14
+ import json
15
+ import logging
16
+ import warnings
17
+ from datetime import datetime
18
+ from typing import Any, Dict, List, Literal, Optional, Union
19
+
20
+ from ants_platform._client.constants import (
21
+ ObservationTypeGenerationLike,
22
+ ObservationTypeSpanLike,
23
+ )
24
+
25
+ from ants_platform._utils.serializer import EventSerializer
26
+ from ants_platform.model import PromptClient
27
+ from ants_platform.types import MapValue, SpanLevel
28
+
29
+ # Agent name validation constants
30
+ AGENT_NAME_MAX_LENGTH = 255
31
+
32
+ # Configure logger
33
+ logger = logging.getLogger(__name__)
34
+
35
+
36
+ class AntsPlatformOtelSpanAttributes:
37
+ # AntsPlatform-Trace attributes
38
+ TRACE_NAME = "ants_platform.trace.name"
39
+ TRACE_USER_ID = "user.id"
40
+ TRACE_SESSION_ID = "session.id"
41
+ TRACE_TAGS = "ants_platform.trace.tags"
42
+ TRACE_PUBLIC = "ants_platform.trace.public"
43
+ TRACE_METADATA = "ants_platform.trace.metadata"
44
+ TRACE_INPUT = "ants_platform.trace.input"
45
+ TRACE_OUTPUT = "ants_platform.trace.output"
46
+
47
+ # AntsPlatform-observation attributes
48
+ OBSERVATION_TYPE = "ants_platform.observation.type"
49
+ OBSERVATION_METADATA = "ants_platform.observation.metadata"
50
+ OBSERVATION_LEVEL = "ants_platform.observation.level"
51
+ OBSERVATION_STATUS_MESSAGE = "ants_platform.observation.status_message"
52
+ OBSERVATION_INPUT = "ants_platform.observation.input"
53
+ OBSERVATION_OUTPUT = "ants_platform.observation.output"
54
+
55
+ # AntsPlatform-observation of type Generation attributes
56
+ OBSERVATION_COMPLETION_START_TIME = "ants_platform.observation.completion_start_time"
57
+ OBSERVATION_MODEL = "ants_platform.observation.model.name"
58
+ OBSERVATION_MODEL_PARAMETERS = "ants_platform.observation.model.parameters"
59
+ OBSERVATION_USAGE_DETAILS = "ants_platform.observation.usage_details"
60
+ OBSERVATION_COST_DETAILS = "ants_platform.observation.cost_details"
61
+ OBSERVATION_PROMPT_NAME = "ants_platform.observation.prompt.name"
62
+ OBSERVATION_PROMPT_VERSION = "ants_platform.observation.prompt.version"
63
+
64
+ # General
65
+ ENVIRONMENT = "ants_platform.environment"
66
+ RELEASE = "ants_platform.release"
67
+ VERSION = "ants_platform.version"
68
+
69
+ # Agent identification attributes
70
+ AGENT_ID = "ants_platform.agent.id"
71
+ AGENT_NAME = "ants_platform.agent.name"
72
+ AGENT_DISPLAY_NAME = "ants_platform.agent.display_name"
73
+
74
+ # Internal
75
+ AS_ROOT = "ants_platform.internal.as_root"
76
+
77
+
78
+ def validate_and_normalize_agent_name(agent_name: Optional[str]) -> Optional[str]:
79
+ """Validate and normalize agent_name to lowercase snake_case.
80
+
81
+ Applies the following transformations:
82
+ 1. Strip whitespace
83
+ 2. Convert to lowercase for consistency (Python PEP 8 snake_case convention)
84
+ 3. Validate max length (255 chars), truncate with warning if exceeded
85
+ 4. Convert empty strings to None
86
+
87
+ Args:
88
+ agent_name: Raw agent name string
89
+
90
+ Returns:
91
+ Normalized agent name (lowercase) or None if invalid/empty
92
+
93
+ Examples:
94
+ >>> validate_and_normalize_agent_name("QA_Agent")
95
+ "qa_agent"
96
+ >>> validate_and_normalize_agent_name("qa_agent")
97
+ "qa_agent"
98
+ >>> validate_and_normalize_agent_name(" QA_Agent ")
99
+ "qa_agent"
100
+ >>> validate_and_normalize_agent_name("")
101
+ None
102
+ >>> validate_and_normalize_agent_name("A" * 300) # Truncates to 255 with warning
103
+ "aaa..."
104
+ """
105
+ if agent_name is None:
106
+ return None
107
+
108
+ # Strip whitespace
109
+ agent_name = agent_name.strip()
110
+
111
+ # Convert empty strings to None
112
+ if not agent_name:
113
+ return None
114
+
115
+ # Normalize to lowercase for consistency (Python PEP 8 snake_case convention)
116
+ agent_name = agent_name.lower()
117
+
118
+ # Validate max length and truncate if needed
119
+ if len(agent_name) > AGENT_NAME_MAX_LENGTH:
120
+ original_length = len(agent_name)
121
+ agent_name = agent_name[:AGENT_NAME_MAX_LENGTH]
122
+ warning_message = (
123
+ f"agent_name exceeds maximum length of {AGENT_NAME_MAX_LENGTH} characters "
124
+ f"(was {original_length} chars). Truncated to: '{agent_name}'"
125
+ )
126
+ warnings.warn(warning_message, UserWarning, stacklevel=3)
127
+
128
+ return agent_name
129
+
130
+
131
+ def generate_agent_id(agent_name: str, project_id: str) -> str:
132
+ """Generate a stable 16-character hexadecimal agent_id from agent_name and project_id using BLAKE2b-128.
133
+
134
+ The agent_id is a deterministic hash of both agent_name and project_id, ensuring:
135
+ 1. Same agent_name in same project = same agent_id (deterministic)
136
+ 2. Same agent_name in different projects = different agent_id (project-scoped)
137
+ 3. Transfer-safe: projectId doesn't change, so agent_id stays stable
138
+
139
+ Args:
140
+ agent_name: Normalized agent name (should be already validated and normalized)
141
+ project_id: The project ID this agent belongs to
142
+
143
+ Returns:
144
+ str: 16 lowercase hexadecimal characters (64 bits)
145
+
146
+ Examples:
147
+ >>> generate_agent_id("qa_agent", "project-123")
148
+ "a1b2c3d4e5f6g7h8"
149
+ >>> generate_agent_id("qa_agent", "project-123") # Same = same output
150
+ "a1b2c3d4e5f6g7h8"
151
+ >>> generate_agent_id("qa_agent", "project-456") # Different project
152
+ "x9y8z7w6v5u4t3s2"
153
+
154
+ Note:
155
+ Uses BLAKE2b with 8-byte digest (64 bits) to produce 16 hex characters.
156
+ BLAKE2b is faster than SHA-256 and designed for exactly this use case.
157
+ """
158
+ # Validate inputs
159
+ if not agent_name or not isinstance(agent_name, str):
160
+ raise ValueError("agent_name must be a non-empty string")
161
+
162
+ if not project_id or not isinstance(project_id, str):
163
+ raise ValueError("project_id must be a non-empty string")
164
+
165
+ # Use BLAKE2b with 8-byte digest (64 bits = 16 hex characters)
166
+ # Hash both agent_name and project_id for project-scoped agent IDs
167
+ hasher = hashlib.blake2b(digest_size=8)
168
+ hasher.update(agent_name.encode('utf-8'))
169
+ hasher.update(project_id.encode('utf-8'))
170
+ agent_id = hasher.hexdigest()
171
+
172
+ logger.info(f"[AGENT_ID] Generated: {agent_id} from agent_name: {agent_name}")
173
+
174
+ return agent_id
175
+
176
+
177
+ def create_trace_attributes(
178
+ *,
179
+ name: Optional[str] = None,
180
+ user_id: Optional[str] = None,
181
+ session_id: Optional[str] = None,
182
+ agent_name: Optional[str] = None,
183
+ agent_display_name: Optional[str] = None,
184
+ agent_id: Optional[str] = None,
185
+ project_id: Optional[str] = None,
186
+ version: Optional[str] = None,
187
+ release: Optional[str] = None,
188
+ input: Optional[Any] = None,
189
+ output: Optional[Any] = None,
190
+ metadata: Optional[Any] = None,
191
+ tags: Optional[List[str]] = None,
192
+ public: Optional[bool] = None,
193
+ ) -> dict:
194
+ """Create trace attributes with agent identification.
195
+
196
+ Agent Identity Flow:
197
+ - agent_name (immutable): Stable identifier used for agent_id generation
198
+ - agent_display_name (mutable): Optional user-facing name stored in PostgreSQL
199
+ - agent_id: Auto-generated 16-char hex hash of agent_name + project_id using BLAKE2b-64
200
+
201
+ If only agent_name is provided, it serves as both identifier and display name.
202
+ """
203
+ # Validate and normalize agent_name
204
+ agent_name = validate_and_normalize_agent_name(agent_name)
205
+
206
+ # Generate agent_id from agent_name if agent_name exists but agent_id doesn't
207
+ # Note: This is a fallback; agent_id should be generated in span.py with project_id
208
+ if agent_name and not agent_id:
209
+ if not project_id:
210
+ raise ValueError(
211
+ "project_id is required for agent_id generation. "
212
+ "This is an internal error - agent_id should be generated in span.py."
213
+ )
214
+ agent_id = generate_agent_id(agent_name, project_id)
215
+ logger.info(f"[AGENT_ID] Auto-generated for trace: agent_id={agent_id}, agent_name={agent_name}, project_id={project_id}, agent_display_name={agent_display_name}")
216
+
217
+ attributes = {
218
+ AntsPlatformOtelSpanAttributes.TRACE_NAME: name,
219
+ AntsPlatformOtelSpanAttributes.TRACE_USER_ID: user_id,
220
+ AntsPlatformOtelSpanAttributes.TRACE_SESSION_ID: session_id,
221
+ AntsPlatformOtelSpanAttributes.AGENT_NAME: agent_name,
222
+ AntsPlatformOtelSpanAttributes.AGENT_ID: agent_id,
223
+ AntsPlatformOtelSpanAttributes.AGENT_DISPLAY_NAME: agent_display_name,
224
+ AntsPlatformOtelSpanAttributes.VERSION: version,
225
+ AntsPlatformOtelSpanAttributes.RELEASE: release,
226
+ AntsPlatformOtelSpanAttributes.TRACE_INPUT: _serialize(input),
227
+ AntsPlatformOtelSpanAttributes.TRACE_OUTPUT: _serialize(output),
228
+ AntsPlatformOtelSpanAttributes.TRACE_TAGS: tags,
229
+ AntsPlatformOtelSpanAttributes.TRACE_PUBLIC: public,
230
+ **_flatten_and_serialize_metadata(metadata, "trace"),
231
+ }
232
+
233
+ return {k: v for k, v in attributes.items() if v is not None}
234
+
235
+
236
+ def create_span_attributes(
237
+ *,
238
+ metadata: Optional[Any] = None,
239
+ input: Optional[Any] = None,
240
+ output: Optional[Any] = None,
241
+ level: Optional[SpanLevel] = None,
242
+ status_message: Optional[str] = None,
243
+ version: Optional[str] = None,
244
+ agent_name: Optional[str] = None,
245
+ agent_display_name: Optional[str] = None,
246
+ agent_id: Optional[str] = None,
247
+ observation_type: Optional[
248
+ Union[ObservationTypeSpanLike, Literal["event"]]
249
+ ] = "span",
250
+ ) -> dict:
251
+ # Validate and normalize agent_name
252
+ agent_name = validate_and_normalize_agent_name(agent_name)
253
+
254
+ # Note: agent_id should always be provided by span.py when agent_name is provided
255
+ # This function does NOT generate agent_id - that happens in span.py with project_id
256
+ # If agent_name exists but agent_id doesn't, it's an internal error that should be caught in span.py
257
+
258
+ attributes = {
259
+ AntsPlatformOtelSpanAttributes.OBSERVATION_TYPE: observation_type,
260
+ AntsPlatformOtelSpanAttributes.OBSERVATION_LEVEL: level,
261
+ AntsPlatformOtelSpanAttributes.OBSERVATION_STATUS_MESSAGE: status_message,
262
+ AntsPlatformOtelSpanAttributes.VERSION: version,
263
+ AntsPlatformOtelSpanAttributes.AGENT_NAME: agent_name,
264
+ AntsPlatformOtelSpanAttributes.AGENT_ID: agent_id,
265
+ AntsPlatformOtelSpanAttributes.AGENT_DISPLAY_NAME: agent_display_name,
266
+ AntsPlatformOtelSpanAttributes.OBSERVATION_INPUT: _serialize(input),
267
+ AntsPlatformOtelSpanAttributes.OBSERVATION_OUTPUT: _serialize(output),
268
+ **_flatten_and_serialize_metadata(metadata, "observation"),
269
+ }
270
+
271
+ return {k: v for k, v in attributes.items() if v is not None}
272
+
273
+
274
+ def create_generation_attributes(
275
+ *,
276
+ name: Optional[str] = None,
277
+ completion_start_time: Optional[datetime] = None,
278
+ metadata: Optional[Any] = None,
279
+ level: Optional[SpanLevel] = None,
280
+ status_message: Optional[str] = None,
281
+ version: Optional[str] = None,
282
+ agent_name: Optional[str] = None,
283
+ agent_display_name: Optional[str] = None,
284
+ agent_id: Optional[str] = None,
285
+ model: Optional[str] = None,
286
+ model_parameters: Optional[Dict[str, MapValue]] = None,
287
+ input: Optional[Any] = None,
288
+ output: Optional[Any] = None,
289
+ usage_details: Optional[Dict[str, int]] = None,
290
+ cost_details: Optional[Dict[str, float]] = None,
291
+ prompt: Optional[PromptClient] = None,
292
+ observation_type: Optional[ObservationTypeGenerationLike] = "generation",
293
+ ) -> dict:
294
+ # Validate and normalize agent_name
295
+ agent_name = validate_and_normalize_agent_name(agent_name)
296
+
297
+ # Note: agent_id should always be provided by span.py when agent_name is provided
298
+ # This function does NOT generate agent_id - that happens in span.py with project_id
299
+ # If agent_name exists but agent_id doesn't, it's an internal error that should be caught in span.py
300
+
301
+ attributes = {
302
+ AntsPlatformOtelSpanAttributes.OBSERVATION_TYPE: observation_type,
303
+ AntsPlatformOtelSpanAttributes.OBSERVATION_LEVEL: level,
304
+ AntsPlatformOtelSpanAttributes.OBSERVATION_STATUS_MESSAGE: status_message,
305
+ AntsPlatformOtelSpanAttributes.VERSION: version,
306
+ AntsPlatformOtelSpanAttributes.AGENT_NAME: agent_name,
307
+ AntsPlatformOtelSpanAttributes.AGENT_ID: agent_id,
308
+ AntsPlatformOtelSpanAttributes.AGENT_DISPLAY_NAME: agent_display_name,
309
+ AntsPlatformOtelSpanAttributes.OBSERVATION_INPUT: _serialize(input),
310
+ AntsPlatformOtelSpanAttributes.OBSERVATION_OUTPUT: _serialize(output),
311
+ AntsPlatformOtelSpanAttributes.OBSERVATION_MODEL: model,
312
+ AntsPlatformOtelSpanAttributes.OBSERVATION_PROMPT_NAME: prompt.name
313
+ if prompt and not prompt.is_fallback
314
+ else None,
315
+ AntsPlatformOtelSpanAttributes.OBSERVATION_PROMPT_VERSION: prompt.version
316
+ if prompt and not prompt.is_fallback
317
+ else None,
318
+ AntsPlatformOtelSpanAttributes.OBSERVATION_USAGE_DETAILS: _serialize(usage_details),
319
+ AntsPlatformOtelSpanAttributes.OBSERVATION_COST_DETAILS: _serialize(cost_details),
320
+ AntsPlatformOtelSpanAttributes.OBSERVATION_COMPLETION_START_TIME: _serialize(
321
+ completion_start_time
322
+ ),
323
+ AntsPlatformOtelSpanAttributes.OBSERVATION_MODEL_PARAMETERS: _serialize(
324
+ model_parameters
325
+ ),
326
+ **_flatten_and_serialize_metadata(metadata, "observation"),
327
+ }
328
+
329
+ return {k: v for k, v in attributes.items() if v is not None}
330
+
331
+
332
+ def _serialize(obj: Any) -> Optional[str]:
333
+ if obj is None or isinstance(obj, str):
334
+ return obj
335
+
336
+ return json.dumps(obj, cls=EventSerializer)
337
+
338
+
339
+ def _flatten_and_serialize_metadata(
340
+ metadata: Any, type: Literal["observation", "trace"]
341
+ ) -> dict:
342
+ prefix = (
343
+ AntsPlatformOtelSpanAttributes.OBSERVATION_METADATA
344
+ if type == "observation"
345
+ else AntsPlatformOtelSpanAttributes.TRACE_METADATA
346
+ )
347
+
348
+ metadata_attributes: Dict[str, Union[str, int, None]] = {}
349
+
350
+ if not isinstance(metadata, dict):
351
+ metadata_attributes[prefix] = _serialize(metadata)
352
+ else:
353
+ for key, value in metadata.items():
354
+ metadata_attributes[f"{prefix}.{key}"] = (
355
+ value
356
+ if isinstance(value, str) or isinstance(value, int)
357
+ else _serialize(value)
358
+ )
359
+
360
+ return metadata_attributes