langtrace-python-sdk 2.1.1__tar.gz → 2.1.4__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 (150) hide show
  1. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/PKG-INFO +8 -8
  2. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/pyproject.toml +7 -7
  3. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/pinecone_example/basic.py +20 -8
  4. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +22 -7
  5. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +1 -11
  6. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +8 -7
  7. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +14 -12
  8. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/langtrace.py +7 -0
  9. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/utils/with_root_span.py +9 -11
  10. langtrace_python_sdk-2.1.4/src/langtrace_python_sdk/version.py +1 -0
  11. langtrace_python_sdk-2.1.4/src/tests/langchain/cassettes/test_langchain.yaml +106 -0
  12. langtrace_python_sdk-2.1.4/src/tests/langchain/conftest.py +42 -0
  13. langtrace_python_sdk-2.1.4/src/tests/langchain/test_langchain.py +28 -0
  14. langtrace_python_sdk-2.1.1/src/langtrace_python_sdk/version.py +0 -1
  15. langtrace_python_sdk-2.1.1/src/tests/langchain/test_langchain.py +0 -82
  16. langtrace_python_sdk-2.1.1/src/tests/langchain/test_langchain_community.py +0 -82
  17. langtrace_python_sdk-2.1.1/src/tests/langchain/test_langchain_core.py +0 -141
  18. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/.gitignore +0 -0
  19. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/LICENSE +0 -0
  20. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/README.md +0 -0
  21. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/__init__.py +0 -0
  22. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/__init__.py +0 -0
  23. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/anthropic_example/__init__.py +0 -0
  24. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/anthropic_example/completion.py +0 -0
  25. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/chroma_example/__init__.py +0 -0
  26. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/chroma_example/basic.py +0 -0
  27. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/cohere_example/__init__.py +0 -0
  28. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/cohere_example/chat.py +0 -0
  29. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/cohere_example/chat_stream.py +0 -0
  30. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/cohere_example/embed.py +0 -0
  31. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/cohere_example/rerank.py +0 -0
  32. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/cohere_example/tools.py +0 -0
  33. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/fastapi_example/basic_route.py +0 -0
  34. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/hiveagent_example/basic.py +0 -0
  35. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/langchain_example/__init__.py +0 -0
  36. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/langchain_example/basic.py +0 -0
  37. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/langchain_example/groq_example.py +0 -0
  38. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/langchain_example/langgraph_example.py +0 -0
  39. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/langchain_example/tool.py +0 -0
  40. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/llamaindex_example/__init__.py +0 -0
  41. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/llamaindex_example/agent.py +0 -0
  42. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/llamaindex_example/basic.py +0 -0
  43. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  44. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/__init__.py +0 -0
  45. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  46. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  47. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/chat_completion.py +0 -0
  48. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/embeddings_create.py +0 -0
  49. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/function_calling.py +0 -0
  50. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/images_generate.py +0 -0
  51. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/tool_calling.py +0 -0
  52. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  53. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  54. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/perplexity_example/basic.py +0 -0
  55. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/pinecone_example/__init__.py +0 -0
  56. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/qdrant_example/__init__.py +0 -0
  57. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/qdrant_example/basic.py +0 -0
  58. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/examples/weaviate_example/query_text.py +0 -0
  59. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/__init__.py +0 -0
  60. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  61. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  62. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  63. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  64. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  65. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
  66. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
  67. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  68. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  69. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  70. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  71. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
  72. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  73. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  74. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  75. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  76. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  77. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  78. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  79. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
  80. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  81. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
  82. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +0 -0
  83. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  84. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  85. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
  86. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  87. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  88. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
  89. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  90. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  91. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
  92. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  93. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  94. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
  95. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  96. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  97. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
  98. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  99. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  100. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
  101. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  102. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  103. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
  104. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  105. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  106. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  107. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
  108. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
  109. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
  110. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/types/__init__.py +0 -0
  111. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/utils/__init__.py +0 -0
  112. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/utils/llm.py +0 -0
  113. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/utils/misc.py +0 -0
  114. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
  115. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
  116. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/langtrace_python_sdk/utils/types.py +0 -0
  117. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/run_example.py +0 -0
  118. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/__init__.py +0 -0
  119. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  120. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  121. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  122. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/anthropic/conftest.py +0 -0
  123. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/anthropic/test_anthropic.py +0 -0
  124. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/chroma/conftest.py +0 -0
  125. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/chroma/test_chroma.py +0 -0
  126. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  127. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  128. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  129. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  130. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/conftest.py +0 -0
  131. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/test_cohere_chat.py +0 -0
  132. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/test_cohere_embed.py +0 -0
  133. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/cohere/test_cohere_rerank.py +0 -0
  134. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/conftest.py +0 -0
  135. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  136. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  137. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  138. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  139. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  140. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/conftest.py +0 -0
  141. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/test_chat_completion.py +0 -0
  142. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/test_embeddings.py +0 -0
  143. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/openai/test_image_generation.py +0 -0
  144. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
  145. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
  146. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/pinecone/conftest.py +0 -0
  147. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/pinecone/test_pinecone.py +0 -0
  148. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/qdrant/conftest.py +0 -0
  149. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/src/tests/qdrant/test_qdrant.py +0 -0
  150. {langtrace_python_sdk-2.1.1 → langtrace_python_sdk-2.1.4}/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.1
