langtrace-python-sdk 2.1.17__tar.gz → 2.1.19__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 (163) hide show
  1. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/PKG-INFO +2 -1
  2. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/pyproject.toml +1 -0
  3. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/inspect_ai_example/basic_eval.py +3 -7
  4. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/langchain_example/basic.py +23 -8
  5. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/llamaindex_example/agent.py +1 -1
  6. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/llamaindex_example/basic.py +5 -1
  7. langtrace_python_sdk-2.1.19/src/examples/ollama_example/__init__.py +14 -0
  8. langtrace_python_sdk-2.1.19/src/examples/ollama_example/basic.py +50 -0
  9. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/chat_completion.py +1 -1
  10. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/pinecone_example/basic.py +1 -0
  11. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/__init__.py +6 -4
  12. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/common.py +1 -0
  13. langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/constants/instrumentation/ollama.py +7 -0
  14. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +1 -1
  15. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +31 -15
  16. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/__init__.py +2 -0
  17. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +7 -3
  18. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/groq/patch.py +5 -2
  19. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +8 -2
  20. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +8 -2
  21. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +13 -3
  22. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +7 -2
  23. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +7 -3
  24. langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +3 -0
  25. langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +58 -0
  26. langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/instrumentation/ollama/patch.py +215 -0
  27. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/openai/patch.py +20 -8
  28. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -1
  29. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +7 -3
  30. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +7 -2
  31. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +7 -3
  32. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/langtrace.py +14 -2
  33. langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/types/__init__.py +106 -0
  34. langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/utils/langtrace_sampler.py +56 -0
  35. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/with_root_span.py +11 -2
  36. langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/version.py +1 -0
  37. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/run_example.py +10 -2
  38. langtrace_python_sdk-2.1.17/src/langtrace_python_sdk/types/__init__.py +0 -30
  39. langtrace_python_sdk-2.1.17/src/langtrace_python_sdk/version.py +0 -1
  40. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/.gitignore +0 -0
  41. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/LICENSE +0 -0
  42. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/README.md +0 -0
  43. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/__init__.py +0 -0
  44. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/__init__.py +0 -0
  45. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/anthropic_example/__init__.py +0 -0
  46. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/anthropic_example/completion.py +0 -0
  47. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/chroma_example/__init__.py +0 -0
  48. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/chroma_example/basic.py +0 -0
  49. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/cohere_example/__init__.py +0 -0
  50. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/cohere_example/chat.py +0 -0
  51. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/cohere_example/chat_stream.py +0 -0
  52. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/cohere_example/embed.py +0 -0
  53. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/cohere_example/rerank.py +0 -0
  54. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/cohere_example/tools.py +0 -0
  55. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/fastapi_example/__init__.py +0 -0
  56. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/fastapi_example/basic_route.py +0 -0
  57. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/hiveagent_example/basic.py +0 -0
  58. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/langchain_example/__init__.py +0 -0
  59. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/langchain_example/groq_example.py +0 -0
  60. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/langchain_example/langgraph_example.py +0 -0
  61. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/langchain_example/tool.py +0 -0
  62. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/llamaindex_example/__init__.py +0 -0
  63. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  64. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/__init__.py +0 -0
  65. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  66. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  67. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/embeddings_create.py +0 -0
  68. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/function_calling.py +0 -0
  69. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/images_edit.py +0 -0
  70. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/images_generate.py +0 -0
  71. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
  72. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/resources/mask.png +0 -0
  73. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/tool_calling.py +0 -0
  74. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  75. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  76. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/perplexity_example/basic.py +0 -0
  77. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/pinecone_example/__init__.py +0 -0
  78. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/qdrant_example/__init__.py +0 -0
  79. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/qdrant_example/basic.py +0 -0
  80. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/weaviate_example/__init__.py +0 -0
  81. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/examples/weaviate_example/query_text.py +0 -0
  82. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  83. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  84. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  85. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  86. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  87. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
  88. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  89. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  90. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  91. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
  92. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  93. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
  94. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  95. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  96. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  97. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  98. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  99. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  100. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
  101. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +0 -0
  102. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  103. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  104. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  105. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  106. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  107. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  108. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  109. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  110. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  111. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  112. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  113. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  114. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  115. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  116. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  117. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  118. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  119. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
  120. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
  121. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/__init__.py +0 -0
  122. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/llm.py +0 -0
  123. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/misc.py +0 -0
  124. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
  125. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
  126. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
  127. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/langtrace_python_sdk/utils/types.py +0 -0
  128. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/__init__.py +0 -0
  129. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  130. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  131. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  132. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/anthropic/conftest.py +0 -0
  133. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/anthropic/test_anthropic.py +0 -0
  134. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/chroma/conftest.py +0 -0
  135. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/chroma/test_chroma.py +0 -0
  136. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  137. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  138. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  139. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  140. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/conftest.py +0 -0
  141. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/test_cohere_chat.py +0 -0
  142. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/test_cohere_embed.py +0 -0
  143. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/cohere/test_cohere_rerank.py +0 -0
  144. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/conftest.py +0 -0
  145. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
  146. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/langchain/conftest.py +0 -0
  147. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/langchain/test_langchain.py +0 -0
  148. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  149. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  150. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  151. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  152. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  153. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/conftest.py +0 -0
  154. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/test_chat_completion.py +0 -0
  155. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/test_embeddings.py +0 -0
  156. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/openai/test_image_generation.py +0 -0
  157. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
  158. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
  159. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/pinecone/conftest.py +0 -0
  160. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/pinecone/test_pinecone.py +0 -0
  161. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/qdrant/conftest.py +0 -0
  162. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/src/tests/qdrant/test_qdrant.py +0 -0
  163. {langtrace_python_sdk-2.1.17 → langtrace_python_sdk-2.1.19}/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.17
