langtrace-python-sdk 2.0.7__tar.gz → 2.0.9__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 (143) hide show
  1. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/.gitignore +3 -0
  2. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/PKG-INFO +13 -1
  3. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/README.md +9 -0
  4. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/pyproject.toml +5 -2
  5. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/pinecone_example/basic.py +9 -8
  6. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/__init__.py +2 -1
  7. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/common.py +1 -0
  8. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +56 -0
  9. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +35 -3
  10. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/langtrace.py +3 -1
  11. langtrace_python_sdk-2.0.9/src/langtrace_python_sdk/utils/__init__.py +7 -0
  12. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/utils/llm.py +8 -0
  13. langtrace_python_sdk-2.0.9/src/langtrace_python_sdk/utils/prompt_registry.py +82 -0
  14. langtrace_python_sdk-2.0.9/src/langtrace_python_sdk/utils/silently_fail.py +19 -0
  15. langtrace_python_sdk-2.0.9/src/langtrace_python_sdk/version.py +1 -0
  16. langtrace_python_sdk-2.0.9/src/tests/chroma/conftest.py +15 -0
  17. langtrace_python_sdk-2.0.9/src/tests/chroma/test_chroma.py +31 -0
  18. langtrace_python_sdk-2.0.9/src/tests/pinecone/cassettes/test_query.yaml +822 -0
  19. langtrace_python_sdk-2.0.9/src/tests/pinecone/cassettes/test_upsert.yaml +565 -0
  20. langtrace_python_sdk-2.0.9/src/tests/pinecone/conftest.py +39 -0
  21. langtrace_python_sdk-2.0.9/src/tests/pinecone/test_pinecone.py +91 -0
  22. langtrace_python_sdk-2.0.9/src/tests/qdrant/conftest.py +19 -0
  23. langtrace_python_sdk-2.0.9/src/tests/qdrant/test_qdrant.py +92 -0
  24. langtrace_python_sdk-2.0.7/src/langtrace_python_sdk/version.py +0 -1
  25. langtrace_python_sdk-2.0.7/src/tests/chroma/test_chroma.py +0 -70
  26. langtrace_python_sdk-2.0.7/src/tests/pinecone/test_pinecone.py +0 -81
  27. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/LICENSE +0 -0
  28. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/__init__.py +0 -0
  29. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/__init__.py +0 -0
  30. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/anthropic_example/__init__.py +0 -0
  31. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/anthropic_example/completion.py +0 -0
  32. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/chroma_example/__init__.py +0 -0
  33. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/chroma_example/basic.py +0 -0
  34. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/cohere_example/__init__.py +0 -0
  35. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/cohere_example/chat.py +0 -0
  36. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/cohere_example/chat_stream.py +0 -0
  37. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/cohere_example/embed.py +0 -0
  38. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/cohere_example/rerank.py +0 -0
  39. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/cohere_example/tools.py +0 -0
  40. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/fastapi_example/basic_route.py +0 -0
  41. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/hiveagent_example/basic.py +0 -0
  42. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/langchain_example/__init__.py +0 -0
  43. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/langchain_example/basic.py +0 -0
  44. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/langchain_example/groq_example.py +0 -0
  45. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/langchain_example/langgraph_example.py +0 -0
  46. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/langchain_example/tool.py +0 -0
  47. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/llamaindex_example/__init__.py +0 -0
  48. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/llamaindex_example/agent.py +0 -0
  49. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/llamaindex_example/basic.py +0 -0
  50. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  51. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/__init__.py +0 -0
  52. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  53. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  54. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/chat_completion.py +0 -0
  55. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/embeddings_create.py +0 -0
  56. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/function_calling.py +0 -0
  57. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/images_generate.py +0 -0
  58. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/tool_calling.py +0 -0
  59. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  60. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  61. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/perplexity_example/basic.py +0 -0
  62. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/pinecone_example/__init__.py +0 -0
  63. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/qdrant_example/__init__.py +0 -0
  64. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/examples/qdrant_example/basic.py +0 -0
  65. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  66. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  67. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  68. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  69. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  70. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
  71. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  72. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  73. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  74. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  75. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  76. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
  77. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  78. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  79. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  80. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  81. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  82. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  83. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
  84. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  85. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
  86. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +0 -0
  87. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  88. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  89. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
  90. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  91. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  92. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
  93. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  94. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  95. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
  96. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  97. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  98. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
  99. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  100. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  101. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
  102. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  103. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  104. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
  105. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  106. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  107. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
  108. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  109. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
  110. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  111. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  112. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/types/__init__.py +0 -0
  113. /langtrace_python_sdk-2.0.7/src/langtrace_python_sdk/utils/__init__.py → /langtrace_python_sdk-2.0.9/src/langtrace_python_sdk/utils/types.py +0 -0
  114. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
  115. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/run_example.py +0 -0
  116. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/__init__.py +0 -0
  117. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  118. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  119. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  120. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/anthropic/conftest.py +0 -0
  121. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/anthropic/test_anthropic.py +0 -0
  122. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  123. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  124. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  125. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  126. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/conftest.py +0 -0
  127. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/test_cohere_chat.py +0 -0
  128. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/test_cohere_embed.py +0 -0
  129. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/cohere/test_cohere_rerank.py +0 -0
  130. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/conftest.py +0 -0
  131. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/langchain/test_langchain.py +0 -0
  132. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/langchain/test_langchain_community.py +0 -0
  133. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/langchain/test_langchain_core.py +0 -0
  134. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  135. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  136. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  137. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  138. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  139. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/conftest.py +0 -0
  140. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/test_chat_completion.py +0 -0
  141. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/test_embeddings.py +0 -0
  142. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/openai/test_image_generation.py +0 -0
  143. {langtrace_python_sdk-2.0.7 → langtrace_python_sdk-2.0.9}/src/tests/utils.py +0 -0
@@ -152,6 +152,9 @@ dmypy.json
152
152
  # Cython debug symbols
153
153
  cython_debug/
154
154
 
155
+ # Test artifcats
156
+ chroma.sqlite3
157
+
155
158
  # PyCharm
156
159
  # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
160
  # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.0.7
3
+ Version: 2.0.9
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>
@@ -21,11 +21,14 @@ Requires-Dist: anthropic; extra == 'dev'
21
21
  Requires-Dist: chromadb; extra == 'dev'
22
22
  Requires-Dist: cohere; extra == 'dev'
23
23
  Requires-Dist: langchain; extra == 'dev'
24
+ Requires-Dist: langchain-community; extra == 'dev'
24
25
  Requires-Dist: langchain-openai; extra == 'dev'
25
26
  Requires-Dist: llama-index; extra == 'dev'
26
27
  Requires-Dist: openai; extra == 'dev'
27
28
  Requires-Dist: python-dotenv; extra == 'dev'
29
+ Requires-Dist: qdrant-client; extra == 'dev'
28
30
  Provides-Extra: test
31
+ Requires-Dist: protobuf==3.20.0; extra == 'test'
29
32
  Requires-Dist: pytest; extra == 'test'
30
33
  Requires-Dist: pytest-asyncio; extra == 'test'
31
34
  Requires-Dist: pytest-vcr; extra == 'test'
@@ -217,6 +220,15 @@ def chat_completion():
217
220
  api_call2()
218
221
  ```
219
222
 
223
+ - `get_prompt_from_registry` - this function is designed to fetch the desired prompt from the `Prompt Registry`. You can pass two options for filtering `prompt_version` & `variables`.
224
+
225
+
226
+ ```python
227
+ from langtrace_python_sdk import get_prompt_from_registry
228
+
229
+ prompt = get_prompt_from_registry(<Registry ID>, options={"prompt_version": 1, "variables": {"foo": "bar"} })
230
+ ```
231
+
220
232
  ## Supported integrations
221
233
 
222
234
  Langtrace automatically captures traces from the following vendors:
@@ -184,6 +184,15 @@ def chat_completion():
184
184
  api_call2()
185
185
  ```
186
186
 
187
+ - `get_prompt_from_registry` - this function is designed to fetch the desired prompt from the `Prompt Registry`. You can pass two options for filtering `prompt_version` & `variables`.
188
+
189
+
190
+ ```python
191
+ from langtrace_python_sdk import get_prompt_from_registry
192
+
193
+ prompt = get_prompt_from_registry(<Registry ID>, options={"prompt_version": 1, "variables": {"foo": "bar"} })
194
+ ```
195
+
187
196
  ## Supported integrations
188
197
 
189
198
  Langtrace automatically captures traces from the following vendors:
@@ -34,17 +34,20 @@ dev = [
34
34
  "anthropic",
35
35
  "python-dotenv",
36
36
  "langchain",
37
+ 'langchain-community',
37
38
  "langchain-openai",
38
39
  "llama-index",
39
40
  "langchain-openai",
40
41
  "chromadb",
41
- "cohere"
42
+ "cohere",
43
+ "qdrant_client"
42
44
  ]
43
45
 
44
46
  test = [
45
47
  "pytest",
46
48
  "pytest-vcr",
47
- "pytest-asyncio"
49
+ "pytest-asyncio",
50
+ "protobuf==3.20.0",
48
51
  ]
49
52
 
50
53
 
@@ -2,19 +2,16 @@
2
2
  This example demonstrates how to use Pinecone with Langtrace.
3
3
  """
4
4
 
5
+ from langtrace_python_sdk import langtrace
5
6
  from dotenv import find_dotenv, load_dotenv
6
7
  from openai import OpenAI
7
8
  from pinecone import Pinecone
8
9
 
9
- from langtrace_python_sdk import langtrace
10
10
  from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
11
11
 
12
12
  _ = load_dotenv(find_dotenv())
13
13
 
14
- langtrace.init(
15
- write_spans_to_console=True,
16
- disable_instrumentations={"all_except": ["pinecone", "openai"]},
17
- )
14
+ langtrace.init()
18
15
 
19
16
  client = OpenAI()
20
17
  pinecone = Pinecone()
@@ -30,10 +27,14 @@ def basic():
30
27
 
31
28
  embedding = result.data[0].embedding
32
29
 
33
- unique_id = "randomid"
30
+ unique_id = "unique_random_id"
34
31
  data_to_upsert = {"id": unique_id, "values": embedding}
35
32
 
36
33
  index = pinecone.Index("test-index")
37
- index.upsert(vectors=[data_to_upsert])
34
+ res = index.upsert(vectors=[data_to_upsert], namespace="test-namespace")
35
+ print("res", res)
38
36
 
39
- resp = index.query(vector=embedding, top_k=1)
37
+ resp = index.query(
38
+ vector=embedding, top_k=1, include_values=False, namespace="test-namespace"
39
+ )
40
+ print(resp)
@@ -16,5 +16,6 @@ limitations under the License.
16
16
 
17
17
  from langtrace_python_sdk import langtrace
18
18
  from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
19
+ from langtrace_python_sdk.utils.prompt_registry import get_prompt_from_registry
19
20
 
20
- __all__ = ["langtrace", "with_langtrace_root_span"]
21
+ __all__ = ["langtrace", "with_langtrace_root_span", "get_prompt_from_registry"]
@@ -4,6 +4,7 @@ TIKTOKEN_MODEL_MAPPING = {
4
4
  "gpt-4-0125-preview": "cl100k_base",
5
5
  "gpt-4-1106-preview": "cl100k_base",
6
6
  "gpt-4-1106-vision-preview": "cl100k_base",
7
+ "gpt-4o": "0200k_base",
7
8
  }
8
9
 
9
10
  SERVICE_PROVIDERS = {
@@ -15,6 +15,8 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  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
18
20
  from opentelemetry import baggage
19
21
  from opentelemetry.trace import SpanKind
20
22
  from opentelemetry.trace.status import Status, StatusCode
@@ -24,6 +26,7 @@ from langtrace_python_sdk.constants.instrumentation.common import (
24
26
  SERVICE_PROVIDERS,
25
27
  )
26
28
  from langtrace_python_sdk.constants.instrumentation.pinecone import APIS
29
+ import json
27
30
 
28
31
 
29
32
  def generic_patch(original_method, method, version, tracer):
@@ -49,12 +52,21 @@ def generic_patch(original_method, method, version, tracer):
49
52
  attributes = DatabaseSpanAttributes(**span_attributes)
50
53
 
51
54
  with tracer.start_as_current_span(api["METHOD"], kind=SpanKind.CLIENT) as span:
55
+
56
+ if span.is_recording():
57
+ set_span_attribute(span, "server.address", instance._config.host)
58
+ if method == "QUERY":
59
+ set_query_input_attributes(span, kwargs)
60
+
52
61
  for field, value in attributes.model_dump(by_alias=True).items():
53
62
  if value is not None:
54
63
  span.set_attribute(field, value)
55
64
  try:
56
65
  # Attempt to call the original method
57
66
  result = original_method(instance, *args, **kwargs)
67
+ if result:
68
+ if span.is_recording():
69
+ set_query_response_attributes(span, result)
58
70
  span.set_status(StatusCode.OK)
59
71
  return result
60
72
  except Exception as err:
@@ -67,4 +79,48 @@ def generic_patch(original_method, method, version, tracer):
67
79
  # Reraise the exception to ensure it's not swallowed
68
80
  raise
69
81
 
82
+ @silently_fail
83
+ def set_query_input_attributes(span, kwargs):
84
+ set_span_attribute(span, "db.query.top_k", kwargs.get("top_k"))
85
+ set_span_attribute(span, "db.query.namespace", kwargs.get("namespace"))
86
+ set_span_attribute(span, "db.query.id", kwargs.get("id"))
87
+ filter = (
88
+ json.dumps(kwargs.get("filter"))
89
+ if isinstance(kwargs.get("filter"), dict)
90
+ else kwargs.get("filter")
91
+ )
92
+ set_span_attribute(span, "db.query.filter", filter)
93
+ set_span_attribute(
94
+ span, "db.query.include_values", kwargs.get("include_values")
95
+ )
96
+ set_span_attribute(
97
+ span, "db.query.include_metadata", kwargs.get("include_metadata")
98
+ )
99
+
100
+ @silently_fail
101
+ def set_query_response_attributes(span, response):
102
+ matches = response.get("matches")
103
+
104
+ usage = response.get("usage")
105
+ for match in matches:
106
+ span.add_event(
107
+ name="db.query.match",
108
+ attributes={
109
+ "db.query.match.id": match.get("id"),
110
+ "db.query.match.score": match.get("score"),
111
+ "db.query.match.metadata": match.get("metadata"),
112
+ # "db.query.match.values": match.get("values"),
113
+ },
114
+ )
115
+
116
+ if "read_units" in usage:
117
+ set_span_attribute(
118
+ span, "db.query.usage.read_units", usage.get("read_units")
119
+ )
120
+
121
+ if "write_units" in usage:
122
+ set_span_attribute(
123
+ span, "db.query.usage.write_units", usage.get("write_units")
124
+ )
125
+
70
126
  return traced_method
@@ -15,6 +15,8 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  from langtrace.trace_attributes import DatabaseSpanAttributes
18
+ from langtrace_python_sdk.utils.silently_fail import silently_fail
19
+ from langtrace_python_sdk.utils.llm import set_span_attributes
18
20
  from opentelemetry import baggage
19
21
  from opentelemetry.trace import SpanKind
20
22
  from opentelemetry.trace.status import Status, StatusCode
@@ -47,12 +49,19 @@ def collection_patch(method, version, tracer):
47
49
  **(extra_attributes if extra_attributes is not None else {}),
48
50
  }
49
51
 
50
- if hasattr(instance, "name") and instance.name is not None:
51
- span_attributes["db.collection.name"] = instance.name
52
-
53
52
  attributes = DatabaseSpanAttributes(**span_attributes)
54
53
 
55
54
  with tracer.start_as_current_span(api["METHOD"], kind=SpanKind.CLIENT) as span:
55
+ collection_name = kwargs.get("collection_name") or args[0]
56
+ operation = api["OPERATION"]
57
+ set_span_attributes(span, "db.collection.name", collection_name)
58
+ if operation == "upsert":
59
+ _set_upsert_attributes(span, args, kwargs)
60
+ elif operation == "add":
61
+ _set_upload_attributes(span, args, kwargs, "documents")
62
+
63
+ # Todo: Add support for other operations here.
64
+
56
65
  for field, value in attributes.model_dump(by_alias=True).items():
57
66
  if value is not None:
58
67
  span.set_attribute(field, value)
@@ -72,3 +81,26 @@ def collection_patch(method, version, tracer):
72
81
  raise
73
82
 
74
83
  return traced_method
84
+
85
+
86
+ @silently_fail
87
+ def _set_upsert_attributes(span, args, kwargs):
88
+ points = kwargs.get("points") or args[1]
89
+ if isinstance(points, list):
90
+ length = len(points)
91
+ else:
92
+ # In case of using Batch.
93
+ length = len(points.ids)
94
+ set_span_attributes(span, "db.upsert.points_count", length)
95
+
96
+
97
+ @silently_fail
98
+ def _set_upload_attributes(span, args, kwargs, field):
99
+ docs = kwargs.get(field) or args[0]
100
+ if isinstance(docs, list):
101
+ length = len(docs)
102
+ else:
103
+ # In case of using Batch.
104
+ length = len(docs.ids)
105
+
106
+ set_span_attributes(span, f"db.upload.{field}_count", length)
@@ -24,6 +24,8 @@ from opentelemetry.sdk.trace.export import (
24
24
  ConsoleSpanExporter,
25
25
  SimpleSpanProcessor,
26
26
  )
27
+ import sys
28
+ from opentelemetry.sdk.resources import Resource
27
29
 
28
30
  from langtrace_python_sdk.extensions.langtrace_exporter import LangTraceExporter
29
31
  from langtrace_python_sdk.instrumentation.anthropic.instrumentation import (
@@ -72,7 +74,7 @@ def init(
72
74
  api_host: Optional[str] = None,
73
75
  disable_instrumentations: Optional[DisableInstrumentations] = None,
74
76
  ):
75
- provider = TracerProvider()
77
+ provider = TracerProvider(resource=Resource.create({"service.name": sys.argv[0]}))
76
78
 
77
79
  remote_write_exporter = (
78
80
  LangTraceExporter(api_key=api_key, api_host=api_host)
@@ -0,0 +1,7 @@
1
+ def set_span_attribute(span, name, value):
2
+ if value is not None:
3
+ if value != "":
4
+ span.set_attribute(name, value)
5
+ return
6
+
7
+
@@ -58,3 +58,11 @@ def calculate_price_from_usage(model, usage):
58
58
  + cost_table["output"] * usage["completion_tokens"]
59
59
  ) / 1000
60
60
  return 0
61
+
62
+
63
+ def set_span_attributes(span, name, value):
64
+ if value is not None:
65
+ if value != "":
66
+ span.set_attribute(name, value)
67
+ return
68
+
@@ -0,0 +1,82 @@
1
+ import os
2
+ from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
3
+ LANGTRACE_REMOTE_URL,
4
+ )
5
+ import requests
6
+ from urllib.parse import urlencode
7
+ from typing import Optional, TypedDict, Dict, List
8
+
9
+
10
+ class LangtracePrompt(TypedDict):
11
+ id: str
12
+ value: str
13
+ variables: List[str]
14
+ model: str
15
+ modelSettings: Dict[str, object]
16
+ version: int
17
+ live: bool
18
+ tags: List[str]
19
+ note: str
20
+ promptsetId: str
21
+ createdAt: str
22
+ updatedAt: str
23
+
24
+
25
+ class FetchOptions(TypedDict, total=False):
26
+ prompt_version: int
27
+ variables: Dict[str, str]
28
+
29
+
30
+ def get_prompt_from_registry(
31
+ prompt_registry_id: str,
32
+ options: Optional[FetchOptions] = None,
33
+ ) -> LangtracePrompt:
34
+ """Fetches a prompt from the registry.
35
+
36
+ Args:
37
+ prompt_registry_id (str): The ID of the prompt registry.
38
+ options (dict, optional): Configuration options for fetching the prompt:
39
+ - prompt_version (int): Fetches the prompt with the specified version.
40
+ - variables (dict): Replaces variables in the prompt with provided values.
41
+
42
+ Returns:
43
+ dict: The fetched prompt with variables replaced as specified.
44
+
45
+ Raises:
46
+ Exception: If the fetch operation fails or returns an error.
47
+ """
48
+ try:
49
+ query_params = {"promptset_id": prompt_registry_id}
50
+ if options:
51
+ if "prompt_version" in options:
52
+ query_params["version"] = options["prompt_version"]
53
+ if "variables" in options:
54
+ for key, value in options["variables"].items():
55
+ query_params[f"variables.{key}"] = value
56
+ # Encode the query parameters
57
+ query_string = urlencode(query_params, doseq=True)
58
+ headers = {"x-api-key": os.environ["LANGTRACE_API_KEY"]}
59
+ print(query_params)
60
+ # Make the GET request to the API
61
+ response = requests.get(
62
+ f"{LANGTRACE_REMOTE_URL}/api/promptset?{query_string}",
63
+ headers=headers,
64
+ timeout=None,
65
+ )
66
+ response.raise_for_status()
67
+
68
+ # Extract the prompt data from the response
69
+ prompt_data = response.json()["prompts"][0]
70
+ return prompt_data
71
+
72
+ except requests.RequestException as err:
73
+ # Handle specific HTTP errors or general request exceptions
74
+ error_msg = str(err)
75
+ if err.response:
76
+ try:
77
+ # Try to extract server-provided error message
78
+ error_msg = err.response.json().get("error", error_msg)
79
+ except ValueError:
80
+ # Fallback if response is not JSON
81
+ error_msg = err.response.text
82
+ raise Exception(f"API error: {error_msg}") from err
@@ -0,0 +1,19 @@
1
+ import logging
2
+
3
+
4
+ def silently_fail(func):
5
+ """
6
+ A decorator that catches exceptions thrown by the decorated function and logs them as warnings.
7
+ """
8
+
9
+ logger = logging.getLogger(func.__module__)
10
+
11
+ def wrapper(*args, **kwargs):
12
+ try:
13
+ return func(*args, **kwargs)
14
+ except Exception as exception:
15
+ logger.warning(
16
+ "Failed to execute %s, error: %s", func.__name__, str(exception)
17
+ )
18
+
19
+ return wrapper
@@ -0,0 +1 @@
1
+ __version__ = "2.0.9"
@@ -0,0 +1,15 @@
1
+ import chromadb
2
+ import pytest
3
+ from langtrace_python_sdk.instrumentation.chroma.instrumentation import (
4
+ ChromaInstrumentation,
5
+ )
6
+
7
+
8
+ @pytest.fixture
9
+ def chroma_client():
10
+ return chromadb.Client()
11
+
12
+
13
+ @pytest.fixture(scope="session", autouse=True)
14
+ def instrument():
15
+ ChromaInstrumentation().instrument()
@@ -0,0 +1,31 @@
1
+ import importlib
2
+ from chromadb.utils import embedding_functions
3
+ from langtrace_python_sdk.constants.instrumentation.common import SERVICE_PROVIDERS
4
+
5
+ COLLECTION_NAME = "test_collection"
6
+
7
+
8
+ def test_chroma_add(chroma_client, exporter):
9
+ embedder = embedding_functions.DefaultEmbeddingFunction()
10
+ collection = chroma_client.create_collection(
11
+ name=COLLECTION_NAME, embedding_function=embedder
12
+ )
13
+ collection.add(
14
+ documents=["This is a document", "This is another document"],
15
+ metadatas=[{"source": "my_source"}, {"source": "my_source"}],
16
+ ids=["id1", "id2"],
17
+ )
18
+ spans = exporter.get_finished_spans()
19
+ chroma_span = spans[-1]
20
+
21
+ attributes = chroma_span.attributes
22
+
23
+ assert attributes.get("db.collection.name") == COLLECTION_NAME
24
+ assert attributes.get("db.operation") == "add"
25
+ assert attributes.get("db.system") == "chromadb"
26
+ assert attributes.get("langtrace.sdk.name") == "langtrace-python-sdk"
27
+ assert attributes.get("langtrace.service.name") == SERVICE_PROVIDERS["CHROMA"]
28
+ assert attributes.get("langtrace.service.type") == "vectordb"
29
+ assert attributes.get("langtrace.service.version") == importlib.metadata.version(
30
+ "chromadb"
31
+ )