3
+ Version: 2.1.4
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>
@@ -10,15 +10,14 @@ Classifier: License :: OSI Approved :: Apache Software License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.9
13
- Requires-Dist: opentelemetry-api
13
+ Requires-Dist: colorama>=0.4.6
14
+ Requires-Dist: opentelemetry-api>=1.24.0
14
15
  Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.24.0
15
16
  Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.24.0
16
- Requires-Dist: opentelemetry-instrumentation
17
- Requires-Dist: opentelemetry-sdk
18
- Requires-Dist: pinecone-client
19
- Requires-Dist: tiktoken
20
- Requires-Dist: trace-attributes>=4.0.2
21
- Requires-Dist: weaviate-client
17
+ Requires-Dist: opentelemetry-instrumentation>=0.45b0
18
+ Requires-Dist: opentelemetry-sdk>=1.24.0
19
+ Requires-Dist: tiktoken>=0.1.1
20
+ Requires-Dist: trace-attributes>=4.0.4
22
21
  Provides-Extra: dev
23
22
  Requires-Dist: anthropic; extra == 'dev'
24
23
  Requires-Dist: chromadb; extra == 'dev'
@@ -27,6 +26,7 @@ Requires-Dist: langchain; extra == 'dev'
27
26
  Requires-Dist: langchain-community; extra == 'dev'
28
27
  Requires-Dist: langchain-openai; extra == 'dev'
29
28
  Requires-Dist: openai; extra == 'dev'
29
+ Requires-Dist: pinecone-client; extra == 'dev'
30
30
  Requires-Dist: python-dotenv; extra == 'dev'
31
31
  Requires-Dist: qdrant-client; extra == 'dev'
32
32
  Requires-Dist: weaviate-client; extra == 'dev'
@@ -18,15 +18,14 @@ classifiers=[
18
18
  "Operating System :: OS Independent",
19
19
  ]
20
20
  dependencies = [
21
- 'trace-attributes>=4.0.2',
22
- 'opentelemetry-api',
23
- 'opentelemetry-sdk',
24
- 'opentelemetry-instrumentation',
25
- 'pinecone-client',
26
- 'tiktoken',
21
+ 'trace-attributes>=4.0.4',
22
+ 'opentelemetry-api>=1.24.0',
23
+ 'opentelemetry-sdk>=1.24.0',
24
+ 'opentelemetry-instrumentation>=0.45b0',
25
+ 'tiktoken>=0.1.1',
27
26
  'opentelemetry-exporter-otlp-proto-http>=1.24.0',
28
27
  'opentelemetry-exporter-otlp-proto-grpc>=1.24.0',
29
- 'weaviate-client',
28
+ 'colorama>=0.4.6'
30
29
  ]
31
30
 
32
31
  requires-python = ">=3.9"