3
+ Version: 2.1.19
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>
@@ -28,6 +28,7 @@ Requires-Dist: cohere; extra == 'dev'
28
28
  Requires-Dist: langchain; extra == 'dev'
29
29
  Requires-Dist: langchain-community; extra == 'dev'
30
30
  Requires-Dist: langchain-openai; extra == 'dev'
31
+ Requires-Dist: ollama; extra == 'dev'
31
32
  Requires-Dist: openai; extra == 'dev'
32
33
  Requires-Dist: pinecone-client; extra == 'dev'
33
34
  Requires-Dist: python-dotenv; extra == 'dev'
@@ -49,6 +49,7 @@ dev = [
49
49
  "cohere",
50
50
  "qdrant_client",
51
51
  "weaviate-client",
52
+ "ollama"
52
53
  ]
53
54
 
54
55
  test = [
@@ -5,8 +5,7 @@ from inspect_ai.dataset import csv_dataset
5
5
  from inspect_ai.scorer import model_graded_qa
6
6
  from inspect_ai.solver import chain_of_thought, generate, self_critique
7
7
 
8
- from langtrace_python_sdk.extensions.langtrace_filesystem import \
9
- LangTraceFileSystem
8
+ from langtrace_python_sdk.extensions.langtrace_filesystem import LangTraceFileSystem
10
9
 
11
10
  # from langtrace_python_sdk import langtrace
12
11
 
@@ -20,9 +19,6 @@ fsspec.register_implementation(LangTraceFileSystem.protocol, LangTraceFileSystem
20
19
  def security_guide():
21
20
  return Task(
22
21
  dataset=csv_dataset("langtracefs://clxc2mxu6000lpc7ntsvcjvp9"),
23
- plan=[
24
- chain_of_thought(),
25
- self_critique()
26
- ],
27
- scorer=model_graded_qa()
22
+ plan=[chain_of_thought(), self_critique()],
23
+ scorer=model_graded_qa(),
28
24
  )
@@ -8,14 +8,15 @@ from langchain_core.runnables import RunnablePassthrough
8
8
  from langchain_openai import ChatOpenAI, OpenAIEmbeddings
9
9
 
10
10
  from langtrace_python_sdk import langtrace
11
- from langtrace_python_sdk.utils.with_root_span import (
12
- with_langtrace_root_span,
13
- with_additional_attributes,
14
- )
11
+ from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
12
+ from openai import OpenAI
15
13
 
16
14
  _ = load_dotenv(find_dotenv())
17
15
 
18
- langtrace.init()
16
+ langtrace.init(
17
+ write_spans_to_console=False,
18
+ disable_tracing_for_functions={"langchain": ["RunnableSequence.invoke"]},
19
+ )
19
20
 
20
21
 
21
22
  def api_call_1():
@@ -29,7 +30,8 @@ def api_call_1():
29
30
  output_parser = StrOutputParser()
30
31
  chain = prompt | llm | output_parser
31
32
  res = chain.invoke({"input": "how can langsmith help with testing?"})
32
- print(res)
33
+ # print(res)
34
+ return res
33
35
 
34
36
 
35
37
  def api_call_2():
@@ -43,13 +45,26 @@ def api_call_2():
43
45
  output_parser = StrOutputParser()
44
46
  chain = prompt | llm | output_parser
45
47
  res = chain.invoke({"input": "how can langsmith help with testing?"})
46
- print(res)
48
+ # print(res)
49
+ return res
47
50
 
48
51
 
49
52
  @with_langtrace_root_span()
50
53
  def basic_app():
51
54
  api_call_1()
52
- api_call_2()
55
+ # api_call_2()
56
+ client = OpenAI()
57
+ response = client.chat.completions.create(
58
+ model="gpt-4",
59
+ messages=[
60
+ {"role": "system", "content": "Talk like a pirate"},
61
+ {"role": "user", "content": "Tell me a story in 3 sentences or less."},
62
+ ],
63
+ # stream=True,
64
+ stream=False,
65
+ )
66
+
67
+ return response
53
68
 
54
69
 
55
70
  @with_langtrace_root_span()
@@ -12,7 +12,7 @@ import nest_asyncio
12
12
 
13
13
  nest_asyncio.apply()
14
14
 
15
- langtrace.init(write_spans_to_console=False)
15
+ langtrace.init()
16
16
 
17
17
 
18
18
  def multiply(a: int, b: int) -> int:
@@ -7,7 +7,11 @@ from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
7
7
  _ = load_dotenv(find_dotenv())
8
8
 
9
9
 
10
- langtrace.init(write_spans_to_console=False)
10
+ langtrace.init(
11
+ disable_tracing_for_functions={
12
+ "open_ai": ["openai.chat.completions.create"],
13
+ }
14
+ )
11
15
 
12
16
 
13
17
  @with_langtrace_root_span()
@@ -0,0 +1,14 @@
1
+ from .basic import chat, async_chat, async_generate, generate, embed, async_embed
2
+ from langtrace_python_sdk import with_langtrace_root_span
3
+ import asyncio
4
+
5
+
6
+ class OllamaRunner:
7
+ @with_langtrace_root_span("OllamaRunner")
8
+ def run(self):
9
+ chat()
10
+ generate()
11
+ embed()
12
+ asyncio.run(async_chat())
13
+ asyncio.run(async_generate())
14
+ asyncio.run(async_embed())
@@ -0,0 +1,50 @@
1
+ from langtrace_python_sdk import langtrace, with_langtrace_root_span
2
+ import ollama
3
+ from ollama import AsyncClient
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+
8
+ langtrace.init(write_spans_to_console=False)
9
+
10
+
11
+ def chat():
12
+ response = ollama.chat(
13
+ model="llama3",
14
+ messages=[
15
+ {
16
+ "role": "user",
17
+ "content": "hi",
18
+ },
19
+ ],
20
+ stream=True,
21
+ )
22
+
23
+ return response
24
+
25
+
26
+ async def async_chat():
27
+ message = {"role": "user", "content": "Why is the sky blue?"}
28
+ return await AsyncClient().chat(model="llama3", messages=[message])
29
+
30
+
31
+ def generate():
32
+ return ollama.generate(model="llama3", prompt="Why is the sky blue?")
33
+
34
+
35
+ def async_generate():
36
+ return AsyncClient().generate(model="llama3", prompt="Why is the sky blue?")
37
+
38
+
39
+ def embed():
40
+ return ollama.embeddings(
41
+ model="llama3",
42
+ prompt="cat",
43
+ )
44
+
45
+
46
+ async def async_embed():
47
+ return await AsyncClient().embeddings(
48
+ model="llama3",
49
+ prompt="cat",
50
+ )
@@ -40,5 +40,5 @@ def chat_completion():
40
40
  ]
41
41
  result.append(content[0] if len(content) > 0 else "")
42
42
 
43
- print("".join(result))
43
+ # print("".join(result))
44
44
  return response
@@ -13,6 +13,7 @@ from langtrace_python_sdk import (
13
13
  with_additional_attributes,
14
14
  )
15
15
  from langtrace_python_sdk.utils.with_root_span import SendUserFeedback
16
+ from opentelemetry.sdk.trace.export import ConsoleSpanExporter
16
17
 
17
18
  _ = load_dotenv(find_dotenv())
18
19
  langtrace.init()
@@ -15,12 +15,14 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  from langtrace_python_sdk import langtrace
18
- from langtrace_python_sdk.extensions.langtrace_filesystem import \
19
- LangTraceFileSystem
18
+ from langtrace_python_sdk.extensions.langtrace_filesystem import LangTraceFileSystem
20
19
  from langtrace_python_sdk.utils.prompt_registry import get_prompt_from_registry
21
20
  from langtrace_python_sdk.utils.with_root_span import (
22
- SendUserFeedback, inject_additional_attributes, with_additional_attributes,
23
- with_langtrace_root_span)
21
+ SendUserFeedback,
22
+ inject_additional_attributes,
23
+ with_additional_attributes,
24
+ with_langtrace_root_span,
25
+ )
24
26
 
25
27
  __all__ = [
26
28
  "langtrace",
@@ -23,6 +23,7 @@ SERVICE_PROVIDERS = {
23
23
  "PPLX": "Perplexity",
24
24
  "QDRANT": "Qdrant",
25
25
  "WEAVIATE": "Weaviate",
26
+ "OLLAMA": "Ollama",
26
27
  }
27
28
 
28
29
  LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY = "langtrace_additional_attributes"
@@ -0,0 +1,7 @@
1
+ APIS = {
2
+ "GENERATE": {
3
+ "METHOD": "generate",
4
+ },
5
+ "CHAT": {"METHOD": "chat"},
6
+ "EMBEDDINGS": {"METHOD": "embeddings"},
7
+ }
@@ -12,7 +12,7 @@ APIS = {
12
12
  "OPERATION": "query",
13
13
  },
14
14
  "DELETE": {
15
- "METHOD": PineconeMethods.DELETE,
15
+ "METHOD": PineconeMethods.DELETE.value,
16
16
  "ENDPOINT": "/vectors/delete",
17
17
  "OPERATION": "delete",
18
18
  },
@@ -15,7 +15,7 @@ OpenBinaryMode = Literal["rb", "ab", "wb"]
15
15
 
16
16
  class OpenMode(str):
17
17
  def __init_subclass__(cls, **kwargs):
18
- allowed_values = set(OpenTextMode.__args__) | set(OpenBinaryMode.__args__)
18
+ allowed_values = Union[set(OpenTextMode.__args__), set(OpenBinaryMode.__args__)]
19
19
  super().__init_subclass__(**kwargs)
20
20
 
21
21
  def __new__(cls, value):
@@ -50,13 +50,17 @@ class LangTraceFile(io.BytesIO):
50
50
  log = file_data.decode("utf-8")
51
51
  eval_log = json.loads(log)
52
52
  data = {
53
- "runId": eval_log['eval']['run_id'],
54
- "taskId": eval_log['eval']['task_id'],
53
+ "runId": eval_log["eval"]["run_id"],
54
+ "taskId": eval_log["eval"]["task_id"],
55
55
  "log": log,
56
56
  }
57
57
  if self.path is not None:
58
58
  dataset_id = self.path.split("/")[0]
59
- print(Fore.GREEN + f"Sending results to Langtrace for dataset: {dataset_id}" + Fore.RESET)
59
+ print(
60
+ Fore.GREEN
61
+ + f"Sending results to Langtrace for dataset: {dataset_id}"
62
+ + Fore.RESET
63
+ )
60
64
  data["datasetId"] = dataset_id
61
65
  else:
62
66
  print(Fore.GREEN + "Sending results to Langtrace" + Fore.RESET)
@@ -65,14 +69,12 @@ class LangTraceFile(io.BytesIO):
65
69
  data=json.dumps(data),
66
70
  headers={
67
71
  "Content-Type": "application/json",
68
- "x-api-key": os.environ.get("LANGTRACE_API_KEY")
72
+ "x-api-key": os.environ.get("LANGTRACE_API_KEY"),
69
73
  },
70
74
  timeout=20,
71
75
  )
72
76
  response.raise_for_status()
73
- print(
74
- Fore.GREEN + "Results sent to Langtrace successfully." + Fore.RESET
75
- )
77
+ print(Fore.GREEN + "Results sent to Langtrace successfully." + Fore.RESET)
76
78
  except requests.exceptions.RequestException as error:
77
79
  print(Fore.RED + f"Error reporting results: {error}" + Fore.RESET)
78
80
 
@@ -89,9 +91,9 @@ class LangTraceFileSystem(AbstractFileSystem):
89
91
  def open(
90
92
  self,
91
93
  path: str,
92
- mode: OpenTextMode | OpenBinaryMode = "rb",
94
+ mode: Union[OpenTextMode, OpenBinaryMode] = "rb",
93
95
  **kwargs,
94
- ) -> Iterator[LangTraceFile | io.BytesIO]:
96
+ ) -> Iterator[Union[LangTraceFile, io.BytesIO]]:
95
97
  if "r" in mode:
96
98
  dataset_id = path
97
99
  # Fetch file from API and return a BytesIO object
@@ -104,21 +106,33 @@ class LangTraceFileSystem(AbstractFileSystem):
104
106
 
105
107
  def fetch_file_from_api(self, dataset_id: str) -> bytes:
106
108
  try:
107
- print(Fore.GREEN + f"Fetching dataset with id: {dataset_id} from Langtrace" + Fore.RESET)
109
+ print(
110
+ Fore.GREEN
111
+ + f"Fetching dataset with id: {dataset_id} from Langtrace"
112
+ + Fore.RESET
113
+ )
108
114
  response = requests.get(
109
115
  url=f"{LANGTRACE_REMOTE_URL}/api/dataset/download?id={dataset_id}",
110
116
  headers={
111
117
  "Content-Type": "application/json",
112
- "x-api-key": os.environ.get("LANGTRACE_API_KEY")
118
+ "x-api-key": os.environ.get("LANGTRACE_API_KEY"),
113
119
  },
114
120
  timeout=20,
115
121
  )
116
- print(Fore.GREEN + f"Successfully fetched dataset with id: {dataset_id} from Langtrace" + Fore.RESET)
122
+ print(
123
+ Fore.GREEN
124
+ + f"Successfully fetched dataset with id: {dataset_id} from Langtrace"
125
+ + Fore.RESET
126
+ )
117
127
  response.raise_for_status()
118
128
  file_data = response.content
119
129
  return file_data
120
130
  except requests.exceptions.RequestException as error:
121
- print(Fore.RED + f"Error fetching dataset with id: {dataset_id} from Langtrace: {error}" + Fore.RESET)
131
+ print(
132
+ Fore.RED
133
+ + f"Error fetching dataset with id: {dataset_id} from Langtrace: {error}"
134
+ + Fore.RESET
135
+ )
122
136
  return b""
123
137
 
124
138
  def makedirs(self, path: str, exist_ok: bool = False) -> None:
@@ -167,7 +181,9 @@ class LangTraceFileSystem(AbstractFileSystem):
167
181
  if path in self.dirs:
168
182
  dirs = [d for d in self.dirs if d.startswith(path + self.sep)]
169
183
  files = [f for f in self.files if f.startswith(path + self.sep)]
170
- yield path, [d.split(self.sep)[-1] for d in dirs], [f.split(self.sep)[-1] for f in files]
184
+ yield path, [d.split(self.sep)[-1] for d in dirs], [
185
+ f.split(self.sep)[-1] for f in files
186
+ ]
171
187
  for d in dirs:
172
188
  yield from self._walk(d)
173
189
 
@@ -11,6 +11,7 @@ from .openai import OpenAIInstrumentation
11
11
  from .pinecone import PineconeInstrumentation
12
12
  from .qdrant import QdrantInstrumentation
13
13
  from .weaviate import WeaviateInstrumentation
14
+ from .ollama import OllamaInstrumentor
14
15
 
15
16
  __all__ = [
16
17
  "AnthropicInstrumentation",
@@ -26,4 +27,5 @@ __all__ = [
26
27
  "PineconeInstrumentation",
27
28
  "QdrantInstrumentation",
28
29
  "WeaviateInstrumentation",
30
+ "OllamaInstrumentor",
29
31
  ]
@@ -17,10 +17,10 @@ limitations under the License.
17
17
  from langtrace.trace_attributes import DatabaseSpanAttributes
18
18
  from langtrace_python_sdk.utils.llm import set_span_attributes
19
19
  from langtrace_python_sdk.utils.silently_fail import silently_fail
20
- from opentelemetry import baggage
20
+ from opentelemetry import baggage, trace
21
21
  from opentelemetry.trace import SpanKind
22
22
  from opentelemetry.trace.status import Status, StatusCode
23
-
23
+ from opentelemetry.trace.propagation import set_span_in_context
24
24
  from langtrace_python_sdk.constants.instrumentation.chroma import APIS
25
25
  from langtrace_python_sdk.constants.instrumentation.common import (
26
26
  LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
@@ -59,7 +59,11 @@ def collection_patch(method, version, tracer):
59
59
 
60
60
  attributes = DatabaseSpanAttributes(**span_attributes)
61
61
 
62
- with tracer.start_as_current_span(api["METHOD"], kind=SpanKind.CLIENT) as span:
62
+ with tracer.start_as_current_span(
63
+ api["METHOD"],
64
+ kind=SpanKind.CLIENT,
65
+ context=set_span_in_context(trace.get_current_span()),
66
+ ) as span:
63
67
  for field, value in attributes.model_dump(by_alias=True).items():
64
68
  if value is not None:
65
69
  span.set_attribute(field, value)
@@ -17,7 +17,8 @@ limitations under the License.
17
17
  import json
18
18
 
19
19
  from langtrace.trace_attributes import Event, LLMSpanAttributes
20
- from opentelemetry import baggage
20
+ from opentelemetry import baggage, trace
21
+ from opentelemetry.trace.propagation import set_span_in_context
21
22
  from opentelemetry.trace import SpanKind
22
23
  from opentelemetry.trace.status import Status, StatusCode
23
24
 
@@ -112,7 +113,9 @@ def chat_completions_create(original_method, version, tracer):
112
113
  # with tracer.start_as_current_span(APIS["CHAT_COMPLETION"]["METHOD"],
113
114
  # kind=SpanKind.CLIENT) as span:
114
115
  span = tracer.start_span(
115
- APIS["CHAT_COMPLETION"]["METHOD"], kind=SpanKind.CLIENT
116
+ APIS["CHAT_COMPLETION"]["METHOD"],
117
+ kind=SpanKind.CLIENT,
118
+ context=set_span_in_context(trace.get_current_span()),
116
119
  )
117
120
  for field, value in attributes.model_dump(by_alias=True).items():
118
121
  if value is not None:
@@ -17,7 +17,9 @@ limitations under the License.
17
17
  import json
18
18
 
19
19
  from langtrace.trace_attributes import FrameworkSpanAttributes
20
- from opentelemetry import baggage
20
+ from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
21
+ from opentelemetry import baggage, trace
22
+ from opentelemetry.trace.propagation import set_span_in_context
21
23
  from opentelemetry.trace import SpanKind, StatusCode
22
24
  from opentelemetry.trace.status import Status
23
25
 
@@ -54,7 +56,11 @@ def generic_patch(
54
56
 
55
57
  attributes = FrameworkSpanAttributes(**span_attributes)
56
58
 
57
- with tracer.start_as_current_span(method_name, kind=SpanKind.CLIENT) as span:
59
+ with tracer.start_as_current_span(
60
+ method_name,
61
+ kind=SpanKind.CLIENT,
62
+ context=set_span_in_context(trace.get_current_span()),
63
+ ) as span:
58
64
  for field, value in attributes.model_dump(by_alias=True).items():
59
65
  if value is not None:
60
66
  span.set_attribute(field, value)
@@ -17,7 +17,9 @@ limitations under the License.
17
17
  import json
18
18
 
19
19
  from langtrace.trace_attributes import FrameworkSpanAttributes
20
- from opentelemetry import baggage
20
+ from opentelemetry import baggage, trace
21
+ from opentelemetry.trace.propagation import set_span_in_context
22
+
21
23
  from opentelemetry.trace import SpanKind
22
24
  from opentelemetry.trace.status import Status, StatusCode
23
25
 
@@ -52,7 +54,11 @@ def generic_patch(
52
54
 
53
55
  attributes = FrameworkSpanAttributes(**span_attributes)
54
56
 
55
- with tracer.start_as_current_span(method_name, kind=SpanKind.CLIENT) as span:
57
+ with tracer.start_as_current_span(
58
+ method_name,
59
+ kind=SpanKind.CLIENT,
60
+ context=set_span_in_context(trace.get_current_span()),
61
+ ) as span:
56
62
  for field, value in attributes.model_dump(by_alias=True).items():
57
63
  if value is not None:
58
64
  span.set_attribute(field, value)
@@ -17,9 +17,10 @@ limitations under the License.
17
17
  import json
18
18
 
19
19
  from langtrace.trace_attributes import FrameworkSpanAttributes
20
- from opentelemetry import baggage
20
+ from opentelemetry import baggage, trace
21
21
  from opentelemetry.trace import SpanKind, StatusCode
22
22
  from opentelemetry.trace.status import Status
23
+ from opentelemetry.trace.propagation import set_span_in_context
23
24
 
24
25
  from langtrace_python_sdk.constants.instrumentation.common import (
25
26
  LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
@@ -73,7 +74,12 @@ def generic_patch(
73
74
 
74
75
  attributes = FrameworkSpanAttributes(**span_attributes)
75
76
 
76
- with tracer.start_as_current_span(method_name, kind=SpanKind.CLIENT) as span:
77
+ with tracer.start_as_current_span(
78
+ method_name,
79
+ kind=SpanKind.CLIENT,
80
+ context=set_span_in_context(trace.get_current_span()),
81
+ ) as span:
82
+
77
83
  for field, value in attributes.model_dump(by_alias=True).items():
78
84
  if value is not None:
79
85
  span.set_attribute(field, value)
@@ -147,7 +153,11 @@ def runnable_patch(
147
153
 
148
154
  attributes = FrameworkSpanAttributes(**span_attributes)
149
155
 
150
- with tracer.start_as_current_span(method_name, kind=SpanKind.CLIENT) as span:
156
+ with tracer.start_as_current_span(
157
+ method_name,
158
+ kind=SpanKind.CLIENT,
159
+ context=set_span_in_context(trace.get_current_span()),
160
+ ) as span:
151
161
  for field, value in attributes.model_dump(by_alias=True).items():
152
162
  if value is not None:
153
163
  span.set_attribute(field, value)
@@ -15,9 +15,10 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  import json
18
+ from opentelemetry.trace.propagation import set_span_in_context
18
19
 
19
20
  from langtrace.trace_attributes import FrameworkSpanAttributes
20
- from opentelemetry import baggage
21
+ from opentelemetry import baggage, trace
21
22
  from opentelemetry.trace import SpanKind
22
23
  from opentelemetry.trace.status import Status, StatusCode
23
24
 
@@ -50,7 +51,11 @@ def patch_graph_methods(method_name, tracer, version):
50
51
 
51
52
  attributes = FrameworkSpanAttributes(**span_attributes)
52
53
 
53
- with tracer.start_as_current_span(method_name, kind=SpanKind.CLIENT) as span:
54
+ with tracer.start_as_current_span(
55
+ method_name,
56
+ kind=SpanKind.CLIENT,
57
+ context=set_span_in_context(trace.get_current_span()),
58
+ ) as span:
54
59
  for field, value in attributes.model_dump(by_alias=True).items():
55
60
  if value is not None:
56
61
  span.set_attribute(field, value)
@@ -15,10 +15,10 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  from langtrace.trace_attributes import FrameworkSpanAttributes
18
- from opentelemetry import baggage
18
+ from opentelemetry import baggage, trace
19
19
  from opentelemetry.trace import SpanKind
20
20
  from opentelemetry.trace.status import Status, StatusCode
21
-
21
+ from opentelemetry.trace.propagation import set_span_in_context
22
22
  from langtrace_python_sdk.constants.instrumentation.common import (
23
23
  LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
24
24
  SERVICE_PROVIDERS,
@@ -48,7 +48,11 @@ def generic_patch(method, task, tracer, version):
48
48
 
49
49
  attributes = FrameworkSpanAttributes(**span_attributes)
50
50
 
51
- with tracer.start_as_current_span(method, kind=SpanKind.CLIENT) as span:
51
+ with tracer.start_as_current_span(
52
+ method,
53
+ kind=SpanKind.CLIENT,
54
+ context=set_span_in_context(trace.get_current_span()),
55
+ ) as span:
52
56
  for field, value in attributes.model_dump(by_alias=True).items():
53
57
  if value is not None:
54
58
  span.set_attribute(field, value)
@@ -0,0 +1,3 @@
1
+ from .instrumentation import OllamaInstrumentor
2
+
3
+ __all__ = ["OllamaInstrumentor"]
@@ -0,0 +1,58 @@
1
+ """
2
+ Copyright (c) 2024 Scale3 Labs
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
16
+
17
+ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
18
+ from opentelemetry.trace import get_tracer
19
+ from wrapt import wrap_function_wrapper as _W
20
+ from typing import Collection
21
+ from importlib_metadata import version as v
22
+ from langtrace_python_sdk.constants.instrumentation.ollama import APIS
23
+ from .patch import generic_patch, ageneric_patch
24
+
25
+
26
+ class OllamaInstrumentor(BaseInstrumentor):
27
+ """
28
+ The OllamaInstrumentor class represents the Ollama instrumentation"""
29
+
30
+ def instrumentation_dependencies(self) -> Collection[str]:
31
+ return ["ollama >= 0.2.0, < 1"]
32
+
33
+ def _instrument(self, **kwargs):
34
+ tracer_provider = kwargs.get("tracer_provider")
35
+ tracer = get_tracer(__name__, "", tracer_provider)
36
+ version = v("ollama")
37
+ for operation_name, details in APIS.items():
38
+ operation = details["METHOD"]
39
+ # Dynamically creating the patching call
40
+ _W(
41
+ "ollama._client",
42
+ f"Client.{operation}",
43
+ generic_patch(operation_name, version, tracer),
44
+ )
45
+
46
+ _W(
47
+ "ollama._client",
48
+ f"AsyncClient.{operation}",
49
+ ageneric_patch(operation_name, version, tracer),
50
+ )
51
+ _W(
52
+ "ollama",
53
+ f"{operation}",
54
+ generic_patch(operation_name, version, tracer),
55
+ )
56
+
57
+ def _uninstrument(self, **kwargs):
58
+ pass