langtrace-python-sdk 2.1.11__tar.gz → 2.1.13__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 (151) hide show
  1. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/PKG-INFO +2 -2
  2. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/pyproject.toml +1 -1
  3. langtrace_python_sdk-2.1.13/src/examples/openai_example/images_edit.py +40 -0
  4. langtrace_python_sdk-2.1.13/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
  5. langtrace_python_sdk-2.1.13/src/examples/openai_example/resources/mask.png +0 -0
  6. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/openai.py +4 -0
  7. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +8 -3
  8. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +9 -1
  9. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/openai/patch.py +85 -3
  10. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/langtrace.py +13 -4
  11. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/prompt_registry.py +1 -4
  12. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/with_root_span.py +3 -3
  13. langtrace_python_sdk-2.1.13/src/langtrace_python_sdk/version.py +1 -0
  14. langtrace_python_sdk-2.1.11/src/langtrace_python_sdk/version.py +0 -1
  15. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/.gitignore +0 -0
  16. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/LICENSE +0 -0
  17. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/README.md +0 -0
  18. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/__init__.py +0 -0
  19. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/__init__.py +0 -0
  20. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/anthropic_example/__init__.py +0 -0
  21. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/anthropic_example/completion.py +0 -0
  22. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/chroma_example/__init__.py +0 -0
  23. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/chroma_example/basic.py +0 -0
  24. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/cohere_example/__init__.py +0 -0
  25. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/cohere_example/chat.py +0 -0
  26. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/cohere_example/chat_stream.py +0 -0
  27. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/cohere_example/embed.py +0 -0
  28. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/cohere_example/rerank.py +0 -0
  29. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/cohere_example/tools.py +0 -0
  30. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/fastapi_example/basic_route.py +0 -0
  31. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/hiveagent_example/basic.py +0 -0
  32. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/langchain_example/__init__.py +0 -0
  33. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/langchain_example/basic.py +0 -0
  34. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/langchain_example/groq_example.py +0 -0
  35. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/langchain_example/langgraph_example.py +0 -0
  36. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/langchain_example/tool.py +0 -0
  37. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/llamaindex_example/__init__.py +0 -0
  38. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/llamaindex_example/agent.py +0 -0
  39. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/llamaindex_example/basic.py +0 -0
  40. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  41. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/__init__.py +0 -0
  42. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  43. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  44. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/chat_completion.py +0 -0
  45. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/embeddings_create.py +0 -0
  46. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/function_calling.py +0 -0
  47. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/images_generate.py +0 -0
  48. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/tool_calling.py +0 -0
  49. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  50. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  51. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/perplexity_example/basic.py +0 -0
  52. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/pinecone_example/__init__.py +0 -0
  53. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/pinecone_example/basic.py +0 -0
  54. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/qdrant_example/__init__.py +0 -0
  55. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/qdrant_example/basic.py +0 -0
  56. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/examples/weaviate_example/query_text.py +0 -0
  57. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/__init__.py +0 -0
  58. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  59. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  60. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  61. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  62. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  63. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
  64. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
  65. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  66. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  67. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  68. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
  69. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  70. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  71. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  72. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  73. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  74. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  75. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  76. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
  77. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  78. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
  79. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +0 -0
  80. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  81. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  82. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
  83. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  84. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  85. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
  86. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  87. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  88. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
  89. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  90. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  91. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
  92. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  93. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  94. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
  95. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  96. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  97. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
  98. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  99. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  100. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
  101. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
  102. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  103. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  104. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
  105. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
  106. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
  107. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
  108. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/types/__init__.py +0 -0
  109. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/__init__.py +0 -0
  110. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/llm.py +0 -0
  111. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/misc.py +0 -0
  112. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
  113. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
  114. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/langtrace_python_sdk/utils/types.py +0 -0
  115. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/run_example.py +0 -0
  116. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/__init__.py +0 -0
  117. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  118. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  119. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  120. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/anthropic/conftest.py +0 -0
  121. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/anthropic/test_anthropic.py +0 -0
  122. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/chroma/conftest.py +0 -0
  123. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/chroma/test_chroma.py +0 -0
  124. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  125. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  126. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  127. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  128. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/conftest.py +0 -0
  129. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/test_cohere_chat.py +0 -0
  130. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/test_cohere_embed.py +0 -0
  131. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/cohere/test_cohere_rerank.py +0 -0
  132. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/conftest.py +0 -0
  133. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
  134. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/langchain/conftest.py +0 -0
  135. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/langchain/test_langchain.py +0 -0
  136. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  137. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  138. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  139. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  140. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  141. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/conftest.py +0 -0
  142. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/test_chat_completion.py +0 -0
  143. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/test_embeddings.py +0 -0
  144. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/openai/test_image_generation.py +0 -0
  145. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
  146. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
  147. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/pinecone/conftest.py +0 -0
  148. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/pinecone/test_pinecone.py +0 -0
  149. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/qdrant/conftest.py +0 -0
  150. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/qdrant/test_qdrant.py +0 -0
  151. {langtrace_python_sdk-2.1.11 → langtrace_python_sdk-2.1.13}/src/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.1.11
