langtrace-python-sdk 3.3.13__tar.gz → 3.3.15__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 (283) hide show
  1. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/PKG-INFO +4 -3
  2. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/__init__.py +6 -0
  3. langtrace_python_sdk-3.3.15/src/examples/cohere_example/chat_streamv2.py +17 -0
  4. langtrace_python_sdk-3.3.15/src/examples/cohere_example/chatv2.py +21 -0
  5. langtrace_python_sdk-3.3.15/src/examples/cohere_example/rerankv2.py +23 -0
  6. langtrace_python_sdk-3.3.15/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +2 -0
  7. langtrace_python_sdk-3.3.15/src/langtrace_python_sdk/constants/instrumentation/cohere.py +42 -0
  8. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +8 -0
  9. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +25 -0
  10. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +106 -8
  11. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/dspy/patch.py +1 -1
  12. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/gemini/patch.py +3 -3
  13. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +1 -1
  14. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/patch.py +43 -4
  15. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/vertexai/patch.py +1 -1
  16. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/langtrace.py +14 -6
  17. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/llm.py +26 -4
  18. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/with_root_span.py +11 -0
  19. langtrace_python_sdk-3.3.15/src/langtrace_python_sdk/version.py +1 -0
  20. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/run_example.py +2 -2
  21. langtrace_python_sdk-3.3.15/src/tests/openai/cassettes/test_embeddings_base_url.yaml +208 -0
  22. langtrace_python_sdk-3.3.15/src/tests/openai/test_embeddings.py +88 -0
  23. langtrace_python_sdk-3.3.15/src/tests/test_session_id.py +59 -0
  24. langtrace_python_sdk-3.3.13/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -1
  25. langtrace_python_sdk-3.3.13/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -22
  26. langtrace_python_sdk-3.3.13/src/langtrace_python_sdk/version.py +0 -1
  27. langtrace_python_sdk-3.3.13/src/tests/openai/test_embeddings.py +0 -0
  28. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/.gitignore +0 -0
  29. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/LICENSE +0 -0
  30. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/README.md +0 -0
  31. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/pyproject.toml +0 -0
  32. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/__init__.py +0 -0
  33. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/__init__.py +0 -0
  34. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/anthropic_example/__init__.py +0 -0
  35. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/anthropic_example/completion.py +0 -0
  36. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/autogen_example/__init__.py +0 -0
  37. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/autogen_example/main.py +0 -0
  38. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/awsbedrock_examples/__init__.py +0 -0
  39. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/awsbedrock_examples/converse.py +0 -0
  40. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/azureopenai_example/__init__.py +0 -0
  41. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/azureopenai_example/completion.py +0 -0
  42. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cerebras_example/__init__.py +0 -0
  43. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cerebras_example/main.py +0 -0
  44. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/chroma_example/__init__.py +0 -0
  45. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/chroma_example/basic.py +0 -0
  46. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/chat.py +0 -0
  47. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/chat_stream.py +0 -0
  48. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/embed.py +0 -0
  49. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/rerank.py +0 -0
  50. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/tools.py +0 -0
  51. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/__init__.py +0 -0
  52. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/basic.py +0 -0
  53. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/__init__.py +0 -0
  54. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/agents.py +0 -0
  55. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/main.py +0 -0
  56. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/tasks.py +0 -0
  57. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/tools/__init__.py +0 -0
  58. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/tools/browser_tools.py +0 -0
  59. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/__init__.py +0 -0
  60. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/agents.py +0 -0
  61. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/main.py +0 -0
  62. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/tasks.py +0 -0
  63. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/__init__.py +0 -0
  64. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/agents.py +0 -0
  65. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/main.py +0 -0
  66. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/tasks.py +0 -0
  67. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/tools/calculator.py +0 -0
  68. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/tools/search_tools.py +0 -0
  69. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_basic.py +0 -0
  70. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_basic_with_chain_of_thought.py +0 -0
  71. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_basic_with_signature.py +0 -0
  72. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py +0 -0
  73. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/math_problems_cot.py +0 -0
  74. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/math_problems_cot_parallel.py +0 -0
  75. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/optimizers/bootstrap_fewshot.py +0 -0
  76. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/program_of_thought_basic.py +0 -0
  77. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/quiz_gen.py +0 -0
  78. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/react.py +0 -0
  79. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/embedchain_example/simple.py +0 -0
  80. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/fastapi_example/__init__.py +0 -0
  81. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/fastapi_example/basic_route.py +0 -0
  82. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/gemini_example/__init__.py +0 -0
  83. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/gemini_example/function_tools.py +0 -0
  84. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/gemini_example/main.py +0 -0
  85. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/hiveagent_example/basic.py +0 -0
  86. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/inspect_ai_example/basic_eval.py +0 -0
  87. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/__init__.py +0 -0
  88. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/basic.py +0 -0
  89. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/groq_example.py +0 -0
  90. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/langchain_google_example.py +0 -0
  91. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/langgraph_example.py +0 -0
  92. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/langgraph_example_tools.py +0 -0
  93. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/sagemaker.py +0 -0
  94. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/tool.py +0 -0
  95. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/langgraph_example/main.py +0 -0
  96. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/litellm_example/basic.py +0 -0
  97. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/litellm_example/config.yaml +0 -0
  98. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/litellm_example/proxy_basic.py +0 -0
  99. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/__init__.py +0 -0
  100. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/agent.py +0 -0
  101. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/basic.py +0 -0
  102. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  103. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/milvus_example/main.py +0 -0
  104. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/__init__.py +0 -0
  105. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/complete.py +0 -0
  106. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/complete_async.py +0 -0
  107. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/embeddings.py +0 -0
  108. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/mongo_vector_search_example/main.py +0 -0
  109. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/ollama_example/__init__.py +0 -0
  110. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/ollama_example/basic.py +0 -0
  111. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/__init__.py +0 -0
  112. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  113. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  114. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/chat_completion.py +0 -0
  115. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/chat_completion_tool_choice.py +0 -0
  116. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/embeddings_create.py +0 -0
  117. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/function_calling.py +0 -0
  118. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/images_edit.py +0 -0
  119. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/images_generate.py +0 -0
  120. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
  121. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/resources/mask.png +0 -0
  122. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/send_user_feedback.py +0 -0
  123. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/tool_calling.py +0 -0
  124. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  125. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  126. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/otlp_example/otlp_basic.py +0 -0
  127. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/otlp_example/otlp_with_langtrace.py +0 -0
  128. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/perplexity_example/basic.py +0 -0
  129. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/pinecone_example/__init__.py +0 -0
  130. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/pinecone_example/basic.py +0 -0
  131. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/qdrant_example/__init__.py +0 -0
  132. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/qdrant_example/basic.py +0 -0
  133. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/routellm_example/basic.py +0 -0
  134. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/vertexai_example/__init__.py +0 -0
  135. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/vertexai_example/main.py +0 -0
  136. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/weaviate_example/__init__.py +0 -0
  137. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/examples/weaviate_example/query_text.py +0 -0
  138. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/__init__.py +0 -0
  139. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  140. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  141. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  142. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/aws_bedrock.py +0 -0
  143. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  144. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
  145. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/embedchain.py +0 -0
  146. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/gemini.py +0 -0
  147. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  148. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/litellm.py +0 -0
  149. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/milvus.py +0 -0
  150. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/mistral.py +0 -0
  151. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
  152. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  153. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  154. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/pymongo.py +0 -0
  155. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  156. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/vertexai.py +0 -0
  157. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
  158. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  159. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +0 -0
  160. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  161. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  162. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  163. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  164. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/types.py +0 -0
  165. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/autogen/__init__.py +0 -0
  166. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/autogen/instrumentation.py +0 -0
  167. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/autogen/patch.py +0 -0
  168. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/aws_bedrock/__init__.py +0 -0
  169. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/aws_bedrock/instrumentation.py +0 -0
  170. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/aws_bedrock/patch.py +0 -0
  171. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cerebras/__init__.py +0 -0
  172. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cerebras/instrumentation.py +0 -0
  173. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cerebras/patch.py +0 -0
  174. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  175. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  176. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
  177. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  178. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/crewai/__init__.py +0 -0
  179. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/crewai/instrumentation.py +0 -0
  180. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/crewai/patch.py +0 -0
  181. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +0 -0
  182. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +0 -0
  183. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/embedchain/__init__.py +0 -0
  184. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/embedchain/instrumentation.py +0 -0
  185. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/embedchain/patch.py +0 -0
  186. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/gemini/__init__.py +0 -0
  187. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/gemini/instrumentation.py +0 -0
  188. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  189. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  190. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
  191. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  192. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  193. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
  194. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  195. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  196. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
  197. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  198. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  199. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  200. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  201. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
  202. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/__init__.py +0 -0
  203. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/instrumentation.py +0 -0
  204. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/patch.py +0 -0
  205. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/types.py +0 -0
  206. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  207. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  208. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
  209. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/milvus/__init__.py +0 -0
  210. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/milvus/instrumentation.py +0 -0
  211. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/milvus/patch.py +0 -0
  212. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/mistral/__init__.py +0 -0
  213. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/mistral/instrumentation.py +0 -0
  214. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/mistral/patch.py +0 -0
  215. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
  216. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
  217. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +0 -0
  218. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  219. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  220. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/types.py +0 -0
  221. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  222. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
  223. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
  224. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pymongo/__init__.py +0 -0
  225. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pymongo/instrumentation.py +0 -0
  226. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pymongo/patch.py +0 -0
  227. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  228. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  229. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
  230. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/vertexai/__init__.py +0 -0
  231. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/vertexai/instrumentation.py +0 -0
  232. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
  233. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
  234. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
  235. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/types/__init__.py +0 -0
  236. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/__init__.py +0 -0
  237. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
  238. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/misc.py +0 -0
  239. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
  240. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
  241. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
  242. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/types.py +0 -0
  243. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/__init__.py +0 -0
  244. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  245. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  246. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  247. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/conftest.py +0 -0
  248. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/test_anthropic.py +0 -0
  249. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/chroma/conftest.py +0 -0
  250. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/chroma/test_chroma.py +0 -0
  251. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  252. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  253. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  254. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  255. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/conftest.py +0 -0
  256. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/test_cohere_chat.py +0 -0
  257. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/test_cohere_embed.py +0 -0
  258. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/cohere/test_cohere_rerank.py +0 -0
  259. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/conftest.py +0 -0
  260. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_async_chat_completion.yaml +0 -0
  261. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  262. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_chat_completion.yaml +0 -0
  263. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_chat_completion_streaming.yaml +0 -0
  264. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/groq/conftest.py +0 -0
  265. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/groq/test_groq.py +0 -0
  266. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
  267. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/langchain/conftest.py +0 -0
  268. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/langchain/test_langchain.py +0 -0
  269. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  270. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  271. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  272. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  273. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  274. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/conftest.py +0 -0
  275. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/test_chat_completion.py +0 -0
  276. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/openai/test_image_generation.py +0 -0
  277. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
  278. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
  279. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/conftest.py +0 -0
  280. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/test_pinecone.py +0 -0
  281. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/qdrant/conftest.py +0 -0
  282. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/qdrant/test_qdrant.py +0 -0
  283. {langtrace_python_sdk-3.3.13 → langtrace_python_sdk-3.3.15}/src/tests/utils.py +0 -0
@@ -1,10 +1,11 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: langtrace-python-sdk
3
- Version: 3.3.13
3
+ Version: 3.3.15
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>
7
- License: Apache-2.0
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
8
9
  Classifier: License :: OSI Approved :: Apache Software License
9
10
  Classifier: Operating System :: OS Independent
10
11
  Classifier: Programming Language :: Python :: 3
@@ -1,8 +1,11 @@
1
1
  from examples.cohere_example.chat import chat_comp
2
+ from examples.cohere_example.chatv2 import chat_v2
3
+ from examples.cohere_example.chat_streamv2 import chat_stream_v2
2
4
  from examples.cohere_example.chat_stream import chat_stream
3
5
  from examples.cohere_example.tools import tool_calling
4
6
  from examples.cohere_example.embed import embed
5
7
  from examples.cohere_example.rerank import rerank
8
+ from examples.cohere_example.rerankv2 import rerank_v2
6
9
  from langtrace_python_sdk import with_langtrace_root_span
7
10
 
8
11
 
@@ -10,8 +13,11 @@ class CohereRunner:
10
13
 
11
14
  @with_langtrace_root_span("Cohere")
12
15
  def run(self):
16
+ chat_v2()
17
+ chat_stream_v2()
13
18
  chat_comp()
14
19
  chat_stream()