@@ -38,6 +37,7 @@ dev = [
38
37
  "chromadb",
39
38
  'qdrant-client',
40
39
  "python-dotenv",
40
+ 'pinecone-client',
41
41
  "langchain",
42
42
  'langchain-community',
43
43
  "langchain-openai",
@@ -2,13 +2,12 @@
2
2
  This example demonstrates how to use Pinecone with Langtrace.
3
3
  """
4
4
 
5
- from langtrace_python_sdk import langtrace
6
5
  from dotenv import find_dotenv, load_dotenv
7
6
  from openai import OpenAI
8
- from pinecone import Pinecone
7
+ from pinecone import Pinecone, ServerlessSpec
9
8
 
10
-
11
- from langtrace_python_sdk import with_langtrace_root_span, send_user_feedback
9
+ from langtrace_python_sdk import langtrace, with_langtrace_root_span
10
+ from langtrace_python_sdk.utils.with_root_span import send_user_feedback
12
11
 
13
12
  _ = load_dotenv(find_dotenv())
14
13
 
@@ -17,9 +16,20 @@ langtrace.init()
17
16
  client = OpenAI()
18
17
  pinecone = Pinecone()
19
18
 
19
+ PINECONE_INDEX_NAME = "test-index"
20
+
21
+
22
+ def create_index():
23
+ pinecone.create_index(
24
+ name=PINECONE_INDEX_NAME,
25
+ dimension=1536,
26
+ metric="cosine",
27
+ spec=ServerlessSpec(cloud="aws", region="us-east-1"),
28
+ )
29
+
20
30
 
21
31
  @with_langtrace_root_span()
22
- def basic(span_id, trace_id):
32
+ def basic(span_id=None, trace_id=None):
23
33
 
24
34
  result = client.embeddings.create(
25
35
  model="text-embedding-ada-002",
@@ -32,9 +42,8 @@ def basic(span_id, trace_id):
32
42
  unique_id = "unique_random_id"
33
43
  data_to_upsert = {"id": unique_id, "values": embedding}
34
44
 
35
- index = pinecone.Index("test-index")
45
+ index = pinecone.Index(PINECONE_INDEX_NAME)
36
46
  res = index.upsert(vectors=[data_to_upsert], namespace="test-namespace")
37
- print("res", res)
38
47
 
39
48
  resp = index.query(
40
49
  vector=embedding, top_k=1, include_values=False, namespace="test-namespace"
@@ -42,4 +51,7 @@ def basic(span_id, trace_id):
42
51
  send_user_feedback(
43
52
  {"spanId": span_id, "traceId": trace_id, "userScore": 1, "userId": "123"}
44
53
  )
45
- print(resp)
54
+ return [res, resp]
55
+
56
+
57
+ # create_index()
@@ -9,6 +9,8 @@ from opentelemetry.trace.span import format_trace_id
9
9
  from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
10
10
  LANGTRACE_REMOTE_URL,
11
11
  )
12
+ from colorama import Fore
13
+ from requests.exceptions import RequestException
12
14
 
13
15
 
14
16
  class LangTraceExporter(SpanExporter):
@@ -55,9 +57,6 @@ class LangTraceExporter(SpanExporter):
55
57
  self.api_key = api_key or os.environ.get("LANGTRACE_API_KEY")
56
58
  self.api_host: str = api_host or LANGTRACE_REMOTE_URL
57
59
 
58
- if not self.api_key:
59
- raise ValueError("No API key provided")
60
-
61
60
  def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
62
61
  """
63
62
  Exports a batch of telemetry data.
@@ -68,10 +67,17 @@ class LangTraceExporter(SpanExporter):
68
67
  Returns:
69
68
  The result of the export SUCCESS or FAILURE
70
69
  """
70
+ if not self.api_key:
71
+ print(Fore.RED)
72
+ print(
73
+ "Missing Langtrace API key, proceed to https://langtrace.ai to create one"
74
+ )
75
+ print("Set the API key as an environment variable LANGTRACE_API_KEY")
76
+ print(Fore.RESET)
77
+ return
71
78
  data = [
72
79
  {
73
80
  "traceId": format_trace_id(span.get_span_context().trace_id),
74
- "instrumentationLibrary": span.instrumentation_info.__repr__(),
75
81
  "droppedEventsCount": span.dropped_events,
76
82
  "droppedAttributesCount": span.dropped_attributes,
77
83
  "droppedLinksCount": span.dropped_links,
@@ -83,14 +89,23 @@ class LangTraceExporter(SpanExporter):
83
89
 
84
90
  # Send data to remote URL
85
91
  try:
86
- requests.post(
92
+ response = requests.post(
87
93
  url=f"{self.api_host}/api/trace",
88
94
  data=json.dumps(data),
89
95
  headers={"Content-Type": "application/json", "x-api-key": self.api_key},
96
+ timeout=20,
97
+ )
98
+
99
+ if not response.ok:
100
+ raise RequestException(response.text)
101
+
102
+ print(
103
+ Fore.GREEN + f"Exported {len(spans)} spans successfully." + Fore.RESET
90
104
  )
91
- print(f"sent to {self.api_host}/api/trace with {len(data)} spans")
92
105
  return SpanExportResult.SUCCESS
93
- except Exception as e:
106
+ except RequestException as err:
107
+ print(Fore.RED + "Failed to export spans.")
108
+ print(Fore.RED + f"Error: {err}" + Fore.RESET)
94
109
  return SpanExportResult.FAILURE
95
110
 
96
111
  def shutdown(self) -> None:
@@ -18,7 +18,6 @@ import importlib.metadata
18
18
  import logging
19
19
  from typing import Collection
20
20
 
21
- import pinecone
22
21
  from langtrace.trace_attributes import PineconeMethods
23
22
  from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
24
23
  from opentelemetry.trace import get_tracer
@@ -42,21 +41,12 @@ class PineconeInstrumentation(BaseInstrumentor):
42
41
  tracer = get_tracer(__name__, "", tracer_provider)
43
42
  version = importlib.metadata.version("pinecone-client")
44
43
  for operation_name, details in APIS.items():
45
- method_ref = details["METHOD"]
46
- method = None
47
- if method_ref is PineconeMethods.UPSERT.value:
48
- method = pinecone.Index.upsert
49
- elif method_ref is PineconeMethods.QUERY.value:
50
- method = pinecone.Index.query
51
- elif method_ref is PineconeMethods.DELETE.value:
52
- method = pinecone.Index.delete
53
44
  operation = details["OPERATION"]
54
-
55
45
  # Dynamically creating the patching call
56
46
  wrap_function_wrapper(
57
47
  "pinecone.data.index",
58
48
  f"Index.{operation}",
59
- generic_patch(method, operation_name, version, tracer),
49
+ generic_patch(operation_name, version, tracer),
60
50
  )
61
51
 
62
52
  def _uninstrument(self, **kwargs):
@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  """
16
16
 
17
+ import json
18
+
17
19
  from langtrace.trace_attributes import DatabaseSpanAttributes
18
- from langtrace_python_sdk.utils import set_span_attribute
19
- from langtrace_python_sdk.utils.silently_fail import silently_fail
20
20
  from opentelemetry import baggage
21
21
  from opentelemetry.trace import SpanKind
22
22
  from opentelemetry.trace.status import Status, StatusCode
@@ -26,15 +26,16 @@ from langtrace_python_sdk.constants.instrumentation.common import (
26
26
  SERVICE_PROVIDERS,
27
27
  )
28
28
  from langtrace_python_sdk.constants.instrumentation.pinecone import APIS
29
- import json
29
+ from langtrace_python_sdk.utils import set_span_attribute
30
+ from langtrace_python_sdk.utils.silently_fail import silently_fail
30
31
 
31
32
 
32
- def generic_patch(original_method, method, version, tracer):
33
+ def generic_patch(operation_name, version, tracer):
33
34
  """
34
35
  A generic patch method that wraps a function with a span"""
35
36
 
36
37
  def traced_method(wrapped, instance, args, kwargs):
37
- api = APIS[method]
38
+ api = APIS[operation_name]
38
39
  service_provider = SERVICE_PROVIDERS["PINECONE"]
39
40
  extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY)
40
41
 
@@ -56,7 +57,7 @@ def generic_patch(original_method, method, version, tracer):
56
57
 
57
58
  if span.is_recording():
58
59
  set_span_attribute(span, "server.address", instance._config.host)
59
- if method == "QUERY":
60
+ if operation_name == "QUERY":
60
61
  set_query_input_attributes(span, kwargs)
61
62
 
62
63
  for field, value in attributes.model_dump(by_alias=True).items():
@@ -64,7 +65,7 @@ def generic_patch(original_method, method, version, tracer):
64
65
  span.set_attribute(field, value)
65
66
  try:
66
67
  # Attempt to call the original method
67
- result = original_method(instance, *args, **kwargs)
68
+ result = wrapped(*args, **kwargs)
68
69
  if result:
69
70
  if span.is_recording():
70
71
  set_query_response_attributes(span, result)
@@ -17,7 +17,7 @@ limitations under the License.
17
17
  import importlib.metadata
18
18
  import logging
19
19
  from typing import Collection
20
-
20
+ from opentelemetry.instrumentation.utils import unwrap
21
21
  from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
22
22
  from opentelemetry.trace import get_tracer
23
23
  from wrapt import wrap_function_wrapper
@@ -28,7 +28,7 @@ from langtrace_python_sdk.instrumentation.weaviate.patch import (
28
28
  )