3
+ Version: 2.1.13
4
4
  Summary: Python SDK for LangTrace
5
5
  Project-URL: Homepage, https://github.com/Scale3-Labs/langtrace-python-sdk
6
6
  Author-email: Scale3 Labs <engineering@scale3labs.com>
@@ -19,7 +19,7 @@ Requires-Dist: opentelemetry-instrumentation>=0.46b0
19
19
  Requires-Dist: opentelemetry-sdk>=1.25.0
20
20
  Requires-Dist: sqlalchemy
21
21
  Requires-Dist: tiktoken>=0.1.1
22
- Requires-Dist: trace-attributes>=4.0.4
22
+ Requires-Dist: trace-attributes==4.0.5
23
23
  Provides-Extra: dev
24
24
  Requires-Dist: anthropic; extra == 'dev'
25
25
  Requires-Dist: chromadb; extra == 'dev'
@@ -18,7 +18,7 @@ classifiers=[
18
18
  "Operating System :: OS Independent",
19
19
  ]
20
20
  dependencies = [
21
- 'trace-attributes>=4.0.4',
21
+ 'trace-attributes==4.0.5',
22
22
  'opentelemetry-api>=1.25.0',
23
23
  'opentelemetry-sdk>=1.25.0',
24
24
  'opentelemetry-instrumentation>=0.46b0',
@@ -0,0 +1,40 @@
1
+ from dotenv import find_dotenv, load_dotenv
2
+ from openai import OpenAI
3
+
4
+ from langtrace_python_sdk import langtrace
5
+
6
+ # from PIL import Image
7
+
8
+
9
+ _ = load_dotenv(find_dotenv())
10
+
11
+ langtrace.init(write_spans_to_console=True)
12
+
13
+
14
+ client = OpenAI()
15
+
16
+
17
+ # use this to convert the image to RGBA
18
+ # def convert_to_rgba():
19
+ # Image.open("./resources/image.png").convert("RGBA").save("./resources/image_with_alpha.png")
20
+
21
+
22
+ def image_edit():
23
+
24
+ response = client.images.edit(
25
+ model="dall-e-2",
26
+ image=open("./resources/lounge_flamingo.png", "rb"),
27
+ mask=open("./resources/mask.png", "rb"),
28
+ prompt="A sunlit indoor lounge area with a pool and duck standing in side with flamingo.",
29
+ n=1,
30
+ size="1024x1024",
31
+ response_format="url",
32
+ )
33
+
34
+ image_url = response.data[0].url
35
+ print(image_url)
36
+ print(response)
37
+
38
+
39
+ image_edit()
40
+ # convert_to_rgba()
@@ -40,6 +40,10 @@ APIS = {
40
40
  "METHOD": OpenAIMethods.IMAGES_GENERATION.value,
41
41
  "ENDPOINT": "/images/generations",
42
42
  },
43
+ "IMAGES_EDIT": {
44
+ "METHOD": OpenAIMethods.IMAGES_EDIT.value,
45
+ "ENDPOINT": "/images/edits",
46
+ },
43
47
  "EMBEDDINGS_CREATE": {
44
48
  "METHOD": OpenAIMethods.EMBEDDINGS_CREATE.value,
45
49
  "ENDPOINT": "/embeddings",
@@ -48,14 +48,19 @@ class LangTraceExporter(SpanExporter):
48
48
  """
49
49
 
50
50
  api_key: str
51
+ api_host: str
51
52
 
52
53
  def __init__(
53
54
  self,
55
+ api_host,
54
56
  api_key: str = None,
55
- api_host: typing.Optional[str] = None,
56
57
  ) -> None:
57
58
  self.api_key = api_key or os.environ.get("LANGTRACE_API_KEY")
58
- self.api_host: str = api_host or LANGTRACE_REMOTE_URL
59
+ self.api_host = (
60
+ f"{LANGTRACE_REMOTE_URL}/api/trace"
61
+ if api_host == LANGTRACE_REMOTE_URL
62
+ else api_host
63
+ )
59
64
 
60
65
  def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
61
66
  """
@@ -90,7 +95,7 @@ class LangTraceExporter(SpanExporter):
90
95
  # Send data to remote URL
91
96
  try:
92
97
  response = requests.post(
93
- url=f"{self.api_host}/api/trace",
98
+ url=f"{self.api_host}",
94
99
  data=json.dumps(data),
95
100
  headers={"Content-Type": "application/json", "x-api-key": self.api_key},
96
101
  timeout=20,
@@ -28,6 +28,7 @@ from langtrace_python_sdk.instrumentation.openai.patch import (
28
28
  async_images_generate,
29
29
  chat_completions_create,
30
30
  embeddings_create,
31
+ images_edit,
31
32
  images_generate,
32
33
  )
33
34
 
@@ -37,7 +38,7 @@ logging.basicConfig(level=logging.FATAL)
37
38
  class OpenAIInstrumentation(BaseInstrumentor):
38
39
 
39
40
  def instrumentation_dependencies(self) -> Collection[str]:
40
- return ["openai >= 0.27.0"]
41
+ return ["openai >= 0.27.0", "trace-attributes >= 4.0.5"]
41
42
 
42
43
  def _instrument(self, **kwargs):
43
44
  tracer_provider = kwargs.get("tracer_provider")
@@ -69,6 +70,13 @@ class OpenAIInstrumentation(BaseInstrumentor):
69
70
  "AsyncImages.generate",
70
71
  async_images_generate("openai.images.generate", version, tracer),
71
72
  )
73
+
74
+ wrap_function_wrapper(
75
+ "openai.resources.images",
76
+ "Images.edit",
77
+ images_edit("openai.images.edit", version, tracer),
78
+ )
79
+
72
80
  wrap_function_wrapper(
73
81
  "openai.resources.embeddings",
74
82
  "Embeddings.create",
@@ -16,20 +16,19 @@ limitations under the License.
16
16
 
17
17
  import json
18
18
 
19
+ from importlib_metadata import version as v
19
20
  from langtrace.trace_attributes import Event, LLMSpanAttributes
20
21
  from opentelemetry import baggage
21
22
  from opentelemetry.trace import SpanKind
22
23
  from opentelemetry.trace.status import Status, StatusCode
23
24
 
25
+ from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
24
26
  from langtrace_python_sdk.constants.instrumentation.common import (
25
27
  LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
26
28
  SERVICE_PROVIDERS,
27
29
  )
28
30
  from langtrace_python_sdk.constants.instrumentation.openai import APIS
29
31
  from langtrace_python_sdk.utils.llm import calculate_prompt_tokens, estimate_tokens
30
- from importlib_metadata import version as v
31
-
32
- from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
33
32
 
34
33
 
35
34
  def images_generate(original_method, version, tracer):
@@ -187,6 +186,89 @@ def async_images_generate(original_method, version, tracer):
187
186
  return traced_method
188
187
 
189
188
 
189
+ def images_edit(original_method, version, tracer):
190
+ """
191
+ Wrap the `edit` method of the `Images` class to trace it.
192
+ """
193
+
194
+ def traced_method(wrapped, instance, args, kwargs):
195
+ base_url = (
196
+ str(instance._client._base_url)
197
+ if hasattr(instance, "_client") and hasattr(instance._client, "_base_url")
198
+ else ""
199
+ )
200
+ service_provider = SERVICE_PROVIDERS["OPENAI"]
201
+ extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY)
202
+
203
+ span_attributes = {
204
+ "langtrace.sdk.name": "langtrace-python-sdk",
205
+ "langtrace.service.name": service_provider,
206
+ "langtrace.service.type": "llm",
207
+ "langtrace.service.version": version,
208
+ "langtrace.version": v(LANGTRACE_SDK_NAME),
209
+ "url.full": base_url,
210
+ "llm.api": APIS["IMAGES_EDIT"]["ENDPOINT"],
211
+ "llm.model": kwargs.get("model"),
212
+ "llm.response_format": kwargs.get("response_format"),
213
+ "llm.image.size": kwargs.get("size"),
214
+ "llm.prompts": json.dumps(
215
+ [
216
+ {
217
+ "role": kwargs.get("user", "user"),
218
+ "content": kwargs.get("prompt", []),
219
+ }
220
+ ]
221
+ ),
222
+ "llm.top_k": kwargs.get("n"),
223
+ **(extra_attributes if extra_attributes is not None else {}),
224
+ }
225
+
226
+ attributes = LLMSpanAttributes(**span_attributes)
227
+
228
+ with tracer.start_as_current_span(
229
+ APIS["IMAGES_EDIT"]["METHOD"], kind=SpanKind.CLIENT
230
+ ) as span:
231
+ for field, value in attributes.model_dump(by_alias=True).items():
232
+ if value is not None:
233
+ span.set_attribute(field, value)
234
+ try:
235
+ # Attempt to call the original method
236
+ result = wrapped(*args, **kwargs)
237
+
238
+ response = []
239
+ # Parse each image object
240
+ for each_data in result.data:
241
+ response.append(
242
+ {
243
+ "role": "assistant",
244
+ "content": {
245
+ "url": each_data.url,
246
+ "revised_prompt": each_data.revised_prompt,
247
+ "base64": each_data.b64_json,
248
+ },
249
+ }
250
+ )
251
+
252
+ span.add_event(
253
+ name="response",
254
+ attributes={"llm.responses": json.dumps(response)},
255
+ )
256
+
257
+ span.set_status(StatusCode.OK)
258
+ return result
259
+ except Exception as err:
260
+ # Record the exception in the span
261
+ span.record_exception(err)
262
+
263
+ # Set the span status to indicate an error
264
+ span.set_status(Status(StatusCode.ERROR, str(err)))
265
+
266
+ # Reraise the exception to ensure it's not swallowed
267
+ raise
268
+
269
+ return traced_method
270
+
271
+
190
272
  def chat_completions_create(original_method, version, tracer):
191
273
  """Wrap the `create` method of the `ChatCompletion` class to trace it."""
192
274
 
@@ -16,6 +16,9 @@ limitations under the License.
16
16
 
17
17
  from typing import Optional
18
18
 
19
+ from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
20
+ LANGTRACE_REMOTE_URL,
21
+ )
19
22
  from langtrace_python_sdk.types import DisableInstrumentations, InstrumentationType
20
23
  from opentelemetry import trace
21
24
  from opentelemetry.sdk.trace import TracerProvider
@@ -46,6 +49,7 @@ from langtrace_python_sdk.instrumentation import (
46
49
  from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
47
50
  from colorama import Fore
48
51
  from langtrace_python_sdk.utils import check_if_sdk_is_outdated
52
+ import os
49
53
 
50
54
 
51
55
  def init(
@@ -53,15 +57,19 @@ def init(
53
57
  batch: bool = True,
54
58
  write_spans_to_console: bool = False,
55
59
  custom_remote_exporter=None,
56
- api_host: Optional[str] = None,
60
+ api_host: Optional[str] = LANGTRACE_REMOTE_URL,
57
61
  disable_instrumentations: Optional[DisableInstrumentations] = None,
58
62
  ):
63
+
64
+ host = (
65
+ os.environ.get("LANGTRACE_API_HOST", None) or api_host or LANGTRACE_REMOTE_URL
66
+ )
59
67
  check_if_sdk_is_outdated()
60
68
  print(Fore.GREEN + "Initializing Langtrace SDK.." + Fore.RESET)
61
69
  provider = TracerProvider(resource=Resource.create({"service.name": sys.argv[0]}))
62
70
 
63
71
  remote_write_exporter = (
64
- LangTraceExporter(api_key=api_key, api_host=api_host)
72
+ LangTraceExporter(api_key=api_key, api_host=host)
65
73
  if custom_remote_exporter is None
66
74
  else custom_remote_exporter
67
75
  )
@@ -70,6 +78,7 @@ def init(
70
78
  simple_processor_remote = SimpleSpanProcessor(remote_write_exporter)
71
79
  simple_processor_console = SimpleSpanProcessor(console_exporter)
72
80
 
81
+ os.environ["LANGTRACE_API_HOST"] = host.replace("/api/trace", "")
73
82
  # Initialize tracer
74
83
  trace.set_tracer_provider(provider)
75
84
  all_instrumentations = {
@@ -101,8 +110,8 @@ def init(
101
110
  else:
102
111
  provider.add_span_processor(simple_processor_remote)
103
112
 
104
- elif api_host is not None:
105
- print(Fore.BLUE + f"Exporting spans to custom host: {api_host}.." + Fore.RESET)
113
+ elif host != LANGTRACE_REMOTE_URL:
114
+ print(Fore.BLUE + f"Exporting spans to custom host: {host}.." + Fore.RESET)
106
115
  if batch:
107
116
  provider.add_span_processor(batch_processor_remote)
108
117
  else:
@@ -1,7 +1,4 @@
1
1
  import os
2
- from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
3
- LANGTRACE_REMOTE_URL,
4
- )
5
2
  import requests
6
3
  from urllib.parse import urlencode
7
4
  from typing import Optional, TypedDict, Dict, List
@@ -59,7 +56,7 @@ def get_prompt_from_registry(
59
56
  print(query_params)
60
57
  # Make the GET request to the API
61
58
  response = requests.get(
62
- f"{LANGTRACE_REMOTE_URL}/api/promptset?{query_string}",
59
+ f"{os.environ['LANGTRACE_API_HOST']}/api/promptset?{query_string}",
63
60
  headers=headers,
64
61
  timeout=None,
65
62
  )
@@ -118,9 +118,7 @@ class SendUserFeedback:
118
118
  _langtrace_api_key: str
119
119
 
120
120
  def __init__(self):
121
- self._langtrace_host = os.environ.get(
122
- "LANGTRACE_API_HOST", LANGTRACE_REMOTE_URL
123
- )
121
+ self._langtrace_host = os.environ["LANGTRACE_API_HOST"]
124
122
  self._langtrace_api_key = os.environ.get("LANGTRACE_API_KEY", None)
125
123
 
126
124
  def evaluate(self, data: EvaluationAPIData) -> None:
@@ -137,6 +135,7 @@ class SendUserFeedback:
137
135
  headers = {"x-api-key": self._langtrace_api_key}
138
136
  if evaluation is not None:
139
137
  # Make a PUT request to update the evaluation
138
+ print(Fore.BLUE + "Updating Feedback.." + Fore.RESET)
140
139
  response = requests.put(
141
140
  f"{self._langtrace_host}/api/evaluation",
142
141
  json=data,
@@ -147,6 +146,7 @@ class SendUserFeedback:
147
146
  response.raise_for_status()
148
147
 
149
148
  else:
149
+ print(Fore.BLUE + "Sending User Feedback.." + Fore.RESET)
150
150
  # Make a POST request to create a new evaluation
151
151
  response = requests.post(
152
152
  f"{self._langtrace_host}/api/evaluation",
@@ -0,0 +1 @@
1
+ __version__ = "2.1.13"
@@ -1 +0,0 @@
1
- __version__ = "2.1.11"