15
20
  tool_calling()
16
21
  embed()
17
22
  rerank()
23
+ rerank_v2()
@@ -0,0 +1,17 @@
1
+ import os
2
+ from langtrace_python_sdk import langtrace
3
+ import cohere
4
+
5
+ langtrace.init(api_key=os.getenv("LANGTRACE_API_KEY"))
6
+ co = cohere.ClientV2(api_key=os.getenv("COHERE_API_KEY"))
7
+
8
+ def chat_stream_v2():
9
+ res = co.chat_stream(
10
+ model="command-r-plus-08-2024",
11
+ messages=[{"role": "user", "content": "Write a title for a blog post about API design. Only output the title text"}],
12
+ )
13
+
14
+ for event in res:
15
+ if event:
16
+ if event.type == "content-delta":
17
+ print(event.delta.message.content.text)
@@ -0,0 +1,21 @@
1
+ import os
2
+ from langtrace_python_sdk import langtrace
3
+ import cohere
4
+
5
+ langtrace.init(api_key=os.getenv("LANGTRACE_API_KEY"))
6
+
7
+
8
+ def chat_v2():
9
+ co = cohere.ClientV2(api_key=os.getenv("COHERE_API_KEY"))
10
+
11
+ res = co.chat(
12
+ model="command-r-plus-08-2024",
13
+ messages=[
14
+ {
15
+ "role": "user",
16
+ "content": "Write a title for a blog post about API design. Only output the title text.",
17
+ }
18
+ ],
19
+ )
20
+
21
+ print(res.message.content[0].text)
@@ -0,0 +1,23 @@
1
+ import os
2
+ from langtrace_python_sdk import langtrace
3
+ import cohere
4
+
5
+ langtrace.init(api_key=os.getenv("LANGTRACE_API_KEY"))
6
+ co = cohere.ClientV2(api_key=os.getenv("COHERE_API_KEY"))
7
+
8
+ docs = [
9
+ "Carson City is the capital city of the American state of Nevada.",
10
+ "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
11
+ "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.",
12
+ "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
13
+ "Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.",
14
+ ]
15
+
16
+ def rerank_v2():
17
+ response = co.rerank(
18
+ model="rerank-v3.5",
19
+ query="What is the capital of the United States?",
20
+ documents=docs,
21
+ top_n=3,
22
+ )
23
+ print(response)
@@ -0,0 +1,2 @@
1
+ LANGTRACE_REMOTE_URL = "https://app.langtrace.ai"
2
+ LANGTRACE_SESSION_ID_HEADER = "x-langtrace-session-id"
@@ -0,0 +1,42 @@
1
+ APIS = {
2
+ "CHAT_CREATE": {
3
+ "URL": "https://api.cohere.ai",
4
+ "METHOD": "cohere.client.chat",
5
+ "ENDPOINT": "/v1/chat",
6
+ },
7
+ "CHAT_CREATE_V2": {
8
+ "URL": "https://api.cohere.ai",
9
+ "METHOD": "cohere.client_v2.chat",
10
+ "ENDPOINT": "/v2/chat",
11
+ },
12
+ "EMBED": {
13
+ "URL": "https://api.cohere.ai",
14
+ "METHOD": "cohere.client.embed",
15
+ "ENDPOINT": "/v1/embed",
16
+ },
17
+ "EMBED_V2": {
18
+ "URL": "https://api.cohere.ai",
19
+ "METHOD": "cohere.client_v2.embed",
20
+ "ENDPOINT": "/v2/embed",
21
+ },
22
+ "CHAT_STREAM": {
23
+ "URL": "https://api.cohere.ai",
24
+ "METHOD": "cohere.client.chat_stream",
25
+ "ENDPOINT": "/v1/chat",
26
+ },
27
+ "CHAT_STREAM_V2": {
28
+ "URL": "https://api.cohere.ai",
29
+ "METHOD": "cohere.client_v2.chat_stream",
30
+ "ENDPOINT": "/v2/chat",
31
+ },
32
+ "RERANK": {
33
+ "URL": "https://api.cohere.ai",
34
+ "METHOD": "cohere.client.rerank",
35
+ "ENDPOINT": "/v1/rerank",
36
+ },
37
+ "RERANK_V2": {
38
+ "URL": "https://api.cohere.ai",
39
+ "METHOD": "cohere.client_v2.rerank",
40
+ "ENDPOINT": "/v2/rerank",
41
+ },
42
+ }
@@ -9,6 +9,7 @@ from opentelemetry.trace.span import format_trace_id
9
9
 
