langtrace-python-sdk 2.2.17__tar.gz → 2.2.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 (199) hide show
  1. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/PKG-INFO +1 -1
  2. langtrace_python_sdk-2.2.19/src/examples/langchain_example/sagemaker.py +81 -0
  3. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +2 -1
  4. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +2 -1
  5. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +14 -4
  6. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/crewai/patch.py +4 -1
  7. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/gemini/patch.py +3 -2
  8. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/groq/patch.py +3 -2
  9. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +2 -1
  10. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +8 -3
  11. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +36 -10
  12. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +3 -3
  13. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +38 -23
  14. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +2 -1
  15. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +5 -2
  16. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +2 -1
  17. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/openai/patch.py +8 -7
  18. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +2 -1
  19. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +2 -1
  20. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/vertexai/patch.py +2 -1
  21. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +2 -1
  22. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/llm.py +7 -0
  23. langtrace_python_sdk-2.2.19/src/langtrace_python_sdk/version.py +1 -0
  24. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/langchain/test_langchain.py +1 -8
  25. langtrace_python_sdk-2.2.17/src/langtrace_python_sdk/version.py +0 -1
  26. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/.gitignore +0 -0
  27. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/LICENSE +0 -0
  28. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/README.md +0 -0
  29. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/pyproject.toml +0 -0
  30. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/__init__.py +0 -0
  31. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/__init__.py +0 -0
  32. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/anthropic_example/__init__.py +0 -0
  33. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/anthropic_example/completion.py +0 -0
  34. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/chroma_example/__init__.py +0 -0
  35. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/chroma_example/basic.py +0 -0
  36. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/cohere_example/__init__.py +0 -0
  37. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/cohere_example/chat.py +0 -0
  38. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/cohere_example/chat_stream.py +0 -0
  39. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/cohere_example/embed.py +0 -0
  40. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/cohere_example/rerank.py +0 -0
  41. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/cohere_example/tools.py +0 -0
  42. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/crewai_example/basic.py +0 -0
  43. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/dspy_example/math_problems_cot.py +0 -0
  44. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/dspy_example/math_problems_cot_parallel.py +0 -0
  45. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/dspy_example/program_of_thought_basic.py +0 -0
  46. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/dspy_example/quiz_gen.py +0 -0
  47. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/dspy_example/react.py +0 -0
  48. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/fastapi_example/__init__.py +0 -0
  49. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/fastapi_example/basic_route.py +0 -0
  50. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/gemini_example/__init__.py +0 -0
  51. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/gemini_example/function_tools.py +0 -0
  52. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/gemini_example/main.py +0 -0
  53. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/hiveagent_example/basic.py +0 -0
  54. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/inspect_ai_example/basic_eval.py +0 -0
  55. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/langchain_example/__init__.py +0 -0
  56. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/langchain_example/basic.py +0 -0
  57. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/langchain_example/groq_example.py +0 -0
  58. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/langchain_example/langgraph_example.py +0 -0
  59. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/langchain_example/tool.py +0 -0
  60. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/llamaindex_example/__init__.py +0 -0
  61. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/llamaindex_example/agent.py +0 -0
  62. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/llamaindex_example/basic.py +0 -0
  63. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  64. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/ollama_example/__init__.py +0 -0
  65. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/ollama_example/basic.py +0 -0
  66. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/__init__.py +0 -0
  67. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  68. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  69. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/chat_completion.py +0 -0
  70. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/chat_completion_tool_choice.py +0 -0
  71. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/embeddings_create.py +0 -0
  72. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/function_calling.py +0 -0
  73. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/images_edit.py +0 -0
  74. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/images_generate.py +0 -0
  75. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
  76. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/resources/mask.png +0 -0
  77. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/send_user_feedback.py +0 -0
  78. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/tool_calling.py +0 -0
  79. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  80. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  81. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/otlp_example/otlp_basic.py +0 -0
  82. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/otlp_example/otlp_with_langtrace.py +0 -0
  83. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/perplexity_example/basic.py +0 -0
  84. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/pinecone_example/__init__.py +0 -0
  85. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/pinecone_example/basic.py +0 -0
  86. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/qdrant_example/__init__.py +0 -0
  87. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/qdrant_example/basic.py +0 -0
  88. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/routellm_example/basic.py +0 -0
  89. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/vertexai_example/__init__.py +0 -0
  90. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/vertexai_example/main.py +0 -0
  91. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/weaviate_example/__init__.py +0 -0
  92. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/examples/weaviate_example/query_text.py +0 -0
  93. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/__init__.py +0 -0
  94. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  95. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  96. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  97. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  98. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  99. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
  100. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
  101. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/gemini.py +0 -0
  102. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  103. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
  104. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  105. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  106. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  107. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/vertexai.py +0 -0
  108. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
  109. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  110. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
  111. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +0 -0
  112. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  113. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  114. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  115. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  116. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  117. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  118. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
  119. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/crewai/__init__.py +0 -0
  120. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/crewai/instrumentation.py +0 -0
  121. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +0 -0
  122. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +0 -0
  123. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/dspy/patch.py +0 -0
  124. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/gemini/__init__.py +0 -0
  125. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/gemini/instrumentation.py +0 -0
  126. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  127. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  128. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  129. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  130. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  131. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  132. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  133. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  134. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  135. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  136. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
  137. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
  138. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  139. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  140. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  141. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
  142. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  143. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  144. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/vertexai/__init__.py +0 -0
  145. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/vertexai/instrumentation.py +0 -0
  146. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
  147. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
  148. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/langtrace.py +0 -0
  149. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/types/__init__.py +0 -0
  150. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/__init__.py +0 -0
  151. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
  152. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/misc.py +0 -0
  153. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
  154. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
  155. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
  156. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/types.py +0 -0
  157. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
  158. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/run_example.py +0 -0
  159. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/__init__.py +0 -0
  160. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  161. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  162. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  163. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/anthropic/conftest.py +0 -0
  164. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/anthropic/test_anthropic.py +0 -0
  165. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/chroma/conftest.py +0 -0
  166. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/chroma/test_chroma.py +0 -0
  167. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  168. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  169. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  170. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  171. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/conftest.py +0 -0
  172. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/test_cohere_chat.py +0 -0
  173. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/test_cohere_embed.py +0 -0
  174. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/cohere/test_cohere_rerank.py +0 -0
  175. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/conftest.py +0 -0
  176. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/groq/cassettes/test_async_chat_completion.yaml +0 -0
  177. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/groq/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  178. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/groq/cassettes/test_chat_completion.yaml +0 -0
  179. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/groq/cassettes/test_chat_completion_streaming.yaml +0 -0
  180. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/groq/conftest.py +0 -0
  181. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/groq/test_groq.py +0 -0
  182. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
  183. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/langchain/conftest.py +0 -0
  184. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  185. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  186. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  187. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  188. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  189. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/conftest.py +0 -0
  190. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/test_chat_completion.py +0 -0
  191. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/test_embeddings.py +0 -0
  192. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/openai/test_image_generation.py +0 -0
  193. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
  194. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
  195. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/pinecone/conftest.py +0 -0
  196. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/pinecone/test_pinecone.py +0 -0
  197. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/qdrant/conftest.py +0 -0
  198. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.19}/src/tests/qdrant/test_qdrant.py +0 -0
  199. {langtrace_python_sdk-2.2.17 → langtrace_python_sdk-2.2.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.2.17
3
+ Version: 2.2.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>
@@ -0,0 +1,81 @@
1
+ import json
2
+ from typing import Dict
3
+
4
+ import boto3
5
+ from dotenv import load_dotenv
6
+ from langchain.chains.question_answering import load_qa_chain
7
+ from langchain_community.llms.sagemaker_endpoint import (LLMContentHandler,
8
+ SagemakerEndpoint)
9
+ from langchain_core.documents import Document
10
+ from langchain_core.prompts import PromptTemplate
11
+
12
+ from langtrace_python_sdk import langtrace, with_langtrace_root_span
13
+
14
+ # Add the path to the root of the project to the sys.path
15
+
16
+ load_dotenv()
17
+
18
+ langtrace.init()
19
+ example_doc_1 = """
20
+ Peter and Elizabeth took a taxi to attend the night party in the city. While in the party, Elizabeth collapsed and was rushed to the hospital.
21
+ Since she was diagnosed with a brain injury, the doctor told Peter to stay besides her until she gets well.
22
+ Therefore, Peter stayed with her at the hospital for 3 days without leaving.
23
+ """
24
+
25
+ docs = [
26
+ Document(
27
+ page_content=example_doc_1,
28
+ )
29
+ ]
30
+
31
+
32
+ query = """How long was Elizabeth hospitalized?"""
33
+ prompt_template = """Use the following pieces of context to answer the question at the end.
34
+
35
+ {context}
36
+
37
+ Question: {question}
38
+ Answer:"""
39
+ PROMPT = PromptTemplate(
40
+ template=prompt_template, input_variables=["context", "question"]
41
+ )
42
+
43
+
44
+ client = boto3.client(
45
+ "sagemaker-runtime",
46
+ region_name="us-east-1",
47
+ )
48
+
49
+
50
+ class ContentHandler(LLMContentHandler):
51
+ content_type = "application/json"
52
+ accepts = "application/json"
53
+
54
+ def transform_input(self, prompt: str, model_kwargs: Dict) -> bytes:
55
+ input_str = json.dumps({"inputs": prompt, "parameters": model_kwargs})
56
+ return input_str.encode("utf-8")
57
+
58
+ def transform_output(self, output: bytes) -> str:
59
+ response_json = json.loads(output.read().decode("utf-8"))
60
+ return response_json["generated_text"]
61
+
62
+
63
+ @with_langtrace_root_span("SagemakerEndpoint")
64
+ def main():
65
+ content_handler = ContentHandler()
66
+
67
+ chain = load_qa_chain(
68
+ llm=SagemakerEndpoint(
69
+ endpoint_name="jumpstart-dft-meta-textgeneration-l-20240809-083223",
70
+ client=client,
71
+ model_kwargs={"temperature": 1e-10},
72
+ content_handler=content_handler,
73
+ ),
74
+ prompt=PROMPT,
75
+ )
76
+
77
+ res = chain({"input_documents": docs, "question": query}, return_only_outputs=True)
78
+ print(res)
79
+
80
+
81
+ main()
@@ -23,6 +23,7 @@ from langtrace_python_sdk.utils.llm import (
23
23
  get_langtrace_attributes,
24
24
  get_llm_request_attributes,
25
25
  get_llm_url,
26
+ get_span_name,
26
27
  is_streaming,
27
28
  set_event_completion,
28
29
  set_event_completion_chunk,
@@ -64,7 +65,7 @@ def messages_create(original_method, version, tracer):
64
65
  attributes = LLMSpanAttributes(**span_attributes)
65
66
 
66
67
  span = tracer.start_span(
67
- APIS["MESSAGES_CREATE"]["METHOD"], kind=SpanKind.CLIENT
68
+ name=get_span_name(APIS["MESSAGES_CREATE"]["METHOD"]), kind=SpanKind.CLIENT
68
69
  )
69
70
  for field, value in attributes.model_dump(by_alias=True).items():
70
71
  set_span_attribute(span, field, value)
@@ -16,6 +16,7 @@ limitations under the License.
16
16
 
17
17
  from langtrace.trace_attributes import DatabaseSpanAttributes
18
18
  from langtrace_python_sdk.utils import set_span_attribute
19
+ from langtrace_python_sdk.utils.llm import get_span_name
19
20
  from langtrace_python_sdk.utils.silently_fail import silently_fail
20
21
  from opentelemetry import baggage, trace
21
22
  from opentelemetry.trace import SpanKind
@@ -60,7 +61,7 @@ def collection_patch(method, version, tracer):
60
61
  attributes = DatabaseSpanAttributes(**span_attributes)
61
62
 
62
63
  with tracer.start_as_current_span(
63
- api["METHOD"],
64
+ name=get_span_name(api["METHOD"]),
64
65
  kind=SpanKind.CLIENT,
65
66
  context=set_span_in_context(trace.get_current_span()),
66
67
  ) as span:
@@ -21,6 +21,7 @@ from langtrace_python_sdk.utils.llm import (
21
21
  get_llm_request_attributes,
22
22
  get_extra_attributes,
23
23
  get_llm_url,
24
+ get_span_name,
24
25
  set_event_completion,
25
26
  set_event_completion_chunk,
26
27
  set_usage_attributes,
@@ -57,7 +58,9 @@ def rerank(original_method, version, tracer):
57
58
 
58
59
  attributes = LLMSpanAttributes(**span_attributes)
59
60
 
60
- span = tracer.start_span(APIS["RERANK"]["METHOD"], kind=SpanKind.CLIENT)
61
+ span = tracer.start_span(
62
+ name=get_span_name(APIS["RERANK"]["METHOD"]), kind=SpanKind.CLIENT
63
+ )
61
64
  for field, value in attributes.model_dump(by_alias=True).items():
62
65
  set_span_attribute(span, field, value)
63
66
  try:
@@ -137,7 +140,10 @@ def embed(original_method, version, tracer):
137
140
 
138
141
  attributes = LLMSpanAttributes(**span_attributes)
139
142
 
140
- span = tracer.start_span(APIS["EMBED"]["METHOD"], kind=SpanKind.CLIENT)
143
+ span = tracer.start_span(
144
+ name=get_span_name(APIS["EMBED"]["METHOD"]),
145
+ kind=SpanKind.CLIENT,
146
+ )
141
147
  for field, value in attributes.model_dump(by_alias=True).items():
142
148
  set_span_attribute(span, field, value)
143
149
  try:
@@ -225,7 +231,9 @@ def chat_create(original_method, version, tracer):
225
231
  # stringify the list of objects
226
232
  attributes.llm_tool_results = json.dumps(kwargs.get("tool_results"))
227
233
 
228
- span = tracer.start_span(APIS["CHAT_CREATE"]["METHOD"], kind=SpanKind.CLIENT)
234
+ span = tracer.start_span(
235
+ name=get_span_name(APIS["CHAT_CREATE"]["METHOD"]), kind=SpanKind.CLIENT
236
+ )
229
237
 
230
238
  # Set the attributes on the span
231
239
  for field, value in attributes.model_dump(by_alias=True).items():
@@ -391,7 +399,9 @@ def chat_stream(original_method, version, tracer):
391
399
  # stringify the list of objects
392
400
  attributes.llm_tool_results = json.dumps(kwargs.get("tool_results"))
393
401
 
394
- span = tracer.start_span(APIS["CHAT_STREAM"]["METHOD"], kind=SpanKind.CLIENT)
402
+ span = tracer.start_span(
403
+ name=get_span_name(APIS["CHAT_STREAM"]["METHOD"]), kind=SpanKind.CLIENT
404
+ )
395
405
  for field, value in attributes.model_dump(by_alias=True).items():
396
406
  set_span_attribute(span, field, value)
397
407
  try:
@@ -2,6 +2,7 @@ import json
2
2
  from importlib_metadata import version as v
3
3
  from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
4
4
  from langtrace_python_sdk.utils import set_span_attribute
5
+ from langtrace_python_sdk.utils.llm import get_span_name
5
6
  from langtrace_python_sdk.utils.silently_fail import silently_fail
6
7
  from langtrace_python_sdk.constants.instrumentation.common import (
7
8
  LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
@@ -143,7 +144,9 @@ def patch_crew(operation_name, version, tracer):
143
144
 
144
145
  attributes = FrameworkSpanAttributes(**span_attributes)
145
146
 
146
- with tracer.start_as_current_span(operation_name, kind=SpanKind.CLIENT) as span:
147
+ with tracer.start_as_current_span(
148
+ get_span_name(operation_name), kind=SpanKind.CLIENT
149
+ ) as span:
147
150
  _set_input_attributes(span, kwargs, attributes)
148
151
 
149
152
  try:
@@ -10,6 +10,7 @@ from langtrace_python_sdk.utils.llm import (
10
10
  get_langtrace_attributes,
11
11
  get_llm_request_attributes,
12
12
  get_llm_url,
13
+ get_span_name,
13
14
  is_streaming,
14
15
  set_event_completion,
15
16
  set_event_completion_chunk,
@@ -35,7 +36,7 @@ def patch_gemini(name, version, tracer: Tracer):
35
36
  }
36
37
  attributes = LLMSpanAttributes(**span_attributes)
37
38
  span = tracer.start_span(
38
- name=name,
39
+ name=get_span_name(name),
39
40
  kind=SpanKind.CLIENT,
40
41
  context=set_span_in_context(trace.get_current_span()),
41
42
  )
@@ -76,7 +77,7 @@ def apatch_gemini(name, version, tracer: Tracer):
76
77
  }
77
78
  attributes = LLMSpanAttributes(**span_attributes)
78
79
  span = tracer.start_span(
79
- name=name,
80
+ name=get_span_name(name),
80
81
  kind=SpanKind.CLIENT,
81
82
  context=set_span_in_context(trace.get_current_span()),
82
83
  )
@@ -29,6 +29,7 @@ from langtrace_python_sdk.utils.llm import (
29
29
  get_llm_request_attributes,
30
30
  get_llm_url,
31
31
  get_langtrace_attributes,
32
+ get_span_name,
32
33
  set_event_completion,
33
34
  set_event_completion_chunk,
34
35
  set_usage_attributes,
@@ -107,7 +108,7 @@ def chat_completions_create(original_method, version, tracer):
107
108
  # with tracer.start_as_current_span(APIS["CHAT_COMPLETION"]["METHOD"],
108
109
  # kind=SpanKind.CLIENT) as span:
109
110
  span = tracer.start_span(
110
- APIS["CHAT_COMPLETION"]["METHOD"],
111
+ name=get_span_name(APIS["CHAT_COMPLETION"]["METHOD"]),
111
112
  kind=SpanKind.CLIENT,
112
113
  context=set_span_in_context(trace.get_current_span()),
113
114
  )
@@ -335,7 +336,7 @@ def async_chat_completions_create(original_method, version, tracer):
335
336
  # with tracer.start_as_current_span(APIS["CHAT_COMPLETION"]["METHOD"],
336
337
  # kind=SpanKind.CLIENT) as span:
337
338
  span = tracer.start_span(
338
- APIS["CHAT_COMPLETION"]["METHOD"], kind=SpanKind.CLIENT
339
+ name=get_span_name(APIS["CHAT_COMPLETION"]["METHOD"]), kind=SpanKind.CLIENT
339
340
  )
340
341
  for field, value in attributes.model_dump(by_alias=True).items():
341
342
  set_span_attribute(span, field, value)
@@ -18,6 +18,7 @@ import json
18
18
 
19
19
  from langtrace.trace_attributes import FrameworkSpanAttributes
20
20
  from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
21
+ from langtrace_python_sdk.utils.llm import get_span_name
21
22
  from opentelemetry import baggage, trace
22
23
  from opentelemetry.trace.propagation import set_span_in_context
23
24
  from opentelemetry.trace import SpanKind, StatusCode
@@ -57,7 +58,7 @@ def generic_patch(
57
58
  attributes = FrameworkSpanAttributes(**span_attributes)
58
59
 
59
60
  with tracer.start_as_current_span(
60
- method_name,
61
+ name=get_span_name(method_name),
61
62
  kind=SpanKind.CLIENT,
62
63
  context=set_span_in_context(trace.get_current_span()),
63
64
  ) as span:
@@ -49,9 +49,8 @@ def patch_module_classes(
49
49
  lambda member: inspect.isclass(member) and member.__module__ == module.__name__,
50
50
  ):
51
51
  # loop through all public methods of the class
52
- for method_name, _ in inspect.getmembers(obj, predicate=inspect.isfunction):
53
- # Skip private methods
54
- if method_name.startswith("_"):
52
+ for method_name, method in inspect.getmembers(obj, predicate=inspect.isfunction):
53
+ if method.__qualname__.split('.')[0] != name:
55
54
  continue
56
55
  try:
57
56
  method_path = f"{name}.{method_name}"
@@ -82,6 +81,12 @@ class LangchainCommunityInstrumentation(BaseInstrumentor):
82
81
 
83
82
  # List of modules to patch, with their corresponding patch names
84
83
  modules_to_patch = [
84
+ (
85
+ "langchain_community.llms.sagemaker_endpoint",
86
+ "sagemaker_endpoint",
87
+ True,
88
+ True,
89
+ ),
85
90
  ("langchain_community.document_loaders.pdf", "load_pdf", True, True),
86
91
  ("langchain_community.vectorstores.faiss", "vector_store", False, False),
87
92
  ("langchain_community.vectorstores.pgvector", "vector_store", False, False),
@@ -17,6 +17,7 @@ limitations under the License.
17
17
  import json
18
18
 
19
19
  from langtrace.trace_attributes import FrameworkSpanAttributes
20
+ from langtrace_python_sdk.utils.llm import get_span_name
20
21
  from opentelemetry import baggage, trace
21
22
  from opentelemetry.trace.propagation import set_span_in_context
22
23
 
@@ -49,13 +50,15 @@ def generic_patch(
49
50
  **(extra_attributes if extra_attributes is not None else {}),
50
51
  }
51
52
 
53
+ span_attributes["langchain.metadata"] = to_json_string(kwargs)
54
+
52
55
  if trace_input and len(args) > 0:
53
56
  span_attributes["langchain.inputs"] = to_json_string(args)
54
57
 
55
58
  attributes = FrameworkSpanAttributes(**span_attributes)
56
59
 
57
60
  with tracer.start_as_current_span(
58
- method_name,
61
+ name=get_span_name(method_name),
59
62
  kind=SpanKind.CLIENT,
60
63
  context=set_span_in_context(trace.get_current_span()),
61
64
  ) as span:
@@ -85,15 +88,31 @@ def generic_patch(
85
88
 
86
89
  def clean_empty(d):
87
90
  """Recursively remove empty lists, empty dicts, or None elements from a dictionary."""
88
- if not isinstance(d, (dict, list)):
91
+ if not isinstance(d, (dict, list, tuple)):
89
92
  return d
93
+ if isinstance(d, tuple):
94
+ return tuple(val for val in (clean_empty(val) for val in d) if val != () and val is not None)
90
95
  if isinstance(d, list):
91
- return [v for v in (clean_empty(v) for v in d) if v != [] and v is not None]
92
- return {
93
- k: v
94
- for k, v in ((k, clean_empty(v)) for k, v in d.items())
95
- if v is not None and v != {}
96
- }
96
+ return [val for val in (clean_empty(val) for val in d) if val != [] and val is not None]
97
+ result = {}
98
+ for k, val in d.items():
99
+ if isinstance(val, dict):
100
+ val = clean_empty(val)
101
+ if val != {} and val is not None:
102
+ result[k] = val
103
+ elif isinstance(val, list):
104
+ val = [clean_empty(value) for value in val]
105
+ if val != [] and val is not None:
106
+ result[k] = val
107
+ elif isinstance(val, str) and val is not None:
108
+ if val.strip() != "":
109
+ result[k] = val.strip()
110
+ elif isinstance(val, object):
111
+ # some langchain objects have a text attribute
112
+ val = getattr(val, 'text', None)
113
+ if val is not None and val.strip() != "":
114
+ result[k] = val.strip()
115
+ return result
97
116
 
98
117
 
99
118
  def custom_serializer(obj):
@@ -108,5 +127,12 @@ def custom_serializer(obj):
108
127
 
109
128
  def to_json_string(any_object):
110
129
  """Converts any object to a JSON-parseable string, omitting empty or None values."""
111
- cleaned_object = clean_empty(any_object)
112
- return json.dumps(cleaned_object, default=custom_serializer, indent=2)
130
+ try:
131
+ cleaned_object = clean_empty(any_object)
132
+ return json.dumps(cleaned_object, default=custom_serializer, indent=2)
133
+ except NotImplementedError:
134
+ # Handle specific types that raise this error
135
+ return str(any_object) # or another appropriate fallback
136
+ except TypeError:
137
+ # Handle cases where obj is not serializable
138
+ return str(any_object)
@@ -66,9 +66,8 @@ def patch_module_classes(
66
66
  if name.startswith("_") or name in exclude_classes:
67
67
  continue
68
68
  # loop through all public methods of the class
69
- for method_name, _ in inspect.getmembers(obj, predicate=inspect.isfunction):
70
- # Skip private methods
71
- if method_name.startswith("_") or method_name in exclude_methods:
69
+ for method_name, method in inspect.getmembers(obj, predicate=inspect.isfunction):
70
+ if method_name in exclude_methods or method.__qualname__.split('.')[0] != name:
72
71
  continue
73
72
  try:
74
73
  method_path = f"{name}.{method_name}"
@@ -126,6 +125,7 @@ class LangchainCoreInstrumentation(BaseInstrumentor):
126
125
  modules_to_patch = [
127
126
  ("langchain_core.retrievers", "retriever", generic_patch, True, True),
128
127
  ("langchain_core.prompts.chat", "prompt", generic_patch, True, True),
128
+ ("langchain_core.language_models.llms", "generate", generic_patch, True, True),
129
129
  ("langchain_core.runnables.base", "runnable", runnable_patch, True, True),
130
130
  (
131
131
  "langchain_core.runnables.passthrough",
@@ -17,6 +17,7 @@ limitations under the License.
17
17
  import json
18
18
 
19
19
  from langtrace.trace_attributes import FrameworkSpanAttributes
20
+ from langtrace_python_sdk.utils.llm import get_span_name
20
21
  from opentelemetry import baggage, trace
21
22
  from opentelemetry.trace import SpanKind, StatusCode
22
23
  from opentelemetry.trace.status import Status
@@ -58,24 +59,15 @@ def generic_patch(
58
59
  **(extra_attributes if extra_attributes is not None else {}),
59
60
  }
60
61
 
61
- if len(args) > 0 and trace_input:
62
- inputs = {}
63
- for arg in args:
64
- if isinstance(arg, dict):
65
- for key, value in arg.items():
66
- if isinstance(value, list):
67
- for item in value:
68
- inputs[key] = item.__class__.__name__
69
- elif isinstance(value, str):
70
- inputs[key] = value
71
- elif isinstance(arg, str):
72
- inputs["input"] = arg
73
- span_attributes["langchain.inputs"] = to_json_string(inputs)
62
+ if trace_input and len(args) > 0:
63
+ span_attributes["langchain.inputs"] = to_json_string(args)
64
+
65
+ span_attributes["langchain.metadata"] = to_json_string(kwargs)
74
66
 
75
67
  attributes = FrameworkSpanAttributes(**span_attributes)
76
68
 
77
69
  with tracer.start_as_current_span(
78
- method_name,
70
+ name=get_span_name(method_name),
79
71
  kind=SpanKind.CLIENT,
80
72
  context=set_span_in_context(trace.get_current_span()),
81
73
  ) as span:
@@ -199,15 +191,31 @@ def runnable_patch(
199
191
 
200
192
  def clean_empty(d):
201
193
  """Recursively remove empty lists, empty dicts, or None elements from a dictionary."""
202
- if not isinstance(d, (dict, list)):
194
+ if not isinstance(d, (dict, list, tuple)):
203
195
  return d
196
+ if isinstance(d, tuple):
197
+ return tuple(val for val in (clean_empty(val) for val in d) if val != () and val is not None)
204
198
  if isinstance(d, list):
205
- return [v for v in (clean_empty(v) for v in d) if v != [] and v is not None]
206
- return {
207
- k: v
208
- for k, v in ((k, clean_empty(v)) for k, v in d.items())
209
- if v is not None and v != {}
210
- }
199
+ return [val for val in (clean_empty(val) for val in d) if val != [] and val is not None]
200
+ result = {}
201
+ for k, val in d.items():
202
+ if isinstance(val, dict):
203
+ val = clean_empty(val)
204
+ if val != {} and val is not None:
205
+ result[k] = val
206
+ elif isinstance(val, list):
207
+ val = [clean_empty(value) for value in val]
208
+ if val != [] and val is not None:
209
+ result[k] = val
210
+ elif isinstance(val, str) and val is not None:
211
+ if val.strip() != "":
212
+ result[k] = val.strip()
213
+ elif isinstance(val, object):
214
+ # some langchain objects have a text attribute
215
+ val = getattr(val, 'text', None)
216
+ if val is not None and val.strip() != "":
217
+ result[k] = val.strip()
218
+ return result
211
219
 
212
220
 
213
221
  def custom_serializer(obj):
@@ -222,5 +230,12 @@ def custom_serializer(obj):
222
230
 
223
231
  def to_json_string(any_object):
224
232
  """Converts any object to a JSON-parseable string, omitting empty or None values."""
225
- cleaned_object = clean_empty(any_object)
226
- return json.dumps(cleaned_object, default=custom_serializer, indent=2)
233
+ try:
234
+ cleaned_object = clean_empty(any_object)
235
+ return json.dumps(cleaned_object, default=custom_serializer, indent=2)
236
+ except NotImplementedError:
237
+ # Handle specific types that raise this error
238
+ return str(any_object) # or another appropriate fallback
239
+ except TypeError:
240
+ # Handle cases where obj is not serializable
241
+ return str(any_object)
@@ -15,6 +15,7 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  import json
18
+ from langtrace_python_sdk.utils.llm import get_span_name
18
19
  from opentelemetry.trace.propagation import set_span_in_context
19
20
 
20
21
  from langtrace.trace_attributes import FrameworkSpanAttributes
@@ -52,7 +53,7 @@ def patch_graph_methods(method_name, tracer, version):
52
53
  attributes = FrameworkSpanAttributes(**span_attributes)
53
54
 
54
55
  with tracer.start_as_current_span(
55
- method_name,
56
+ name=get_span_name(method_name),
56
57
  kind=SpanKind.CLIENT,
57
58
  context=set_span_in_context(trace.get_current_span()),
58
59
  ) as span:
@@ -15,6 +15,7 @@ limitations under the License.
15
15
  """
16
16
 
17
17
  from langtrace.trace_attributes import FrameworkSpanAttributes
18
+ from langtrace_python_sdk.utils.llm import get_span_name
18
19
  from opentelemetry import baggage, trace
19
20
  from opentelemetry.trace import SpanKind
20
21
  from opentelemetry.trace.status import Status, StatusCode
@@ -49,7 +50,7 @@ def generic_patch(method, task, tracer, version):
49
50
  attributes = FrameworkSpanAttributes(**span_attributes)
50
51
 
51
52
  with tracer.start_as_current_span(
52
- method,
53
+ name=get_span_name(method),
53
54
  kind=SpanKind.CLIENT,
54
55
  context=set_span_in_context(trace.get_current_span()),
55
56
  ) as span:
@@ -94,7 +95,9 @@ def async_generic_patch(method, task, tracer, version):
94
95
 
95
96
  attributes = FrameworkSpanAttributes(**span_attributes)
96
97
 
97
- with tracer.start_as_current_span(method, kind=SpanKind.CLIENT) as span:
98
+ with tracer.start_as_current_span(
99
+ name=get_span_name(method), kind=SpanKind.CLIENT
100
+ ) as span:
98
101
  async for field, value in attributes.model_dump(by_alias=True).items():
99
102
  if value is not None:
100
103
  span.set_attribute(field, value)
@@ -5,6 +5,7 @@ from langtrace_python_sdk.utils.llm import (
5
5
  get_langtrace_attributes,
6
6
  get_llm_request_attributes,
7
7
  get_llm_url,
8
+ get_span_name,
8
9
  set_event_completion,
9
10
  set_event_completion_chunk,
10
11
  )
@@ -35,7 +36,7 @@ def generic_patch(operation_name, version, tracer):
35
36
 
36
37
  attributes = LLMSpanAttributes(**span_attributes)
37
38
  with tracer.start_as_current_span(
38
- f'ollama.{api["METHOD"]}', kind=SpanKind.CLIENT
39
+ name=get_span_name(f'ollama.{api["METHOD"]}'), kind=SpanKind.CLIENT
39
40
  ) as span:
40
41
  _set_input_attributes(span, kwargs, attributes)
41
42
 
@@ -37,6 +37,7 @@ from langtrace_python_sdk.utils.llm import (
37
37
  get_langtrace_attributes,
38
38
  get_llm_request_attributes,
39
39
  get_llm_url,
40
+ get_span_name,
40
41
  get_tool_calls,
41
42
  is_streaming,
42
43
  set_event_completion,
@@ -64,7 +65,7 @@ def images_generate(original_method, version, tracer):
64
65
  attributes = LLMSpanAttributes(**span_attributes)
65
66
 
66
67
  with tracer.start_as_current_span(
67
- APIS["IMAGES_GENERATION"]["METHOD"],
68
+ name=get_span_name(APIS["IMAGES_GENERATION"]["METHOD"]),
68
69
  kind=SpanKind.CLIENT,
69
70
  context=set_span_in_context(trace.get_current_span()),
70
71
  ) as span:
@@ -127,7 +128,7 @@ def async_images_generate(original_method, version, tracer):
127
128
  attributes = LLMSpanAttributes(**span_attributes)
128
129
 
129
130
  with tracer.start_as_current_span(
130
- APIS["IMAGES_GENERATION"]["METHOD"],
131
+ name=get_span_name(APIS["IMAGES_GENERATION"]["METHOD"]),
131
132
  kind=SpanKind.CLIENT,
132
133
  context=set_span_in_context(trace.get_current_span()),
133
134
  ) as span:
@@ -192,7 +193,7 @@ def images_edit(original_method, version, tracer):
192
193
  attributes = LLMSpanAttributes(**span_attributes)
193
194
 
194
195
  with tracer.start_as_current_span(
195
- APIS["IMAGES_EDIT"]["METHOD"],
196
+ name=APIS["IMAGES_EDIT"]["METHOD"],
196
197
  kind=SpanKind.CLIENT,
197
198
  context=set_span_in_context(trace.get_current_span()),
198
199
  ) as span:
@@ -282,7 +283,7 @@ def chat_completions_create(original_method, version, tracer):
282
283
  attributes = LLMSpanAttributes(**span_attributes)
283
284
 
284
285
  span = tracer.start_span(
285
- APIS["CHAT_COMPLETION"]["METHOD"],
286
+ name=get_span_name(APIS["CHAT_COMPLETION"]["METHOD"]),
286
287
  kind=SpanKind.CLIENT,
287
288
  context=set_span_in_context(trace.get_current_span()),
288
289
  )
@@ -376,7 +377,7 @@ def async_chat_completions_create(original_method, version, tracer):
376
377
  attributes = LLMSpanAttributes(**span_attributes)
377
378
 
378
379
  span = tracer.start_span(
379
- APIS["CHAT_COMPLETION"]["METHOD"],
380
+ name=get_span_name(APIS["CHAT_COMPLETION"]["METHOD"]),
380
381
  kind=SpanKind.CLIENT,
381
382
  context=set_span_in_context(trace.get_current_span()),
382
383
  )
@@ -455,7 +456,7 @@ def embeddings_create(original_method, version, tracer):
455
456
  attributes = LLMSpanAttributes(**span_attributes)
456
457
 
457
458
  with tracer.start_as_current_span(
458
- APIS["EMBEDDINGS_CREATE"]["METHOD"],
459
+ name=get_span_name(APIS["EMBEDDINGS_CREATE"]["METHOD"]),
459
460
  kind=SpanKind.CLIENT,
460
461
  context=set_span_in_context(trace.get_current_span()),
461
462
  ) as span:
@@ -512,7 +513,7 @@ def async_embeddings_create(original_method, version, tracer):
512
513
  )
513
514
 
514
515
  with tracer.start_as_current_span(
515
- APIS["EMBEDDINGS_CREATE"]["METHOD"],
516
+ name=get_span_name(APIS["EMBEDDINGS_CREATE"]["METHOD"]),
516
517
  kind=SpanKind.CLIENT,
517
518
  context=set_span_in_context(trace.get_current_span()),
518
519
  ) as span:
@@ -17,6 +17,7 @@ limitations under the License.
17
17
  import json
18
18
 
19
19
  from langtrace.trace_attributes import DatabaseSpanAttributes
20
+ from langtrace_python_sdk.utils.llm import get_span_name
20
21
  from opentelemetry import baggage, trace
21
22
  from opentelemetry.trace import SpanKind
22
23
  from opentelemetry.trace.status import Status, StatusCode
@@ -57,7 +58,7 @@ def generic_patch(operation_name, version, tracer):
57
58
  attributes = DatabaseSpanAttributes(**span_attributes)
58
59
 
59
60
  with tracer.start_as_current_span(
60
- api["METHOD"],
61
+ name=get_span_name(api["METHOD"]),
61
62
  kind=SpanKind.CLIENT,
62
63
  context=set_span_in_context(trace.get_current_span()),
63
64
  ) as span:
@@ -16,6 +16,7 @@ limitations under the License.
16
16
 
17
17
  import json
18
18
  from langtrace.trace_attributes import DatabaseSpanAttributes
19
+ from langtrace_python_sdk.utils.llm import get_span_name
19
20
  from langtrace_python_sdk.utils.silently_fail import silently_fail
20
21
  from langtrace_python_sdk.utils import set_span_attribute
21
22
  from opentelemetry import baggage, trace
@@ -58,7 +59,7 @@ def collection_patch(method, version, tracer):
58
59
  attributes = DatabaseSpanAttributes(**span_attributes)
59
60
 
60
61
  with tracer.start_as_current_span(
61
- api["METHOD"],
62
+ name=get_span_name(api["METHOD"]),
62
63
  kind=SpanKind.CLIENT,
63
64
  context=set_span_in_context(trace.get_current_span()),
64
65
  ) as span: