moda-openai 0.1.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 (224) hide show
  1. moda_openai-0.1.0/.gitignore +185 -0
  2. moda_openai-0.1.0/.python-version +1 -0
  3. moda_openai-0.1.0/PKG-INFO +49 -0
  4. moda_openai-0.1.0/README.md +33 -0
  5. moda_openai-0.1.0/opentelemetry/instrumentation/openai/__init__.py +54 -0
  6. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/__init__.py +399 -0
  7. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +1208 -0
  8. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +292 -0
  9. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/config.py +15 -0
  10. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +311 -0
  11. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/event_emitter.py +108 -0
  12. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/event_models.py +41 -0
  13. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +68 -0
  14. moda_openai-0.1.0/opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
  15. moda_openai-0.1.0/opentelemetry/instrumentation/openai/utils.py +190 -0
  16. moda_openai-0.1.0/opentelemetry/instrumentation/openai/v0/__init__.py +176 -0
  17. moda_openai-0.1.0/opentelemetry/instrumentation/openai/v1/__init__.py +374 -0
  18. moda_openai-0.1.0/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +329 -0
  19. moda_openai-0.1.0/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +134 -0
  20. moda_openai-0.1.0/opentelemetry/instrumentation/openai/v1/realtime_wrappers.py +730 -0
  21. moda_openai-0.1.0/opentelemetry/instrumentation/openai/v1/responses_wrappers.py +1113 -0
  22. moda_openai-0.1.0/opentelemetry/instrumentation/openai/version.py +1 -0
  23. moda_openai-0.1.0/poetry.toml +2 -0
  24. moda_openai-0.1.0/project.json +77 -0
  25. moda_openai-0.1.0/pyproject.toml +73 -0
  26. moda_openai-0.1.0/pytest.ini +2 -0
  27. moda_openai-0.1.0/tests/__init__.py +1 -0
  28. moda_openai-0.1.0/tests/conftest.py +199 -0
  29. moda_openai-0.1.0/tests/data/1024+tokens.txt +104 -0
  30. moda_openai-0.1.0/tests/metrics/__init__.py +0 -0
  31. moda_openai-0.1.0/tests/metrics/cassettes/test_openai_metrics/test_chat_completion_metrics.yaml +216 -0
  32. moda_openai-0.1.0/tests/metrics/cassettes/test_openai_metrics/test_chat_completion_metrics_stream.yaml +196 -0
  33. moda_openai-0.1.0/tests/metrics/cassettes/test_openai_metrics/test_chat_parsed_completion_metrics.yaml +115 -0
  34. moda_openai-0.1.0/tests/metrics/cassettes/test_openai_metrics/test_chat_streaming_metrics.yaml +402 -0
  35. moda_openai-0.1.0/tests/metrics/cassettes/test_openai_metrics/test_embeddings_metrics.yaml +399 -0
  36. moda_openai-0.1.0/tests/metrics/cassettes/test_openai_metrics/test_image_gen_metrics.yaml +87 -0
  37. moda_openai-0.1.0/tests/metrics/conftest.py +9 -0
  38. moda_openai-0.1.0/tests/metrics/test_openai_metrics.py +311 -0
  39. moda_openai-0.1.0/tests/traces/__init__.py +0 -0
  40. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_existing_assistant.yaml +1806 -0
  41. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_existing_assistant_with_events_with_content.yaml +1806 -0
  42. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_existing_assistant_with_events_with_no_content.yaml +1806 -0
  43. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_new_assistant.yaml +872 -0
  44. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_new_assistant_with_events_with_content.yaml +872 -0
  45. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_new_assistant_with_events_with_no_content.yaml +872 -0
  46. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_new_assistant_with_polling.yaml +1322 -0
  47. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_new_assistant_with_polling_with_events_with_content.yaml +1322 -0
  48. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_new_assistant_with_polling_with_events_with_no_content.yaml +1322 -0
  49. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_streaming_existing_assistant.yaml +840 -0
  50. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_streaming_existing_assistant_with_events_with_content.yaml +840 -0
  51. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_streaming_existing_assistant_with_events_with_no_content.yaml +840 -0
  52. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_streaming_new_assistant.yaml +1711 -0
  53. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_streaming_new_assistant_with_events_with_content.yaml +1711 -0
  54. moda_openai-0.1.0/tests/traces/cassettes/test_assistant/test_streaming_new_assistant_with_events_with_no_content.yaml +1711 -0
  55. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat.yaml +81 -0
  56. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_async_streaming.yaml +190 -0
  57. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_async_streaming_with_events_with_content.yaml +190 -0
  58. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_async_streaming_with_events_with_no_content.yaml +190 -0
  59. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_content_filtering.yaml +79 -0
  60. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_content_filtering_with_events_with_content.yaml +79 -0
  61. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_content_filtering_with_events_with_no_content.yaml +79 -0
  62. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_reasoning.yaml +81 -0
  63. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_streaming.yaml +177 -0
  64. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_streaming_with_events_with_content.yaml +177 -0
  65. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_streaming_with_events_with_no_content.yaml +177 -0
  66. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_with_events_with_content.yaml +81 -0
  67. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_chat_with_events_with_no_content.yaml +81 -0
  68. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_prompt_content_filtering.yaml +109 -0
  69. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_prompt_content_filtering_with_events_with_content.yaml +109 -0
  70. moda_openai-0.1.0/tests/traces/cassettes/test_azure/test_prompt_content_filtering_with_events_with_no_content.yaml +109 -0
  71. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat.yaml +102 -0
  72. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_async_context_propagation.yaml +57 -0
  73. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_async_context_propagation_with_events_with_content.yaml +57 -0
  74. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_async_context_propagation_with_events_with_no_content.yaml +57 -0
  75. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_async_streaming.yaml +192 -0
  76. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_async_streaming_with_events_with_content.yaml +192 -0
  77. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_async_streaming_with_events_with_no_content.yaml +192 -0
  78. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_context_propagation.yaml +57 -0
  79. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_context_propagation_with_events_with_content.yaml +57 -0
  80. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_context_propagation_with_events_with_no_content.yaml +57 -0
  81. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_history_message_dict.yaml +212 -0
  82. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_history_message_pydantic.yaml +212 -0
  83. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_pydantic_based_tool_calls.yaml +99 -0
  84. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_pydantic_based_tool_calls_with_events_with_content.yaml +99 -0
  85. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_pydantic_based_tool_calls_with_events_with_no_content.yaml +99 -0
  86. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_reasoning.yaml +106 -0
  87. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_streaming.yaml +256 -0
  88. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_streaming_exception_during_consumption.yaml +188 -0
  89. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_streaming_memory_leak_prevention.yaml +188 -0
  90. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_streaming_not_consumed.yaml +188 -0
  91. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_streaming_partial_consumption.yaml +188 -0
  92. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_streaming_with_events_with_content.yaml +188 -0
  93. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_streaming_with_events_with_no_content.yaml +188 -0
  94. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tool_calls.yaml +97 -0
  95. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tool_calls_with_events_with_content.yaml +97 -0
  96. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tool_calls_with_events_with_no_content.yaml +97 -0
  97. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools.yaml +101 -0
  98. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_async_streaming.yaml +119 -0
  99. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_async_streaming_with_events_with_content.yaml +119 -0
  100. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_async_streaming_with_events_with_no_content.yaml +119 -0
  101. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_streaming.yaml +119 -0
  102. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_streaming_with_events_with_content.yaml +119 -0
  103. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_streaming_with_events_with_no_content.yaml +119 -0
  104. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_with_events_with_content.yaml +101 -0
  105. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_tools_with_events_with_no_content.yaml +101 -0
  106. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_with_events_with_content.yaml +102 -0
  107. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_with_events_with_no_content.yaml +102 -0
  108. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_chat_with_service_tier.yaml +113 -0
  109. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_with_asyncio_run.yaml +103 -0
  110. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_with_asyncio_run_with_events_with_content.yaml +103 -0
  111. moda_openai-0.1.0/tests/traces/cassettes/test_chat/test_with_asyncio_run_with_events_with_no_content.yaml +103 -0
  112. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_async_parsed_completion.yaml +102 -0
  113. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_async_parsed_completion_with_events_with_content.yaml +102 -0
  114. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_async_parsed_completion_with_events_with_no_content.yaml +102 -0
  115. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_async_parsed_refused_completion.yaml +102 -0
  116. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_async_parsed_refused_completion_with_events_with_content.yaml +102 -0
  117. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_async_parsed_refused_completion_with_events_with_no_content.yaml +102 -0
  118. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_parsed_completion.yaml +102 -0
  119. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_parsed_completion_with_events_with_content.yaml +102 -0
  120. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_parsed_completion_with_events_with_no_content.yaml +102 -0
  121. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_parsed_refused_completion.yaml +102 -0
  122. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_parsed_refused_completion_with_events_with_content.yaml +102 -0
  123. moda_openai-0.1.0/tests/traces/cassettes/test_chat_parse/test_parsed_refused_completion_with_events_with_no_content.yaml +102 -0
  124. moda_openai-0.1.0/tests/traces/cassettes/test_chat_response_format/test_async_chat_response_format.yaml +114 -0
  125. moda_openai-0.1.0/tests/traces/cassettes/test_chat_response_format/test_chat_response_format.yaml +114 -0
  126. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion.yaml +100 -0
  127. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_context_propagation.yaml +56 -0
  128. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_context_propagation_with_events_with_content.yaml +56 -0
  129. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_context_propagation_with_events_with_no_content.yaml +56 -0
  130. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_streaming.yaml +121 -0
  131. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_streaming_with_events_with_content.yaml +121 -0
  132. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_streaming_with_events_with_no_content.yaml +121 -0
  133. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_with_events_with_content.yaml +100 -0
  134. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_async_completion_with_events_with_no_content.yaml +100 -0
  135. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion.yaml +99 -0
  136. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_context_propagation.yaml +56 -0
  137. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_context_propagation_with_events_with_content.yaml +56 -0
  138. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_context_propagation_with_events_with_no_content.yaml +56 -0
  139. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_langchain_style.yaml +100 -0
  140. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_langchain_style_with_events_with_content.yaml +100 -0
  141. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_langchain_style_with_events_with_no_content.yaml +100 -0
  142. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_streaming.yaml +493 -0
  143. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_streaming_with_events_with_content.yaml +155 -0
  144. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_streaming_with_events_with_no_content.yaml +155 -0
  145. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_with_events_with_content.yaml +99 -0
  146. moda_openai-0.1.0/tests/traces/cassettes/test_completions/test_completion_with_events_with_no_content.yaml +99 -0
  147. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_async_embeddings_context_propagation.yaml +55 -0
  148. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_async_embeddings_context_propagation_with_events_with_content.yaml +55 -0
  149. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_async_embeddings_context_propagation_with_events_with_no_content.yaml +55 -0
  150. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_azure_openai_embeddings.yaml +146 -0
  151. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_azure_openai_embeddings_with_events_with_content.yaml +146 -0
  152. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_azure_openai_embeddings_with_events_with_no_content.yaml +146 -0
  153. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings.yaml +399 -0
  154. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_context_propagation.yaml +55 -0
  155. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_context_propagation_with_events_with_content.yaml +55 -0
  156. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_context_propagation_with_events_with_no_content.yaml +55 -0
  157. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_with_events_with_content.yaml +399 -0
  158. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_with_events_with_no_content.yaml +399 -0
  159. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_with_raw_response.yaml +403 -0
  160. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_with_raw_response_with_events_with_content.yaml +403 -0
  161. moda_openai-0.1.0/tests/traces/cassettes/test_embeddings/test_embeddings_with_raw_response_with_events_with_no_content.yaml +403 -0
  162. moda_openai-0.1.0/tests/traces/cassettes/test_exceptions/test_exception_in_instrumentation_suppressed.yaml +102 -0
  163. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls.yaml +207 -0
  164. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools.yaml +108 -0
  165. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_parallel.yaml +102 -0
  166. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_parallel_with_events_with_content.yaml +102 -0
  167. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_parallel_with_events_with_no_content.yaml +102 -0
  168. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_streaming.yaml +126 -0
  169. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_streaming_parallel.yaml +142 -0
  170. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_streaming_parallel_with_events_with_content.yaml +142 -0
  171. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_streaming_parallel_with_events_with_no_content.yaml +142 -0
  172. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_streaming_with_events_with_content.yaml +126 -0
  173. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_streaming_with_events_with_no_content.yaml +126 -0
  174. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_with_events_with_content.yaml +108 -0
  175. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_tools_with_events_with_no_content.yaml +108 -0
  176. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_with_events_with_content.yaml +207 -0
  177. moda_openai-0.1.0/tests/traces/cassettes/test_functions/test_open_ai_function_calls_with_events_with_no_content.yaml +207 -0
  178. moda_openai-0.1.0/tests/traces/cassettes/test_prompt_caching/test_openai_prompt_caching.yaml +397 -0
  179. moda_openai-0.1.0/tests/traces/cassettes/test_prompt_caching/test_openai_prompt_caching_async.yaml +393 -0
  180. moda_openai-0.1.0/tests/traces/cassettes/test_prompt_caching/test_openai_prompt_caching_async_with_events_with_content.yaml +393 -0
  181. moda_openai-0.1.0/tests/traces/cassettes/test_prompt_caching/test_openai_prompt_caching_async_with_events_with_no_content.yaml +393 -0
  182. moda_openai-0.1.0/tests/traces/cassettes/test_prompt_caching/test_openai_prompt_caching_with_events_with_content.yaml +397 -0
  183. moda_openai-0.1.0/tests/traces/cassettes/test_prompt_caching/test_openai_prompt_caching_with_events_with_no_content.yaml +397 -0
  184. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses.yaml +104 -0
  185. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_reasoning.yaml +107 -0
  186. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_reasoning_dict_issue.yaml +136 -0
  187. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_streaming.yaml +255 -0
  188. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_streaming_async.yaml +591 -0
  189. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_streaming_async_with_context_manager.yaml +202 -0
  190. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_streaming_async_with_parent_span.yaml +165 -0
  191. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_streaming_with_content.yaml +172 -0
  192. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_streaming_with_context_manager.yaml +202 -0
  193. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_streaming_with_parent_span.yaml +186 -0
  194. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_tool_calls.yaml +113 -0
  195. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_with_input_history.yaml +211 -0
  196. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_with_request_params.yaml +111 -0
  197. moda_openai-0.1.0/tests/traces/cassettes/test_responses/test_responses_with_service_tier.yaml +110 -0
  198. moda_openai-0.1.0/tests/traces/cassettes/test_streaming_with_api_usage/test_streaming_with_api_usage_and_events.yaml +775 -0
  199. moda_openai-0.1.0/tests/traces/cassettes/test_streaming_with_api_usage/test_streaming_with_api_usage_capture.yaml +164 -0
  200. moda_openai-0.1.0/tests/traces/cassettes/test_vision/test_vision.yaml +191 -0
  201. moda_openai-0.1.0/tests/traces/cassettes/test_vision/test_vision_base64.yaml +18831 -0
  202. moda_openai-0.1.0/tests/traces/cassettes/test_vision/test_vision_base64_with_events_with_content.yaml +18831 -0
  203. moda_openai-0.1.0/tests/traces/cassettes/test_vision/test_vision_base64_with_events_with_no_content.yaml +18831 -0
  204. moda_openai-0.1.0/tests/traces/cassettes/test_vision/test_vision_with_events_with_content.yaml +191 -0
  205. moda_openai-0.1.0/tests/traces/cassettes/test_vision/test_vision_with_events_with_no_content.yaml +191 -0
  206. moda_openai-0.1.0/tests/traces/conftest.py +9 -0
  207. moda_openai-0.1.0/tests/traces/test_assistant.py +1229 -0
  208. moda_openai-0.1.0/tests/traces/test_azure.py +799 -0
  209. moda_openai-0.1.0/tests/traces/test_chat.py +1834 -0
  210. moda_openai-0.1.0/tests/traces/test_chat_parse.py +597 -0
  211. moda_openai-0.1.0/tests/traces/test_chat_response_format.py +87 -0
  212. moda_openai-0.1.0/tests/traces/test_completions.py +959 -0
  213. moda_openai-0.1.0/tests/traces/test_embedding_metrics_handler.py +46 -0
  214. moda_openai-0.1.0/tests/traces/test_embeddings.py +659 -0
  215. moda_openai-0.1.0/tests/traces/test_exceptions.py +50 -0
  216. moda_openai-0.1.0/tests/traces/test_functions.py +950 -0
  217. moda_openai-0.1.0/tests/traces/test_prompt_caching.py +511 -0
  218. moda_openai-0.1.0/tests/traces/test_realtime.py +860 -0
  219. moda_openai-0.1.0/tests/traces/test_responses.py +820 -0
  220. moda_openai-0.1.0/tests/traces/test_span_context_propagation.py +58 -0
  221. moda_openai-0.1.0/tests/traces/test_streaming_with_api_usage.py +76 -0
  222. moda_openai-0.1.0/tests/traces/test_vision.py +404 -0
  223. moda_openai-0.1.0/tests/traces/utils.py +27 -0
  224. moda_openai-0.1.0/uv.lock +1283 -0
@@ -0,0 +1,185 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+
3
+ # compiled output
4
+ dist
5
+ tmp
6
+ /out-tsc
7
+
8
+ # dependencies
9
+ node_modules
10
+
11
+ # IDEs and editors
12
+ /.idea
13
+ .project
14
+ .classpath
15
+ .c9/
16
+ *.launch
17
+ .settings/
18
+ *.sublime-workspace
19
+
20
+ # IDE - VSCode
21
+ .vscode/*
22
+ !.vscode/settings.json
23
+ !.vscode/tasks.json
24
+ !.vscode/launch.json
25
+ !.vscode/extensions.json
26
+
27
+ # misc
28
+ /.sass-cache
29
+ /connect.lock
30
+ /coverage
31
+ /libpeerconnection.log
32
+ npm-debug.log
33
+ yarn-error.log
34
+ testem.log
35
+ /typings
36
+
37
+ # System Files
38
+ .DS_Store
39
+ Thumbs.db
40
+
41
+ .cache/
42
+ reports/
43
+ .vscode/
44
+
45
+ # Byte-compiled / optimized / DLL files
46
+ __pycache__/
47
+ *.py[cod]
48
+ *$py.class
49
+
50
+ # C extensions
51
+ *.so
52
+
53
+ # Distribution / packaging
54
+ .Python
55
+ build/
56
+ develop-eggs/
57
+ dist/
58
+ downloads/
59
+ eggs/
60
+ .eggs/
61
+ lib/
62
+ lib64/
63
+ parts/
64
+ sdist/
65
+ var/
66
+ wheels/
67
+ share/python-wheels/
68
+ *.egg-info/
69
+ .installed.cfg
70
+ *.egg
71
+ MANIFEST
72
+
73
+ # PyInstaller
74
+ # Usually these files are written by a python script from a template
75
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
76
+ *.manifest
77
+ *.spec
78
+
79
+ # Installer logs
80
+ pip-log.txt
81
+ pip-delete-this-directory.txt
82
+
83
+ # Unit test / coverage reports
84
+ htmlcov/
85
+ .tox/
86
+ .nox/
87
+ .coverage
88
+ .coverage.*
89
+ .cache
90
+ nosetests.xml
91
+ coverage.xml
92
+ *.cover
93
+ *.py,cover
94
+ .hypothesis/
95
+ .pytest_cache/
96
+ cover/
97
+
98
+ # Translations
99
+ *.mo
100
+ *.pot
101
+
102
+ # Django stuff:
103
+ *.log
104
+ local_settings.py
105
+ db.sqlite3
106
+ db.sqlite3-journal
107
+
108
+ # Flask stuff:
109
+ instance/
110
+ .webassets-cache
111
+
112
+ # Scrapy stuff:
113
+ .scrapy
114
+
115
+ # Sphinx documentation
116
+ docs/_build/
117
+
118
+ # PyBuilder
119
+ .pybuilder/
120
+ target/
121
+
122
+ # Jupyter Notebook
123
+ .ipynb_checkpoints
124
+
125
+ # IPython
126
+ profile_default/
127
+ ipython_config.py
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule
134
+ celerybeat.pid
135
+
136
+ # SageMath parsed files
137
+ *.sage.py
138
+
139
+ # Environments
140
+ .env
141
+ .venv
142
+ env/
143
+ venv/
144
+ ENV/
145
+ env.bak/
146
+ venv.bak/
147
+
148
+ # Spyder project settings
149
+ .spyderproject
150
+ .spyproject
151
+
152
+ # Rope project settings
153
+ .ropeproject
154
+
155
+ # mkdocs documentation
156
+ /site
157
+
158
+ # mypy
159
+ .mypy_cache/
160
+ .dmypy.json
161
+ dmypy.json
162
+
163
+ # Pyre type checker
164
+ .pyre/
165
+
166
+ # pytype static type analyzer
167
+ .pytype/
168
+
169
+ # Cython debug symbols
170
+ cython_debug/
171
+
172
+ # PyCharm
173
+ .idea/
174
+
175
+ # NX
176
+ .nx
177
+
178
+ # Test artifcats
179
+ chroma.sqlite3
180
+
181
+ # Claude
182
+ .claude
183
+
184
+ # Development files
185
+ packages/sample-app/sample_app/development/
@@ -0,0 +1 @@
1
+ 3.10
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: moda-openai
3
+ Version: 0.1.0
4
+ Summary: Moda OpenAI instrumentation for LLM observability
5
+ Project-URL: Repository, https://github.com/ModaLabs/moda-python/tree/main/packages/moda-openai
6
+ Author-email: Moda Labs <support@moda.so>
7
+ License-Expression: Apache-2.0
8
+ Requires-Python: <4,>=3.10
9
+ Requires-Dist: opentelemetry-api<2,>=1.38.0
10
+ Requires-Dist: opentelemetry-instrumentation>=0.59b0
11
+ Requires-Dist: opentelemetry-semantic-conventions-ai<0.5.0,>=0.4.13
12
+ Requires-Dist: opentelemetry-semantic-conventions>=0.59b0
13
+ Provides-Extra: instruments
14
+ Requires-Dist: openai; extra == 'instruments'
15
+ Description-Content-Type: text/markdown
16
+
17
+ # OpenTelemetry OpenAI Instrumentation
18
+
19
+ <a href="https://pypi.org/project/opentelemetry-instrumentation-openai/">
20
+ <img src="https://badge.fury.io/py/opentelemetry-instrumentation-openai.svg">
21
+ </a>
22
+
23
+ This library allows tracing OpenAI prompts and completions sent with the official [OpenAI library](https://github.com/openai/openai-python).
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install opentelemetry-instrumentation-openai
29
+ ```
30
+
31
+ ## Example usage
32
+
33
+ ```python
34
+ from opentelemetry.instrumentation.openai import OpenAIInstrumentor
35
+
36
+ OpenAIInstrumentor().instrument()
37
+ ```
38
+
39
+ ## Privacy
40
+
41
+ **By default, this instrumentation logs prompts, completions, and embeddings to span attributes**. This gives you a clear visibility into how your LLM application is working, and can make it easy to debug and evaluate the quality of the outputs.
42
+
43
+ However, you may want to disable this logging for privacy reasons, as they may contain highly sensitive data from your users. You may also simply want to reduce the size of your traces.
44
+
45
+ To disable logging, set the `TRACELOOP_TRACE_CONTENT` environment variable to `false`.
46
+
47
+ ```bash
48
+ TRACELOOP_TRACE_CONTENT=false
49
+ ```
@@ -0,0 +1,33 @@
1
+ # OpenTelemetry OpenAI Instrumentation
2
+
3
+ <a href="https://pypi.org/project/opentelemetry-instrumentation-openai/">
4
+ <img src="https://badge.fury.io/py/opentelemetry-instrumentation-openai.svg">
5
+ </a>
6
+
7
+ This library allows tracing OpenAI prompts and completions sent with the official [OpenAI library](https://github.com/openai/openai-python).
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install opentelemetry-instrumentation-openai
13
+ ```
14
+
15
+ ## Example usage
16
+
17
+ ```python
18
+ from opentelemetry.instrumentation.openai import OpenAIInstrumentor
19
+
20
+ OpenAIInstrumentor().instrument()
21
+ ```
22
+
23
+ ## Privacy
24
+
25
+ **By default, this instrumentation logs prompts, completions, and embeddings to span attributes**. This gives you a clear visibility into how your LLM application is working, and can make it easy to debug and evaluate the quality of the outputs.
26
+
27
+ However, you may want to disable this logging for privacy reasons, as they may contain highly sensitive data from your users. You may also simply want to reduce the size of your traces.
28
+
29
+ To disable logging, set the `TRACELOOP_TRACE_CONTENT` environment variable to `false`.
30
+
31
+ ```bash
32
+ TRACELOOP_TRACE_CONTENT=false
33
+ ```
@@ -0,0 +1,54 @@
1
+ from typing import Callable, Collection, Optional
2
+
3
+ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4
+ from opentelemetry.instrumentation.openai.shared.config import Config
5
+ from opentelemetry.instrumentation.openai.utils import is_openai_v1
6
+ from typing_extensions import Coroutine
7
+
8
+ _instruments = ("openai >= 0.27.0",)
9
+
10
+
11
+ class OpenAIInstrumentor(BaseInstrumentor):
12
+ """An instrumentor for OpenAI's client library."""
13
+
14
+ def __init__(
15
+ self,
16
+ enrich_assistant: bool = False,
17
+ exception_logger=None,
18
+ get_common_metrics_attributes: Callable[[], dict] = lambda: {},
19
+ upload_base64_image: Optional[
20
+ Callable[[str, str, str, str], Coroutine[None, None, str]]
21
+ ] = lambda *args: "",
22
+ enable_trace_context_propagation: bool = True,
23
+ use_legacy_attributes: bool = True,
24
+ ):
25
+ super().__init__()
26
+ Config.enrich_assistant = enrich_assistant
27
+ Config.exception_logger = exception_logger
28
+ Config.get_common_metrics_attributes = get_common_metrics_attributes
29
+ Config.upload_base64_image = upload_base64_image
30
+ Config.enable_trace_context_propagation = enable_trace_context_propagation
31
+ Config.use_legacy_attributes = use_legacy_attributes
32
+
33
+ def instrumentation_dependencies(self) -> Collection[str]:
34
+ return _instruments
35
+
36
+ def _instrument(self, **kwargs):
37
+ if is_openai_v1():
38
+ from opentelemetry.instrumentation.openai.v1 import OpenAIV1Instrumentor
39
+
40
+ OpenAIV1Instrumentor().instrument(**kwargs)
41
+ else:
42
+ from opentelemetry.instrumentation.openai.v0 import OpenAIV0Instrumentor
43
+
44
+ OpenAIV0Instrumentor().instrument(**kwargs)
45
+
46
+ def _uninstrument(self, **kwargs):
47
+ if is_openai_v1():
48
+ from opentelemetry.instrumentation.openai.v1 import OpenAIV1Instrumentor
49
+
50
+ OpenAIV1Instrumentor().uninstrument(**kwargs)
51
+ else:
52
+ from opentelemetry.instrumentation.openai.v0 import OpenAIV0Instrumentor
53
+
54
+ OpenAIV0Instrumentor().uninstrument(**kwargs)