10
10
  from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
11
11
  LANGTRACE_REMOTE_URL,
12
+ LANGTRACE_SESSION_ID_HEADER,
12
13
  )
13
14
  from colorama import Fore
14
15
  from requests.exceptions import RequestException
@@ -51,12 +52,14 @@ class LangTraceExporter(SpanExporter):
51
52
  api_key: str
52
53
  api_host: str
53
54
  disable_logging: bool
55
+ session_id: str
54
56
 
55
57
  def __init__(
56
58
  self,
57
59
  api_host,
58
60
  api_key: str = None,
59
61
  disable_logging: bool = False,
62
+ session_id: str = None,
60
63
  ) -> None:
61
64
  self.api_key = api_key or os.environ.get("LANGTRACE_API_KEY")
62
65
  self.api_host = (
@@ -65,6 +68,7 @@ class LangTraceExporter(SpanExporter):
65
68
  else api_host
66
69
  )
67
70
  self.disable_logging = disable_logging
71
+ self.session_id = session_id or os.environ.get("LANGTRACE_SESSION_ID")
68
72
 
69
73
  def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
70
74
  """
@@ -82,6 +86,10 @@ class LangTraceExporter(SpanExporter):
82
86
  "User-Agent": "LangtraceExporter",
83
87
  }
84
88
 
89
+ # Add session ID if available
90
+ if self.session_id:
91
+ headers[LANGTRACE_SESSION_ID_HEADER] = self.session_id
92
+
85
93
  # Check if the OTEL_EXPORTER_OTLP_HEADERS environment variable is set
86
94
  otel_headers = os.getenv("OTEL_EXPORTER_OTLP_HEADERS", None)
87
95
  if otel_headers:
@@ -23,6 +23,7 @@ from wrapt import wrap_function_wrapper
23
23
 
24
24
  from langtrace_python_sdk.instrumentation.cohere.patch import (
25
25
  chat_create,
26
+ chat_create_v2,
26
27
  chat_stream,
27
28
  embed,
28
29
  rerank,
@@ -48,6 +49,18 @@ class CohereInstrumentation(BaseInstrumentor):
48
49
  chat_create("cohere.client.chat", version, tracer),
49
50
  )
50
51
 
52
+ wrap_function_wrapper(
53
+ "cohere.client_v2",
54
+ "ClientV2.chat",
55
+ chat_create_v2("cohere.client_v2.chat", version, tracer),
56
+ )
57
+
58
+ wrap_function_wrapper(
59
+ "cohere.client_v2",
60
+ "ClientV2.chat_stream",
61
+ chat_create_v2("cohere.client_v2.chat", version, tracer, stream=True),
62
+ )
63
+
51
64
  wrap_function_wrapper(
52
65
  "cohere.client",
53
66
  "Client.chat_stream",
@@ -60,12 +73,24 @@ class CohereInstrumentation(BaseInstrumentor):
60
73
  embed("cohere.client.embed", version, tracer),
61
74
  )
62
75
 
76
+ wrap_function_wrapper(
77
+ "cohere.client_v2",
78
+ "ClientV2.embed",
79
+ embed("cohere.client.embed", version, tracer, v2=True),
80
+ )
81
+
63
82
  wrap_function_wrapper(
64
83
  "cohere.client",
65
84
  "Client.rerank",
66
85
  rerank("cohere.client.rerank", version, tracer),
67
86
  )
68
87
 
88
+ wrap_function_wrapper(
89
+ "cohere.client_v2",
90
+ "ClientV2.rerank",
91
+ rerank("cohere.client.rerank", version, tracer, v2=True),
92
+ )
93
+
69
94
  def _instrument_module(self, module_name):
70
95
  pass
71
96
 
@@ -24,6 +24,7 @@ from langtrace_python_sdk.utils.llm import (
24
24
  get_span_name,
25
25
  set_event_completion,
26
26
  set_usage_attributes,
27
+ StreamWrapper
27
28
  )
28
29
  from langtrace.trace_attributes import Event, LLMSpanAttributes
29
30
  from langtrace_python_sdk.utils import set_span_attribute
@@ -38,7 +39,7 @@ from langtrace_python_sdk.constants.instrumentation.common import (
38
39
  from langtrace.trace_attributes import SpanAttributes
39
40
 
40
41
 
41
- def rerank(original_method, version, tracer):
42
+ def rerank(original_method, version, tracer, v2=False):
42
43
  """Wrap the `rerank` method."""
43
44
 
44
45
  def traced_method(wrapped, instance, args, kwargs):
@@ -49,8 +50,8 @@ def rerank(original_method, version, tracer):
49
50
  **get_llm_request_attributes(kwargs, operation_name="rerank"),
50
51
  **get_llm_url(instance),
51
52
  SpanAttributes.LLM_REQUEST_MODEL: kwargs.get("model") or "command-r-plus",
52
- SpanAttributes.LLM_URL: APIS["RERANK"]["URL"],
53
- SpanAttributes.LLM_PATH: APIS["RERANK"]["ENDPOINT"],
53
+ SpanAttributes.LLM_URL: APIS["RERANK" if not v2 else "RERANK_V2"]["URL"],
54
+ SpanAttributes.LLM_PATH: APIS["RERANK" if not v2 else "RERANK_V2"]["ENDPOINT"],
54
55
  SpanAttributes.LLM_REQUEST_DOCUMENTS: json.dumps(
55
56
  kwargs.get("documents"), cls=datetime_encoder
56
57
  ),
@@ -61,7 +62,7 @@ def rerank(original_method, version, tracer):
61
62
  attributes = LLMSpanAttributes(**span_attributes)
62
63
 
63
64
  span = tracer.start_span(
64
- name=get_span_name(APIS["RERANK"]["METHOD"]), kind=SpanKind.CLIENT
65
+ name=get_span_name(APIS["RERANK" if not v2 else "RERANK_V2"]["METHOD"]), kind=SpanKind.CLIENT
65
66
  )
66
67
  for field, value in attributes.model_dump(by_alias=True).items():
67
68
  set_span_attribute(span, field, value)
@@ -119,7 +120,7 @@ def rerank(original_method, version, tracer):
119
120
  return traced_method
120
121
 
121
122
 
122
- def embed(original_method, version, tracer):
123
+ def embed(original_method, version, tracer, v2=False):
123
124
  """Wrap the `embed` method."""
124
125
 
125
126
  def traced_method(wrapped, instance, args, kwargs):
@@ -129,8 +130,8 @@ def embed(original_method, version, tracer):
129
130
  **get_langtrace_attributes(version, service_provider),
130
131
  **get_llm_request_attributes(kwargs, operation_name="embed"),
131
132
  **get_llm_url(instance),
132
- SpanAttributes.LLM_URL: APIS["EMBED"]["URL"],
133
- SpanAttributes.LLM_PATH: APIS["EMBED"]["ENDPOINT"],
133
+ SpanAttributes.LLM_URL: APIS["EMBED" if not v2 else "EMBED_V2"]["URL"],
134
+ SpanAttributes.LLM_PATH: APIS["EMBED" if not v2 else "EMBED_V2"]["ENDPOINT"],
134
135
  SpanAttributes.LLM_REQUEST_EMBEDDING_INPUTS: json.dumps(
135
136
  kwargs.get("texts")
136
137
  ),
@@ -143,7 +144,7 @@ def embed(original_method, version, tracer):
143
144
  attributes = LLMSpanAttributes(**span_attributes)
144
145
 
145
146
  span = tracer.start_span(
146
- name=get_span_name(APIS["EMBED"]["METHOD"]),
147
+ name=get_span_name(APIS["EMBED" if not v2 else "EMBED_V2"]["METHOD"]),
147
148
  kind=SpanKind.CLIENT,
148
149
  )
149
150
  for field, value in attributes.model_dump(by_alias=True).items():
@@ -343,6 +344,103 @@ def chat_create(original_method, version, tracer):
343
344
  return traced_method
344
345
 
345
346
 
347
+ def chat_create_v2(original_method, version, tracer, stream=False):
348
+ """Wrap the `chat_create` method for Cohere API v2."""
349
+
350
+ def traced_method(wrapped, instance, args, kwargs):
351
+ service_provider = SERVICE_PROVIDERS["COHERE"]
352
+
353
+ messages = kwargs.get("messages", [])
354
+ if kwargs.get("preamble"):
355
+ messages = [{"role": "system", "content": kwargs["preamble"]}] + messages
356
+
357
+ span_attributes = {
358
+ **get_langtrace_attributes(version, service_provider),
359
+ **get_llm_request_attributes(kwargs, prompts=messages),
360
+ **get_llm_url(instance),
361
+ SpanAttributes.LLM_REQUEST_MODEL: kwargs.get("model") or "command-r-plus",
362
+ SpanAttributes.LLM_URL: APIS["CHAT_CREATE_V2"]["URL"],
363
+ SpanAttributes.LLM_PATH: APIS["CHAT_CREATE_V2"]["ENDPOINT"],
364
+ **get_extra_attributes(),
365
+ }
366
+
367
+ attributes = LLMSpanAttributes(**span_attributes)
368
+
369
+ for attr_name in ["max_input_tokens", "conversation_id", "connectors", "tools", "tool_results"]:
370
+ value = kwargs.get(attr_name)
371
+ if value is not None:
372
+ if attr_name == "max_input_tokens":
373
+ attributes.llm_max_input_tokens = str(value)
374
+ elif attr_name == "conversation_id":
375
+ attributes.conversation_id = value
376
+ else:
377
+ setattr(attributes, f"llm_{attr_name}", json.dumps(value))
378
+
379
+ span = tracer.start_span(
380
+ name=get_span_name(APIS["CHAT_CREATE_V2"]["METHOD"]),
381
+ kind=SpanKind.CLIENT
382
+ )
383
+
384
+ for field, value in attributes.model_dump(by_alias=True).items():
385
+ set_span_attribute(span, field, value)
386
+
387
+ try:
388
+ result = wrapped(*args, **kwargs)
389
+
390
+ if stream:
391
+ return StreamWrapper(
392
+ result,
393
+ span,
394
+ tool_calls=kwargs.get("tools") is not None,
395
+ )
396
+ else:
397
+ if hasattr(result, "id") and result.id is not None:
398
+ span.set_attribute(SpanAttributes.LLM_GENERATION_ID, result.id)
399
+ span.set_attribute(SpanAttributes.LLM_RESPONSE_ID, result.id)
400
+
401
+ if (hasattr(result, "message") and
402
+ hasattr(result.message, "content") and
403
+ len(result.message.content) > 0 and
404
+ hasattr(result.message.content[0], "text") and
405
+ result.message.content[0].text is not None and
406
+ result.message.content[0].text != ""):
407
+ responses = [{
408
+ "role": result.message.role,
409
+ "content": result.message.content[0].text
410
+ }]
411
+ set_event_completion(span, responses)
412
+ if hasattr(result, "tool_calls") and result.tool_calls is not None:
413
+ tool_calls = [tool_call.json() for tool_call in result.tool_calls]
414
+ span.set_attribute(
415
+ SpanAttributes.LLM_TOOL_RESULTS,
416
+ json.dumps(tool_calls)
417
+ )
418
+ if hasattr(result, "usage") and result.usage is not None:
419
+ if (hasattr(result.usage, "billed_units") and
420
+ result.usage.billed_units is not None):
421
+ usage = result.usage.billed_units
422
+ for metric, value in {
423
+ "input": usage.input_tokens or 0,
424
+ "output": usage.output_tokens or 0,
425
+ "total": (usage.input_tokens or 0) + (usage.output_tokens or 0),
426
+ }.items():
427
+ span.set_attribute(
428
+ f"gen_ai.usage.{metric}_tokens",
429
+ int(value)
430
+ )
431
+ span.set_status(StatusCode.OK)
432
+ span.end()
433
+ return result
434
+
435
+ except Exception as error:
436
+ span.record_exception(error)
437
+ span.set_status(Status(StatusCode.ERROR, str(error)))
438
+ span.end()
439
+ raise
440
+
441
+ return traced_method
442
+
443
+
346
444
  def chat_stream(original_method, version, tracer):
347
445
  """Wrap the `messages_stream` method."""
348
446
 
@@ -50,7 +50,7 @@ def patch_bootstrapfewshot_optimizer(operation_name, version, tracer):
50
50
  ),
51
51
  }
52
52
  span_attributes["dspy.optimizer.module.prog"] = json.dumps(prog)
53
- if hasattr(instance, "metric"):
53
+ if hasattr(instance, "metric") and getattr(instance, "metric") is not None:
54
54
  span_attributes["dspy.optimizer.metric"] = getattr(
55
55
  instance, "metric"
56
56
  ).__name__
@@ -137,7 +137,7 @@ def set_response_attributes(
137
137
  if hasattr(result, "text"):
138
138
  set_event_completion(span, [{"role": "assistant", "content": result.text}])
139
139
 
140
- if hasattr(result, "usage_metadata"):
140
+ if hasattr(result, "usage_metadata") and result.usage_metadata is not None:
141
141
  usage = result.usage_metadata
142
142
  input_tokens = usage.prompt_token_count
143
143
  output_tokens = usage.candidates_token_count
@@ -152,7 +152,7 @@ def build_streaming_response(span, response):
152
152
  item_to_yield = item
153
153
  complete_response += str(item.text)
154
154
  yield item_to_yield
155
- if hasattr(item, "usage_metadata"):
155
+ if hasattr(item, "usage_metadata") and item.usage_metadata is not None:
156
156
  usage = item.usage_metadata
157
157
  input_tokens = usage.prompt_token_count
158
158
  output_tokens = usage.candidates_token_count
@@ -171,7 +171,7 @@ async def abuild_streaming_response(span, response):
171
171
  item_to_yield = item
172
172
  complete_response += str(item.text)
173
173
  yield item_to_yield
174
- if hasattr(item, "usage_metadata"):
174
+ if hasattr(item, "usage_metadata") and item.usage_metadata is not None:
175
175
  usage = item.usage_metadata
176
176
  input_tokens = usage.prompt_token_count
177
177
  output_tokens = usage.candidates_token_count
@@ -98,7 +98,7 @@ def generic_patch(
98
98
  result = wrapped(*args, **kwargs)
99
99
  if trace_output:
100
100
  span.set_attribute("langchain.outputs", to_json_string(result))
101
- if hasattr(result, "usage_metadata"):
101
+ if hasattr(result, "usage_metadata") and result.usage_metadata is not None:
102
102
  span.set_attribute(
103
103
  SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
104
104
  result.usage_metadata["input_tokens"],
@@ -342,8 +342,12 @@ def async_chat_completions_create(version: str, tracer: Tracer) -> Callable:
342
342
  service_provider = SERVICE_PROVIDERS["PPLX"]
343
343
  elif "azure" in get_base_url(instance):
344
344
  service_provider = SERVICE_PROVIDERS["AZURE"]
345
+ elif "groq" in get_base_url(instance):
346
+ service_provider = SERVICE_PROVIDERS["GROQ"]
345
347
  elif "x.ai" in get_base_url(instance):
346
348
  service_provider = SERVICE_PROVIDERS["XAI"]
349
+ elif "deepseek" in get_base_url(instance):
350
+ service_provider = SERVICE_PROVIDERS["DEEPSEEK"]
347
351
  llm_prompts = []
348
352
  for item in kwargs.get("messages", []):
349
353
  tools = get_tool_calls(item)
@@ -431,6 +435,18 @@ def embeddings_create(version: str, tracer: Tracer) -> Callable:
431
435
  kwargs: EmbeddingsCreateKwargs,
432
436
  ) -> Any:
433
437
  service_provider = SERVICE_PROVIDERS["OPENAI"]
438
+ base_url = get_base_url(instance)
439
+
440
+ if "perplexity" in base_url:
441
+ service_provider = SERVICE_PROVIDERS["PPLX"]
442
+ elif "azure" in base_url:
443
+ service_provider = SERVICE_PROVIDERS["AZURE"]
444
+ elif "groq" in base_url:
445
+ service_provider = SERVICE_PROVIDERS["GROQ"]
446
+ elif "x.ai" in base_url:
447
+ service_provider = SERVICE_PROVIDERS["XAI"]
448
+ elif "deepseek" in base_url:
449
+ service_provider = SERVICE_PROVIDERS["DEEPSEEK"]
434
450
 
435
451
  span_attributes = {
436
452
  **get_langtrace_attributes(version, service_provider, vendor_type="llm"),
@@ -469,7 +485,6 @@ def embeddings_create(version: str, tracer: Tracer) -> Callable:
469
485
  kind=SpanKind.CLIENT,
470
486
  context=set_span_in_context(trace.get_current_span()),
471
487
  ) as span:
472
-
473
488
  set_span_attributes(span, attributes)
474
489
  try:
475
490
  # Attempt to call the original method
@@ -507,17 +522,27 @@ def async_embeddings_create(version: str, tracer: Tracer) -> Callable:
507
522
  ) -> Awaitable[Any]:
508
523
 
509
524
  service_provider = SERVICE_PROVIDERS["OPENAI"]
525
+ base_url = get_base_url(instance)
526
+ if "perplexity" in base_url:
527
+ service_provider = SERVICE_PROVIDERS["PPLX"]
528
+ elif "azure" in base_url:
529
+ service_provider = SERVICE_PROVIDERS["AZURE"]
530
+ elif "groq" in base_url:
531
+ service_provider = SERVICE_PROVIDERS["GROQ"]
532
+ elif "x.ai" in base_url:
533
+ service_provider = SERVICE_PROVIDERS["XAI"]
534
+ elif "deepseek" in base_url:
535
+ service_provider = SERVICE_PROVIDERS["DEEPSEEK"]
510
536
 
511
537
  span_attributes = {
512
538
  **get_langtrace_attributes(version, service_provider, vendor_type="llm"),
513
539
  **get_llm_request_attributes(kwargs, operation_name="embed"),
540
+ **get_llm_url(instance),
514
541
  SpanAttributes.LLM_PATH: APIS["EMBEDDINGS_CREATE"]["ENDPOINT"],
515
542
  SpanAttributes.LLM_REQUEST_DIMENSIONS: kwargs.get("dimensions"),
516
543
  **get_extra_attributes(), # type: ignore
517
544
  }
518
545
 
519
- attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
520
-
521
546
  encoding_format = kwargs.get("encoding_format")
522
547
  if encoding_format is not None:
523
548
  if not isinstance(encoding_format, list):
@@ -530,17 +555,31 @@ def async_embeddings_create(version: str, tracer: Tracer) -> Callable:
530
555
  span_attributes[SpanAttributes.LLM_REQUEST_EMBEDDING_INPUTS] = json.dumps(
531
556
  [kwargs.get("input", "")]
532
557
  )
558
+ span_attributes[SpanAttributes.LLM_PROMPTS] = json.dumps(
559
+ [
560
+ {
561
+ "role": "user",
562
+ "content": kwargs.get("input"),
563
+ }
564
+ ]
565
+ )
566
+
567
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
533
568
 
534
569
  with tracer.start_as_current_span(
535
570
  name=get_span_name(APIS["EMBEDDINGS_CREATE"]["METHOD"]),
536
571
  kind=SpanKind.CLIENT,
537
572
  context=set_span_in_context(trace.get_current_span()),
538
573
  ) as span:
539
-
540
574
  set_span_attributes(span, attributes)
541
575
  try:
542
576
  # Attempt to call the original method
543
577
  result = await wrapped(*args, **kwargs)
578
+ usage = getattr(result, "usage", None)
579
+ if usage:
580
+ set_usage_attributes(
581
+ span, {"prompt_tokens": getattr(usage, "prompt_tokens", 0)}
582
+ )
544
583
  span.set_status(StatusCode.OK)
545
584
  return result
546
585
  except Exception as err:
@@ -77,7 +77,7 @@ def set_response_attributes(span: Span, result):
77
77
  if hasattr(result, "text"):
78
78
  set_event_completion(span, [{"role": "assistant", "content": result.text}])
79
79
 
80
- if hasattr(result, "usage_metadata"):
80
+ if hasattr(result, "usage_metadata") and result.usage_metadata is not None:
81
81
  usage = result.usage_metadata
82
82
  input_tokens = usage.prompt_token_count
83
83
  output_tokens = usage.candidates_token_count
@@ -39,6 +39,7 @@ from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
39
39
  )
40
40
  from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
41
41
  LANGTRACE_REMOTE_URL,
42
+ LANGTRACE_SESSION_ID_HEADER,
42
43
  )
43
44
  from langtrace_python_sdk.instrumentation import (
44
45
  AnthropicInstrumentation,
@@ -98,6 +99,7 @@ class LangtraceConfig:
98
99
  or os.environ.get("LANGTRACE_HEADERS")
99
100
  or os.environ.get("OTEL_EXPORTER_OTLP_HEADERS")
100
101
  )
102
+ self.session_id = kwargs.get("session_id") or os.environ.get("LANGTRACE_SESSION_ID")
101
103
 
102
104
 
103
105
  def get_host(config: LangtraceConfig) -> str:
@@ -134,15 +136,19 @@ def setup_tracer_provider(config: LangtraceConfig, host: str) -> TracerProvider:
134
136
 
135
137
 
136
138
  def get_headers(config: LangtraceConfig):
137
- if not config.headers:
138
- return {
139
- "x-api-key": config.api_key,
140
- }
139
+ headers = {
140
+ "x-api-key": config.api_key,
141
+ }
142
+
143
+ if config.session_id:
144
+ headers[LANGTRACE_SESSION_ID_HEADER] = config.session_id
141
145
 
142
146
  if isinstance(config.headers, str):
143
- return parse_env_headers(config.headers, liberal=True)
147
+ headers.update(parse_env_headers(config.headers, liberal=True))
148
+ elif config.headers:
149
+ headers.update(config.headers)
144
150
 
145
- return config.headers
151
+ return headers
146
152
 
147
153
 
148
154
  def get_exporter(config: LangtraceConfig, host: str):
@@ -215,6 +221,7 @@ def init(
215
221
  service_name: Optional[str] = None,
216
222
  disable_logging: bool = False,
217
223
  headers: Dict[str, str] = {},
224
+ session_id: Optional[str] = None,
218
225
  ):
219
226
 
220
227
  check_if_sdk_is_outdated()
@@ -229,6 +236,7 @@ def init(
229
236
  service_name=service_name,
230
237
  disable_logging=disable_logging,
231
238
  headers=headers,
239
+ session_id=session_id,
232
240
  )
233
241
 
234
242
  if config.disable_logging: