langwatch-scenario 0.4.0__py3-none-any.whl → 0.7.1__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 (238) hide show
  1. {langwatch_scenario-0.4.0.dist-info → langwatch_scenario-0.7.1.dist-info}/METADATA +210 -86
  2. langwatch_scenario-0.7.1.dist-info/RECORD +237 -0
  3. scenario/__init__.py +12 -118
  4. scenario/_events/__init__.py +64 -0
  5. scenario/_events/event_bus.py +185 -0
  6. scenario/_events/event_reporter.py +83 -0
  7. scenario/_events/events.py +162 -0
  8. scenario/_events/messages.py +58 -0
  9. scenario/_events/utils.py +97 -0
  10. scenario/_generated/langwatch_api_client/README.md +139 -0
  11. scenario/_generated/langwatch_api_client/lang_watch_api_client/__init__.py +13 -0
  12. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/__init__.py +1 -0
  13. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/__init__.py +1 -0
  14. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/delete_api_annotations_id.py +155 -0
  15. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/delete_api_prompts_by_id.py +218 -0
  16. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/delete_api_scenario_events.py +183 -0
  17. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_annotations.py +136 -0
  18. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_annotations_id.py +155 -0
  19. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_annotations_trace_id.py +160 -0
  20. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_dataset_by_slug_or_id.py +229 -0
  21. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_prompts.py +188 -0
  22. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_prompts_by_id.py +218 -0
  23. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_prompts_by_id_versions.py +218 -0
  24. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/get_api_trace_id.py +155 -0
  25. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/patch_api_annotations_id.py +178 -0
  26. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/post_api_annotations_trace_id.py +178 -0
  27. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/post_api_dataset_by_slug_entries.py +108 -0
  28. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/post_api_prompts.py +187 -0
  29. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/post_api_prompts_by_id_versions.py +241 -0
  30. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/post_api_scenario_events.py +229 -0
  31. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/post_api_trace_id_share.py +155 -0
  32. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/post_api_trace_id_unshare.py +155 -0
  33. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/default/put_api_prompts_by_id.py +241 -0
  34. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/traces/__init__.py +1 -0
  35. scenario/_generated/langwatch_api_client/lang_watch_api_client/api/traces/post_api_trace_search.py +168 -0
  36. scenario/_generated/langwatch_api_client/lang_watch_api_client/client.py +268 -0
  37. scenario/_generated/langwatch_api_client/lang_watch_api_client/errors.py +16 -0
  38. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/__init__.py +455 -0
  39. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/annotation.py +131 -0
  40. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/dataset_post_entries.py +74 -0
  41. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/dataset_post_entries_entries_item.py +44 -0
  42. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_annotations_id_response_200.py +68 -0
  43. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_prompts_by_id_response_200.py +59 -0
  44. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_prompts_by_id_response_400.py +61 -0
  45. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_prompts_by_id_response_400_error.py +8 -0
  46. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_prompts_by_id_response_401.py +61 -0
  47. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_prompts_by_id_response_401_error.py +8 -0
  48. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_prompts_by_id_response_404.py +59 -0
  49. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_prompts_by_id_response_500.py +59 -0
  50. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_scenario_events_response_200.py +81 -0
  51. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_scenario_events_response_400.py +59 -0
  52. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_scenario_events_response_401.py +59 -0
  53. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/delete_api_scenario_events_response_500.py +59 -0
  54. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/error.py +67 -0
  55. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/evaluation.py +164 -0
  56. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/evaluation_timestamps.py +68 -0
  57. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_200.py +75 -0
  58. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_200_data_item.py +109 -0
  59. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_200_data_item_entry.py +44 -0
  60. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_400.py +78 -0
  61. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_401.py +78 -0
  62. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_404.py +78 -0
  63. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_422.py +67 -0
  64. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_dataset_by_slug_or_id_response_500.py +78 -0
  65. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_200.py +172 -0
  66. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_200_messages_item.py +69 -0
  67. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_200_messages_item_role.py +10 -0
  68. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_200_response_format_type_0.py +81 -0
  69. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_200_response_format_type_0_json_schema.py +77 -0
  70. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_200_response_format_type_0_json_schema_schema.py +44 -0
  71. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_200_response_format_type_0_type.py +8 -0
  72. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_400.py +61 -0
  73. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_400_error.py +8 -0
  74. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_401.py +61 -0
  75. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_401_error.py +8 -0
  76. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_404.py +59 -0
  77. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_response_500.py +59 -0
  78. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200.py +155 -0
  79. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data.py +204 -0
  80. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_demonstrations.py +101 -0
  81. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_demonstrations_columns_item.py +79 -0
  82. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_demonstrations_columns_item_type.py +18 -0
  83. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_demonstrations_rows_item.py +59 -0
  84. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_inputs_item.py +71 -0
  85. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_inputs_item_type.py +16 -0
  86. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_messages_item.py +71 -0
  87. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_messages_item_role.py +10 -0
  88. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_outputs_item.py +98 -0
  89. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_outputs_item_json_schema.py +59 -0
  90. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_outputs_item_type.py +11 -0
  91. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_200_config_data_prompting_technique.py +59 -0
  92. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_400.py +61 -0
  93. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_400_error.py +8 -0
  94. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_401.py +61 -0
  95. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_401_error.py +8 -0
  96. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_404.py +59 -0
  97. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_by_id_versions_response_500.py +59 -0
  98. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_200_item.py +172 -0
  99. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_200_item_messages_item.py +69 -0
  100. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_200_item_messages_item_role.py +10 -0
  101. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_200_item_response_format_type_0.py +81 -0
  102. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_200_item_response_format_type_0_json_schema.py +77 -0
  103. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_200_item_response_format_type_0_json_schema_schema.py +44 -0
  104. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_200_item_response_format_type_0_type.py +8 -0
  105. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_400.py +61 -0
  106. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_400_error.py +8 -0
  107. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_401.py +61 -0
  108. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_401_error.py +8 -0
  109. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_prompts_response_500.py +59 -0
  110. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200.py +249 -0
  111. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_error_type_0.py +79 -0
  112. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_evaluations_item.py +152 -0
  113. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_evaluations_item_error.py +79 -0
  114. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_evaluations_item_timestamps.py +68 -0
  115. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_input.py +59 -0
  116. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_metadata.py +68 -0
  117. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_metrics.py +95 -0
  118. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_output.py +59 -0
  119. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item.py +271 -0
  120. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_error_type_0.py +79 -0
  121. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_input.py +90 -0
  122. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_input_value_item.py +69 -0
  123. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_metrics.py +77 -0
  124. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_output.py +89 -0
  125. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_output_value_item.py +68 -0
  126. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_params.py +68 -0
  127. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_spans_item_timestamps.py +95 -0
  128. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/get_api_trace_id_response_200_timestamps.py +77 -0
  129. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/input_.py +68 -0
  130. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/metadata.py +68 -0
  131. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/metrics.py +115 -0
  132. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/output.py +59 -0
  133. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/pagination.py +68 -0
  134. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/patch_api_annotations_id_body.py +77 -0
  135. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/patch_api_annotations_id_response_200.py +68 -0
  136. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_annotations_trace_id_body.py +77 -0
  137. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_body.py +59 -0
  138. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body.py +147 -0
  139. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data.py +207 -0
  140. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_demonstrations.py +106 -0
  141. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_demonstrations_columns_item.py +79 -0
  142. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_demonstrations_columns_item_type.py +18 -0
  143. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_demonstrations_rows_item.py +59 -0
  144. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_inputs_item.py +71 -0
  145. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_inputs_item_type.py +16 -0
  146. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_messages_item.py +71 -0
  147. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_messages_item_role.py +10 -0
  148. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_outputs_item.py +98 -0
  149. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_outputs_item_json_schema.py +59 -0
  150. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_outputs_item_type.py +11 -0
  151. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_body_config_data_prompting_technique.py +59 -0
  152. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200.py +155 -0
  153. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data.py +206 -0
  154. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_demonstrations.py +101 -0
  155. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_demonstrations_columns_item.py +79 -0
  156. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_demonstrations_columns_item_type.py +18 -0
  157. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_demonstrations_rows_item.py +59 -0
  158. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_inputs_item.py +71 -0
  159. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_inputs_item_type.py +16 -0
  160. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_messages_item.py +71 -0
  161. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_messages_item_role.py +10 -0
  162. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_outputs_item.py +98 -0
  163. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_outputs_item_json_schema.py +59 -0
  164. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_outputs_item_type.py +11 -0
  165. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_200_config_data_prompting_technique.py +59 -0
  166. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_400.py +61 -0
  167. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_400_error.py +8 -0
  168. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_401.py +61 -0
  169. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_401_error.py +8 -0
  170. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_404.py +59 -0
  171. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_by_id_versions_response_500.py +59 -0
  172. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_200.py +172 -0
  173. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_200_messages_item.py +69 -0
  174. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_200_messages_item_role.py +10 -0
  175. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_200_response_format_type_0.py +81 -0
  176. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_200_response_format_type_0_json_schema.py +77 -0
  177. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_200_response_format_type_0_json_schema_schema.py +44 -0
  178. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_200_response_format_type_0_type.py +8 -0
  179. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_400.py +61 -0
  180. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_400_error.py +8 -0
  181. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_401.py +61 -0
  182. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_401_error.py +8 -0
  183. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_prompts_response_500.py +59 -0
  184. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_0.py +127 -0
  185. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_0_metadata.py +68 -0
  186. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_1.py +164 -0
  187. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_1_results_type_0.py +98 -0
  188. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_1_results_type_0_verdict.py +10 -0
  189. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_1_status.py +13 -0
  190. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2.py +245 -0
  191. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_0.py +88 -0
  192. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_1.py +88 -0
  193. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2.py +120 -0
  194. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item.py +87 -0
  195. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_2_tool_calls_item_function.py +67 -0
  196. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_3.py +88 -0
  197. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_body_type_2_messages_item_type_4.py +85 -0
  198. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_response_201.py +81 -0
  199. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_response_400.py +59 -0
  200. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_response_401.py +59 -0
  201. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_scenario_events_response_500.py +59 -0
  202. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_trace_id_share_response_200.py +59 -0
  203. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/post_api_trace_id_unshare_response_200.py +59 -0
  204. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_body.py +59 -0
  205. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_response_200.py +75 -0
  206. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_response_400.py +61 -0
  207. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_response_400_error.py +8 -0
  208. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_response_401.py +61 -0
  209. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_response_401_error.py +8 -0
  210. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_response_404.py +59 -0
  211. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/put_api_prompts_by_id_response_500.py +59 -0
  212. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/search_request.py +133 -0
  213. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/search_request_filters.py +51 -0
  214. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/search_response.py +93 -0
  215. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/timestamps.py +77 -0
  216. scenario/_generated/langwatch_api_client/lang_watch_api_client/models/trace.py +225 -0
  217. scenario/_generated/langwatch_api_client/lang_watch_api_client/py.typed +1 -0
  218. scenario/_generated/langwatch_api_client/lang_watch_api_client/types.py +46 -0
  219. scenario/_generated/langwatch_api_client/pyproject.toml +27 -0
  220. scenario/_utils/__init__.py +32 -0
  221. scenario/_utils/ids.py +58 -0
  222. scenario/_utils/message_conversion.py +103 -0
  223. scenario/{utils.py → _utils/utils.py} +21 -110
  224. scenario/agent_adapter.py +8 -4
  225. scenario/cache.py +4 -3
  226. scenario/config.py +7 -5
  227. scenario/judge_agent.py +13 -29
  228. scenario/pytest_plugin.py +6 -51
  229. scenario/scenario_executor.py +372 -215
  230. scenario/scenario_state.py +6 -6
  231. scenario/script.py +9 -9
  232. scenario/types.py +15 -8
  233. scenario/user_simulator_agent.py +4 -11
  234. langwatch_scenario-0.4.0.dist-info/RECORD +0 -18
  235. {langwatch_scenario-0.4.0.dist-info → langwatch_scenario-0.7.1.dist-info}/WHEEL +0 -0
  236. {langwatch_scenario-0.4.0.dist-info → langwatch_scenario-0.7.1.dist-info}/entry_points.txt +0 -0
  237. {langwatch_scenario-0.4.0.dist-info → langwatch_scenario-0.7.1.dist-info}/top_level.txt +0 -0
  238. /scenario/{error_messages.py → _error_messages.py} +0 -0
@@ -0,0 +1,225 @@
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from ..types import UNSET, Unset
8
+
9
+ if TYPE_CHECKING:
10
+ from ..models.evaluation import Evaluation
11
+ from ..models.input_ import Input
12
+ from ..models.metadata import Metadata
13
+ from ..models.metrics import Metrics
14
+ from ..models.output import Output
15
+ from ..models.timestamps import Timestamps
16
+
17
+
18
+ T = TypeVar("T", bound="Trace")
19
+
20
+
21
+ @_attrs_define
22
+ class Trace:
23
+ """
24
+ Attributes:
25
+ trace_id (Union[Unset, str]):
26
+ project_id (Union[Unset, str]):
27
+ timestamps (Union[Unset, Timestamps]):
28
+ input_ (Union[Unset, Input]):
29
+ output (Union[Unset, Output]):
30
+ metadata (Union[Unset, Metadata]):
31
+ metrics (Union[Unset, Metrics]):
32
+ indexing_md5s (Union[Unset, list[str]]):
33
+ error (Union[None, Unset, str]):
34
+ evaluations (Union[Unset, list['Evaluation']]):
35
+ contexts (Union[Unset, list[Any]]):
36
+ """
37
+
38
+ trace_id: Union[Unset, str] = UNSET
39
+ project_id: Union[Unset, str] = UNSET
40
+ timestamps: Union[Unset, "Timestamps"] = UNSET
41
+ input_: Union[Unset, "Input"] = UNSET
42
+ output: Union[Unset, "Output"] = UNSET
43
+ metadata: Union[Unset, "Metadata"] = UNSET
44
+ metrics: Union[Unset, "Metrics"] = UNSET
45
+ indexing_md5s: Union[Unset, list[str]] = UNSET
46
+ error: Union[None, Unset, str] = UNSET
47
+ evaluations: Union[Unset, list["Evaluation"]] = UNSET
48
+ contexts: Union[Unset, list[Any]] = UNSET
49
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
50
+
51
+ def to_dict(self) -> dict[str, Any]:
52
+ trace_id = self.trace_id
53
+
54
+ project_id = self.project_id
55
+
56
+ timestamps: Union[Unset, dict[str, Any]] = UNSET
57
+ if not isinstance(self.timestamps, Unset):
58
+ timestamps = self.timestamps.to_dict()
59
+
60
+ input_: Union[Unset, dict[str, Any]] = UNSET
61
+ if not isinstance(self.input_, Unset):
62
+ input_ = self.input_.to_dict()
63
+
64
+ output: Union[Unset, dict[str, Any]] = UNSET
65
+ if not isinstance(self.output, Unset):
66
+ output = self.output.to_dict()
67
+
68
+ metadata: Union[Unset, dict[str, Any]] = UNSET
69
+ if not isinstance(self.metadata, Unset):
70
+ metadata = self.metadata.to_dict()
71
+
72
+ metrics: Union[Unset, dict[str, Any]] = UNSET
73
+ if not isinstance(self.metrics, Unset):
74
+ metrics = self.metrics.to_dict()
75
+
76
+ indexing_md5s: Union[Unset, list[str]] = UNSET
77
+ if not isinstance(self.indexing_md5s, Unset):
78
+ indexing_md5s = self.indexing_md5s
79
+
80
+ error: Union[None, Unset, str]
81
+ if isinstance(self.error, Unset):
82
+ error = UNSET
83
+ else:
84
+ error = self.error
85
+
86
+ evaluations: Union[Unset, list[dict[str, Any]]] = UNSET
87
+ if not isinstance(self.evaluations, Unset):
88
+ evaluations = []
89
+ for evaluations_item_data in self.evaluations:
90
+ evaluations_item = evaluations_item_data.to_dict()
91
+ evaluations.append(evaluations_item)
92
+
93
+ contexts: Union[Unset, list[Any]] = UNSET
94
+ if not isinstance(self.contexts, Unset):
95
+ contexts = self.contexts
96
+
97
+ field_dict: dict[str, Any] = {}
98
+ field_dict.update(self.additional_properties)
99
+ field_dict.update({})
100
+ if trace_id is not UNSET:
101
+ field_dict["trace_id"] = trace_id
102
+ if project_id is not UNSET:
103
+ field_dict["project_id"] = project_id
104
+ if timestamps is not UNSET:
105
+ field_dict["timestamps"] = timestamps
106
+ if input_ is not UNSET:
107
+ field_dict["input"] = input_
108
+ if output is not UNSET:
109
+ field_dict["output"] = output
110
+ if metadata is not UNSET:
111
+ field_dict["metadata"] = metadata
112
+ if metrics is not UNSET:
113
+ field_dict["metrics"] = metrics
114
+ if indexing_md5s is not UNSET:
115
+ field_dict["indexing_md5s"] = indexing_md5s
116
+ if error is not UNSET:
117
+ field_dict["error"] = error
118
+ if evaluations is not UNSET:
119
+ field_dict["evaluations"] = evaluations
120
+ if contexts is not UNSET:
121
+ field_dict["contexts"] = contexts
122
+
123
+ return field_dict
124
+
125
+ @classmethod
126
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
127
+ from ..models.evaluation import Evaluation
128
+ from ..models.input_ import Input
129
+ from ..models.metadata import Metadata
130
+ from ..models.metrics import Metrics
131
+ from ..models.output import Output
132
+ from ..models.timestamps import Timestamps
133
+
134
+ d = dict(src_dict)
135
+ trace_id = d.pop("trace_id", UNSET)
136
+
137
+ project_id = d.pop("project_id", UNSET)
138
+
139
+ _timestamps = d.pop("timestamps", UNSET)
140
+ timestamps: Union[Unset, Timestamps]
141
+ if isinstance(_timestamps, Unset):
142
+ timestamps = UNSET
143
+ else:
144
+ timestamps = Timestamps.from_dict(_timestamps)
145
+
146
+ _input_ = d.pop("input", UNSET)
147
+ input_: Union[Unset, Input]
148
+ if isinstance(_input_, Unset):
149
+ input_ = UNSET
150
+ else:
151
+ input_ = Input.from_dict(_input_)
152
+
153
+ _output = d.pop("output", UNSET)
154
+ output: Union[Unset, Output]
155
+ if isinstance(_output, Unset):
156
+ output = UNSET
157
+ else:
158
+ output = Output.from_dict(_output)
159
+
160
+ _metadata = d.pop("metadata", UNSET)
161
+ metadata: Union[Unset, Metadata]
162
+ if isinstance(_metadata, Unset):
163
+ metadata = UNSET
164
+ else:
165
+ metadata = Metadata.from_dict(_metadata)
166
+
167
+ _metrics = d.pop("metrics", UNSET)
168
+ metrics: Union[Unset, Metrics]
169
+ if isinstance(_metrics, Unset):
170
+ metrics = UNSET
171
+ else:
172
+ metrics = Metrics.from_dict(_metrics)
173
+
174
+ indexing_md5s = cast(list[str], d.pop("indexing_md5s", UNSET))
175
+
176
+ def _parse_error(data: object) -> Union[None, Unset, str]:
177
+ if data is None:
178
+ return data
179
+ if isinstance(data, Unset):
180
+ return data
181
+ return cast(Union[None, Unset, str], data)
182
+
183
+ error = _parse_error(d.pop("error", UNSET))
184
+
185
+ evaluations = []
186
+ _evaluations = d.pop("evaluations", UNSET)
187
+ for evaluations_item_data in _evaluations or []:
188
+ evaluations_item = Evaluation.from_dict(evaluations_item_data)
189
+
190
+ evaluations.append(evaluations_item)
191
+
192
+ contexts = cast(list[Any], d.pop("contexts", UNSET))
193
+
194
+ trace = cls(
195
+ trace_id=trace_id,
196
+ project_id=project_id,
197
+ timestamps=timestamps,
198
+ input_=input_,
199
+ output=output,
200
+ metadata=metadata,
201
+ metrics=metrics,
202
+ indexing_md5s=indexing_md5s,
203
+ error=error,
204
+ evaluations=evaluations,
205
+ contexts=contexts,
206
+ )
207
+
208
+ trace.additional_properties = d
209
+ return trace
210
+
211
+ @property
212
+ def additional_keys(self) -> list[str]:
213
+ return list(self.additional_properties.keys())
214
+
215
+ def __getitem__(self, key: str) -> Any:
216
+ return self.additional_properties[key]
217
+
218
+ def __setitem__(self, key: str, value: Any) -> None:
219
+ self.additional_properties[key] = value
220
+
221
+ def __delitem__(self, key: str) -> None:
222
+ del self.additional_properties[key]
223
+
224
+ def __contains__(self, key: str) -> bool:
225
+ return key in self.additional_properties
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561
@@ -0,0 +1,46 @@
1
+ """Contains some shared types for properties"""
2
+
3
+ from collections.abc import MutableMapping
4
+ from http import HTTPStatus
5
+ from typing import BinaryIO, Generic, Literal, Optional, TypeVar
6
+
7
+ from attrs import define
8
+
9
+
10
+ class Unset:
11
+ def __bool__(self) -> Literal[False]:
12
+ return False
13
+
14
+
15
+ UNSET: Unset = Unset()
16
+
17
+ FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]]
18
+
19
+
20
+ @define
21
+ class File:
22
+ """Contains information for file uploads"""
23
+
24
+ payload: BinaryIO
25
+ file_name: Optional[str] = None
26
+ mime_type: Optional[str] = None
27
+
28
+ def to_tuple(self) -> FileJsonType:
29
+ """Return a tuple representation that httpx will accept for multipart/form-data"""
30
+ return self.file_name, self.payload, self.mime_type
31
+
32
+
33
+ T = TypeVar("T")
34
+
35
+
36
+ @define
37
+ class Response(Generic[T]):
38
+ """A response from an endpoint"""
39
+
40
+ status_code: HTTPStatus
41
+ content: bytes
42
+ headers: MutableMapping[str, str]
43
+ parsed: Optional[T]
44
+
45
+
46
+ __all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"]
@@ -0,0 +1,27 @@
1
+ [tool.poetry]
2
+ name = "lang-watch-api-client"
3
+ version = "1.0.0"
4
+ description = "A client library for accessing LangWatch API"
5
+ authors = []
6
+ readme = "README.md"
7
+ packages = [
8
+ {include = "lang_watch_api_client"},
9
+ ]
10
+ include = ["CHANGELOG.md", "lang_watch_api_client/py.typed"]
11
+
12
+
13
+ [tool.poetry.dependencies]
14
+ python = "^3.9"
15
+ httpx = ">=0.20.0,<0.29.0"
16
+ attrs = ">=22.2.0"
17
+ python-dateutil = "^2.8.0"
18
+
19
+ [build-system]
20
+ requires = ["poetry-core>=1.0.0"]
21
+ build-backend = "poetry.core.masonry.api"
22
+
23
+ [tool.ruff]
24
+ line-length = 120
25
+
26
+ [tool.ruff.lint]
27
+ select = ["F", "I", "UP"]
@@ -0,0 +1,32 @@
1
+ """
2
+ Utility functions for scenario execution and message handling.
3
+
4
+ This module provides various utility functions used throughout the Scenario framework,
5
+ including message formatting, validation, role reversal, and UI components like spinners
6
+ for better user experience during scenario execution.
7
+ """
8
+
9
+ from .message_conversion import convert_agent_return_types_to_openai_messages
10
+ from .ids import get_or_create_batch_run_id, generate_scenario_run_id
11
+ from .utils import (
12
+ SerializableAndPydanticEncoder,
13
+ SerializableWithStringFallback,
14
+ print_openai_messages,
15
+ show_spinner,
16
+ check_valid_return_type,
17
+ reverse_roles,
18
+ await_if_awaitable,
19
+ )
20
+
21
+ __all__ = [
22
+ "convert_agent_return_types_to_openai_messages",
23
+ "get_or_create_batch_run_id",
24
+ "generate_scenario_run_id",
25
+ "SerializableAndPydanticEncoder",
26
+ "SerializableWithStringFallback",
27
+ "print_openai_messages",
28
+ "show_spinner",
29
+ "check_valid_return_type",
30
+ "reverse_roles",
31
+ "await_if_awaitable",
32
+ ]
scenario/_utils/ids.py ADDED
@@ -0,0 +1,58 @@
1
+ """
2
+ ID generation and management utilities for scenario execution.
3
+
4
+ This module provides functions for generating and managing unique identifiers
5
+ used throughout the scenario execution pipeline, particularly for batch runs
6
+ and scenario tracking.
7
+ """
8
+
9
+ import os
10
+ import uuid
11
+
12
+
13
+ def get_or_create_batch_run_id() -> str:
14
+ """
15
+ Gets or creates a batch run ID for the current scenario execution.
16
+
17
+ The batch run ID is consistent across all scenarios in the same process
18
+ execution, allowing grouping of related scenario runs. This is useful
19
+ for tracking and reporting on batches of scenarios run together.
20
+
21
+ Returns:
22
+ str: A unique batch run ID that persists for the process lifetime
23
+
24
+ Example:
25
+ ```python
26
+ # All scenarios in same process will share this ID
27
+ batch_id = get_or_create_batch_run_id()
28
+ print(f"Running scenario in batch: {batch_id}")
29
+ ```
30
+ """
31
+
32
+ # Check if batch ID already exists in environment
33
+ if not os.environ.get("SCENARIO_BATCH_ID"):
34
+ # Generate new batch ID if not set
35
+ os.environ["SCENARIO_BATCH_ID"] = f"batch-run-{uuid.uuid4()}"
36
+
37
+ return os.environ["SCENARIO_BATCH_ID"]
38
+
39
+
40
+ def generate_scenario_run_id() -> str:
41
+ """
42
+ Generates a unique scenario run ID for a single scenario execution.
43
+
44
+ Each scenario run gets a unique identifier that distinguishes it from
45
+ other runs, even within the same batch. This is used for tracking
46
+ individual scenario executions and correlating events.
47
+
48
+ Returns:
49
+ str: A unique scenario run ID
50
+
51
+ Example:
52
+ ```python
53
+ # Each scenario gets its own unique ID
54
+ scenario_id = generate_scenario_run_id()
55
+ print(f"Running scenario with ID: {scenario_id}")
56
+ ```
57
+ """
58
+ return f"scenario-run-{uuid.uuid4()}"
@@ -0,0 +1,103 @@
1
+ """
2
+ Message conversion utilities for scenario execution.
3
+
4
+ This module provides functions for converting between different message formats
5
+ used in scenario execution, particularly for normalizing agent return types
6
+ to OpenAI-compatible message formats.
7
+ """
8
+
9
+ import json
10
+ from typing import Any, List, Literal, TypeVar, cast
11
+ from pydantic import BaseModel
12
+ from openai.types.chat import ChatCompletionMessageParam
13
+
14
+ from scenario.types import AgentReturnTypes, ScenarioResult
15
+ from scenario._utils.utils import SerializableAndPydanticEncoder
16
+
17
+ T = TypeVar("T")
18
+
19
+
20
+ def convert_agent_return_types_to_openai_messages(
21
+ agent_response: AgentReturnTypes, role: Literal["user", "assistant"]
22
+ ) -> List[ChatCompletionMessageParam]:
23
+ """
24
+ Convert various agent return types to standardized OpenAI message format.
25
+
26
+ This function normalizes different return types from agent adapters into
27
+ a consistent list of OpenAI-compatible messages that can be used throughout
28
+ the scenario execution pipeline.
29
+
30
+ Args:
31
+ agent_response: Response from an agent adapter call
32
+ role: The role to assign to string responses ("user" or "assistant")
33
+
34
+ Returns:
35
+ List of OpenAI-compatible messages
36
+
37
+ Raises:
38
+ ValueError: If agent_response is a ScenarioResult (which should be handled separately)
39
+
40
+ Example:
41
+ ```
42
+ # String response
43
+ messages = convert_agent_return_types_to_openai_messages("Hello", "assistant")
44
+ # Result: [{"role": "assistant", "content": "Hello"}]
45
+
46
+ # Dict response
47
+ response = {"role": "assistant", "content": "Hi", "tool_calls": [...]}
48
+ messages = convert_agent_return_types_to_openai_messages(response, "assistant")
49
+ # Result: [{"role": "assistant", "content": "Hi", "tool_calls": [...]}]
50
+
51
+ # List response
52
+ responses = [
53
+ {"role": "assistant", "content": "Thinking..."},
54
+ {"role": "assistant", "content": "Here's the answer"}
55
+ ]
56
+ messages = convert_agent_return_types_to_openai_messages(responses, "assistant")
57
+ # Result: Same list, validated and normalized
58
+ ```
59
+ """
60
+ if isinstance(agent_response, ScenarioResult):
61
+ raise ValueError(
62
+ "Unexpectedly tried to convert a ScenarioResult to openai messages",
63
+ agent_response.__repr__(),
64
+ )
65
+
66
+ def convert_maybe_object_to_openai_message(
67
+ obj: Any,
68
+ ) -> ChatCompletionMessageParam:
69
+ if isinstance(obj, dict):
70
+ return cast(ChatCompletionMessageParam, obj)
71
+ elif isinstance(obj, BaseModel):
72
+ return cast(
73
+ ChatCompletionMessageParam,
74
+ obj.model_dump(
75
+ exclude_unset=True,
76
+ exclude_none=True,
77
+ exclude_defaults=True,
78
+ warnings=False,
79
+ ),
80
+ )
81
+ else:
82
+ raise ValueError(f"Unexpected agent response type: {type(obj).__name__}")
83
+
84
+ def ensure_dict(
85
+ obj: T,
86
+ ) -> T:
87
+ return json.loads(json.dumps(obj, cls=SerializableAndPydanticEncoder))
88
+
89
+ if isinstance(agent_response, str):
90
+ return [
91
+ (
92
+ {"role": "user", "content": agent_response}
93
+ if role == "user"
94
+ else {"role": "assistant", "content": agent_response}
95
+ )
96
+ ]
97
+ elif isinstance(agent_response, list):
98
+ return [
99
+ ensure_dict(convert_maybe_object_to_openai_message(message))
100
+ for message in agent_response
101
+ ]
102
+ else:
103
+ return [ensure_dict(convert_maybe_object_to_openai_message(agent_response))]