29
29
  from langtrace_python_sdk.constants.instrumentation.weaviate import APIS
30
30
 
31
- logging.basicConfig(level=logging.FATAL)
31
+ logging.basicConfig(level=logging.DEBUG) # Set to DEBUG for detailed logging
32
32
 
33
33
 
34
34
  class WeaviateInstrumentation(BaseInstrumentor):
@@ -47,17 +47,19 @@ class WeaviateInstrumentation(BaseInstrumentor):
47
47
  for api_name, api_config in APIS.items():
48
48
  module_path, function_name = api_name.rsplit(".", 1)
49
49
  if api_config.get("OPERATION") == "query":
50
- wrap_function_wrapper(
51
- api_config["MODULE"],
52
- api_config["METHOD"],
53
- generic_query_patch(api_name, version, tracer),
54
- )
50
+ if getattr(api_config["MODULE"], api_config["METHOD"], None):
51
+ wrap_function_wrapper(
52
+ api_config["MODULE"],
53
+ api_config["METHOD"],
54
+ generic_query_patch(api_name, version, tracer),
55
+ )
55
56
  elif api_config.get("OPERATION") == "create":
56
- wrap_function_wrapper(
57
- api_config["MODULE"],
58
- api_config["METHOD"],
59
- generic_collection_patch(api_name, version, tracer),
60
- )
57
+ if getattr(api_config["MODULE"], api_config["METHOD"], None):
58
+ wrap_function_wrapper(
59
+ api_config["MODULE"],
60
+ api_config["METHOD"],
61
+ generic_collection_patch(api_name, version, tracer),
62
+ )
61
63
 
62
64
  def _instrument_module(self, module_name):
63
65
  pass
@@ -68,6 +68,8 @@ from langtrace_python_sdk.instrumentation.weaviate.instrumentation import (
68
68
  WeaviateInstrumentation,
69
69
  )
70
70
 
71
+ from colorama import Fore
72
+
71
73
 
72
74
  def init(
73
75
  api_key: str = None,
@@ -77,6 +79,7 @@ def init(
77
79
  api_host: Optional[str] = None,
78
80
  disable_instrumentations: Optional[DisableInstrumentations] = None,
79
81
  ):
82
+ print(Fore.GREEN + "Initializing Langtrace SDK.." + Fore.RESET)
80
83
  provider = TracerProvider(resource=Resource.create({"service.name": sys.argv[0]}))
81
84
 
82
85
  remote_write_exporter = (
@@ -90,20 +93,24 @@ def init(
90
93
  simple_processor_console = SimpleSpanProcessor(console_exporter)
91
94
 
92
95
  if write_spans_to_console:
96
+ print(Fore.BLUE + "Writing spans to console" + Fore.RESET)
93
97
  provider.add_span_processor(simple_processor_console)
94
98
 
95
99
  elif custom_remote_exporter is not None:
100
+ print(Fore.BLUE + f"Exporting spans to custom remote exporter.." + Fore.RESET)
96
101
  if batch:
97
102
  provider.add_span_processor(batch_processor_remote)
98
103
  else:
99
104
  provider.add_span_processor(simple_processor_remote)
100
105
 
101
106
  elif api_host is not None:
107
+ print(Fore.BLUE + f"Exporting spans to custom host: {api_host}.." + Fore.RESET)
102
108
  if batch:
103
109
  provider.add_span_processor(batch_processor_remote)
104
110
  else:
105
111
  provider.add_span_processor(simple_processor_remote)
106
112
  else:
113
+ print(Fore.BLUE + "Exporting spans to Langtrace cloud.." + Fore.RESET)
107
114
  provider.add_span_processor(batch_processor_remote)
108
115
 
109
116
  # Initialize tracer
@@ -15,25 +15,25 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  import asyncio
18
+ import os
18
19
  from functools import wraps
19
20
  from typing import Optional
20
21
 
22
+ import requests
23
+ from opentelemetry import baggage, context, trace
24
+ from opentelemetry.trace import SpanKind
25
+
21
26
  from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
22
27
  LANGTRACE_REMOTE_URL,
23
28
  )
29
+ from langtrace_python_sdk.constants.instrumentation.common import (
30
+ LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
31
+ )
24
32
  from langtrace_python_sdk.utils.types import (
25
33
  EvaluationAPIData,
26
34
  LangTraceApiError,
27
35
  LangTraceEvaluation,
28
36
  )
29
- from opentelemetry import baggage, context, trace
30
- from opentelemetry.trace import SpanKind
31
-
32
- from langtrace_python_sdk.constants.instrumentation.common import (
33
- LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
34
- )
35
- import os
36
- import requests
37
37
 
38
38
 
39
39
  def with_langtrace_root_span(
@@ -126,7 +126,6 @@ def send_user_feedback(data: EvaluationAPIData) -> None:
126
126
  timeout=None,
127
127
  )
128
128
  response.raise_for_status()
129
- print("SENDING FEEDBACK PUT", response.status_code, response.text)
130
129
 
131
130
  else:
132
131
  # Make a POST request to create a new evaluation
@@ -137,7 +136,6 @@ def send_user_feedback(data: EvaluationAPIData) -> None:
137
136
  headers=headers,
138
137
  timeout=None,
139
138
  )
140
- print("Response", response.status_code, response.text)
141
139
  response.raise_for_status()
142
140
 
143
141
  except requests.RequestException as err:
@@ -161,7 +159,7 @@ def _get_evaluation(span_id: str) -> Optional[LangTraceEvaluation]:
161
159
  headers={"x-api-key": os.environ["LANGTRACE_API_KEY"]},
162
160
  timeout=None,
163
161
  )
164
- evaluations = response.json()["evaluations"]
162
+ evaluations = response.json().get("evaluations", [])
165
163
  response.raise_for_status()
166
164
  return None if not evaluations else evaluations[0]
167
165
 
@@ -0,0 +1 @@
1
+ __version__ = "2.1.4"
@@ -0,0 +1,106 @@
1
+ interactions:
2
+ - request:
3
+ body: '{"messages": [{"content": "You are world class technical documentation
4
+ writer.", "role": "system"}, {"content": "how can langsmith help with testing?",
5
+ "role": "user"}], "model": "gpt-3.5-turbo", "n": 1, "stream": false, "temperature":
6
+ 0.7}'
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ accept-encoding:
11
+ - gzip, deflate
12
+ connection:
13
+ - keep-alive
14
+ content-length:
15
+ - '240'
16
+ content-type:
17
+ - application/json
18
+ host:
19
+ - api.openai.com
20
+ user-agent:
21
+ - OpenAI/Python 1.30.5
22
+ x-stainless-arch:
23
+ - arm64
24
+ x-stainless-async:
25
+ - 'false'
26
+ x-stainless-lang:
27
+ - python
28
+ x-stainless-os:
29
+ - MacOS
30
+ x-stainless-package-version:
31
+ - 1.30.5
32
+ x-stainless-runtime:
33
+ - CPython
34
+ x-stainless-runtime-version:
35
+ - 3.12.3
36
+ method: POST
37
+ uri: https://api.openai.com/v1/chat/completions
38
+ response:
39
+ body:
40
+ string: !!binary |
41
+ H4sIAAAAAAAAA3xVTW8bOQy9+1cQc7aNfLR16tv2A4tFt9hL9rRdBLSGnlGikVSSsuMt8t8X1Iwd
42
+ pwh6MWxRfHp8fKR/zAAa3zZraFyP6oYcFu//br/s3+271XUeVvfb+0f6cvv4x8MHyjf4tZlbRtrc
43
+ k9Nj1tKlIQdSn+IYdkyoZKiXq8vVxc3NxeqmBobUUrC0Luvievl2oYU3aXFxefV2yuyTdyTNGv6Z
44
+ AQD8qJ/GMbb02KzhYn48GUgEO2rWp0sADadgJw2KeFGM2syfgy5FpVhp/4mxk8FrD14AIac98bYE
45
+ 0JQCaI8KDiP0FDLs7ZaSqI8d+Ag7ZJ+KwB4Psv4Wv8XLJfxWNA1WMtyOF9fw/IIhbQiKUAuaYM9e
46
+ CfCUYdAgjn1WgW1iOKTCIGmre2QCzDl4hyauLOHDAQLtiLGrbFQgohbGAAFjV7AjyJwciVjcYcaN
47
+ D149ydxwK5eRQH3WoZBYUTmgj/A5dsFLP4cBH0Z8IBRPXHnFFBdKro/eYQAlHGCgYUMsVpaJy35T
48
+ DDqB9nTSbCK0NK2ullUh+ISK8DtF4lrZz3J1Y2Ri2drlDZp+KUJmamnrI7XAJZAAxhYyqhJHmdee
49
+ 2atW7ffi3UM4wOjHZzChc6lfKnzbezm2LCOrdyUgh4P1zxxiacfKxFE0N8hoGabvxVvLICB3BDik
50
+ EhXSFlq/Ixaqj1cdricdPqIQfMWIHQ0U9Re2Sdxh9P9RLXeoGWc9fKVl1gVG91B7kTl1TCJG5sge
51
+ nfpd9UbFpCiFCWyWmXqK4nf2q5qNLO8XvrSS3izhU3LFyni1pxgknU1UO901Jud11O9MUoLKvBJL
52
+ 2tNJ8wVTqGPj4zbxUF+qYzENlHkzHI4GMvD2nJR5HUGUi9PC1MII8jwcJxWiLRCK7lA5uIDs9WDp
53
+ VYajhi/Aqwx/mWAhzH+qXpQJh+AjvTYbc/BD5rQ7tnRSfT41psfojFMIuEnjxJi5qnJnU+jjLoVd
54
+ 1eaVJi+baRM+nVZoSF3mtLF1G0sIp/Otj176OyaUFG1diqY8pj/NAP6tq7q82L5N5jRkvdP0QNEA
55
+ r1YjXPP853AWvHw/RTUphrPAm3eziWEjB1Ea7rY+dsSZfd3cxnP2NPsfAAD//wMAt4ZeGbgGAAA=
56
+ headers:
57
+ CF-Cache-Status:
58
+ - DYNAMIC
59
+ CF-RAY:
60
+ - 88c03f46bf3b23c5-LHR
61
+ Connection:
62
+ - keep-alive
63
+ Content-Encoding:
64
+ - gzip
65
+ Content-Type:
66
+ - application/json
67
+ Date:
68
+ - Thu, 30 May 2024 16:54:42 GMT
69
+ Server:
70
+ - cloudflare
71
+ Set-Cookie:
72
+ - __cf_bm=9en.DN2CPQUgM8CubXIqqiVZkm43q.oBCL4n7bXxViw-1717088082-1.0.1.1-nl9dbPbwwGsUORjX1Y8Ta7S2v.MBG3o1JWUgYQU98tFUNcY9hFcmfcXWFu_bcohUX1nun6S55Wg2rg3MX7PHPQ;
73
+ path=/; expires=Thu, 30-May-24 17:24:42 GMT; domain=.api.openai.com; HttpOnly;
74
+ Secure; SameSite=None
75
+ - _cfuvid=bJ_po6.pyb_9JWu27O8yfh1AX1atGjC5_sFN497eMI8-1717088082420-0.0.1.1-604800000;
76
+ path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
77
+ Transfer-Encoding:
78
+ - chunked
79
+ alt-svc:
80
+ - h3=":443"; ma=86400
81
+ openai-organization:
82
+ - scale3-1
83
+ openai-processing-ms:
84
+ - '4295'
85
+ openai-version:
86
+ - '2020-10-01'
87
+ strict-transport-security:
88
+ - max-age=15724800; includeSubDomains
89
+ x-ratelimit-limit-requests:
90
+ - '10000'
91
+ x-ratelimit-limit-tokens:
92
+ - '2000000'
93
+ x-ratelimit-remaining-requests:
94
+ - '9999'
95
+ x-ratelimit-remaining-tokens:
96
+ - '1999960'
97
+ x-ratelimit-reset-requests:
98
+ - 6ms
99
+ x-ratelimit-reset-tokens:
100
+ - 1ms
101
+ x-request-id:
102
+ - req_4b43c2d3cf0dc839647c8b775b75d6f5
103
+ status:
104
+ code: 200
105
+ message: OK
106
+ version: 1
@@ -0,0 +1,42 @@
1
+ """Unit tests configuration module."""
2
+
3
+ import os
4
+ import pytest
5
+
6
+ from langtrace_python_sdk.instrumentation.openai.instrumentation import (
7
+ OpenAIInstrumentation,
8
+ )
9
+ from langtrace_python_sdk.instrumentation.langchain.instrumentation import (
10
+ LangchainInstrumentation,
11
+ )
12
+ from langtrace_python_sdk.instrumentation.langchain_core.instrumentation import (
13
+ LangchainCoreInstrumentation,
14
+ )
15
+
16
+ from langtrace_python_sdk.instrumentation.langchain_community.instrumentation import (
17
+ LangchainCommunityInstrumentation,
18
+ )
19
+
20
+
21
+ @pytest.fixture(autouse=True)
22
+ def clear_exporter(exporter):
23
+ exporter.clear()
24
+
25
+
26
+ @pytest.fixture(autouse=True)
27
+ def environment():
28
+ if not os.environ.get("OPENAI_API_KEY"):
29
+ os.environ["OPENAI_API_KEY"] = "test"
30
+
31
+
32
+ @pytest.fixture(scope="module")
33
+ def vcr_config():
34
+ return {"filter_headers": ["authorization", "x-api-key"]}
35
+
36
+
37
+ @pytest.fixture(scope="session", autouse=True)
38
+ def instrument():
39
+ OpenAIInstrumentation().instrument()
40
+ LangchainInstrumentation().instrument()
41
+ LangchainCoreInstrumentation().instrument()
42
+ LangchainCommunityInstrumentation().instrument()
@@ -0,0 +1,28 @@
1
+ import pytest
2
+ from langchain_openai import ChatOpenAI
3
+ from langchain_core.prompts.chat import ChatPromptTemplate
4
+ from langchain_core.output_parsers import StrOutputParser
5
+
6
+
7
+ @pytest.mark.vcr()
8
+ def test_langchain(exporter):
9
+ llm = ChatOpenAI()
10
+ prompt = ChatPromptTemplate.from_messages(
11
+ [
12
+ ("system", "You are world class technical documentation writer."),
13
+ ("user", "{input}"),
14
+ ]
15
+ )
16
+ output_parser = StrOutputParser()
17
+ chain = prompt | llm | output_parser
18
+ chain.invoke({"input": "how can langsmith help with testing?"})
19
+ spans = exporter.get_finished_spans()
20
+
21
+ assert [
22
+ "ChatPromptTemplate.invoke",
23
+ "openai.chat.completions.create",
24
+ "StrOutputParser.parse",
25
+ "StrOutputParser.parse_result",
26
+ "StrOutputParser.invoke",
27
+ "RunnableSequence.invoke",
28
+ ] == [span.name for span in spans]
@@ -1 +0,0 @@
1
- __version__ = "2.1.1"