langtrace-python-sdk 2.3.15__tar.gz → 2.3.17__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 (244) hide show
  1. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/PKG-INFO +1 -1
  2. langtrace_python_sdk-2.3.17/src/examples/cohere_example/rerank.py +45 -0
  3. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/langchain_example/__init__.py +3 -1
  4. langtrace_python_sdk-2.3.17/src/examples/langchain_example/groq_example.py +121 -0
  5. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +4 -1
  6. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/langtrace.py +25 -63
  7. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/types/__init__.py +14 -5
  8. langtrace_python_sdk-2.3.17/src/langtrace_python_sdk/utils/__init__.py +92 -0
  9. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/llm.py +2 -1
  10. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/misc.py +8 -0
  11. langtrace_python_sdk-2.3.17/src/langtrace_python_sdk/version.py +1 -0
  12. langtrace_python_sdk-2.3.15/src/examples/cohere_example/rerank.py +0 -32
  13. langtrace_python_sdk-2.3.15/src/examples/langchain_example/groq_example.py +0 -45
  14. langtrace_python_sdk-2.3.15/src/langtrace_python_sdk/utils/__init__.py +0 -51
  15. langtrace_python_sdk-2.3.15/src/langtrace_python_sdk/version.py +0 -1
  16. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/.gitignore +0 -0
  17. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/LICENSE +0 -0
  18. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/README.md +0 -0
  19. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/pyproject.toml +0 -0
  20. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/__init__.py +0 -0
  21. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/__init__.py +0 -0
  22. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/anthropic_example/__init__.py +0 -0
  23. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/anthropic_example/completion.py +0 -0
  24. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/autogen_example/__init__.py +0 -0
  25. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/autogen_example/main.py +0 -0
  26. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/azureopenai_example/__init__.py +0 -0
  27. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/azureopenai_example/completion.py +0 -0
  28. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/chroma_example/__init__.py +0 -0
  29. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/chroma_example/basic.py +0 -0
  30. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/cohere_example/__init__.py +0 -0
  31. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/cohere_example/chat.py +0 -0
  32. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/cohere_example/chat_stream.py +0 -0
  33. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/cohere_example/embed.py +0 -0
  34. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/cohere_example/tools.py +0 -0
  35. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/__init__.py +0 -0
  36. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/basic.py +0 -0
  37. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/instagram_post/__init__.py +0 -0
  38. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/instagram_post/agents.py +0 -0
  39. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/instagram_post/main.py +0 -0
  40. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/instagram_post/tasks.py +0 -0
  41. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/instagram_post/tools/__init__.py +0 -0
  42. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/instagram_post/tools/browser_tools.py +0 -0
  43. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/simple_agent/__init__.py +0 -0
  44. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/simple_agent/agents.py +0 -0
  45. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/simple_agent/main.py +0 -0
  46. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/simple_agent/tasks.py +0 -0
  47. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/trip_planner/__init__.py +0 -0
  48. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/trip_planner/agents.py +0 -0
  49. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/trip_planner/main.py +0 -0
  50. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/trip_planner/tasks.py +0 -0
  51. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/trip_planner/tools/calculator.py +0 -0
  52. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/crewai_example/trip_planner/tools/search_tools.py +0 -0
  53. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/dspy_example/math_problems_cot.py +0 -0
  54. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/dspy_example/math_problems_cot_parallel.py +0 -0
  55. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/dspy_example/program_of_thought_basic.py +0 -0
  56. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/dspy_example/quiz_gen.py +0 -0
  57. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/dspy_example/react.py +0 -0
  58. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/embedchain_example/simple.py +0 -0
  59. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/fastapi_example/__init__.py +0 -0
  60. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/fastapi_example/basic_route.py +0 -0
  61. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/gemini_example/__init__.py +0 -0
  62. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/gemini_example/function_tools.py +0 -0
  63. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/gemini_example/main.py +0 -0
  64. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/hiveagent_example/basic.py +0 -0
  65. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/inspect_ai_example/basic_eval.py +0 -0
  66. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/langchain_example/basic.py +0 -0
  67. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/langchain_example/langchain_google_example.py +0 -0
  68. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/langchain_example/langgraph_example.py +0 -0
  69. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/langchain_example/langgraph_example_tools.py +0 -0
  70. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/langchain_example/sagemaker.py +0 -0
  71. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/langchain_example/tool.py +0 -0
  72. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/litellm_example/basic.py +0 -0
  73. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/llamaindex_example/__init__.py +0 -0
  74. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/llamaindex_example/agent.py +0 -0
  75. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/llamaindex_example/basic.py +0 -0
  76. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  77. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/mistral_example/__init__.py +0 -0
  78. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/mistral_example/complete.py +0 -0
  79. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/mistral_example/complete_async.py +0 -0
  80. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/mistral_example/embeddings.py +0 -0
  81. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/ollama_example/__init__.py +0 -0
  82. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/ollama_example/basic.py +0 -0
  83. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/__init__.py +0 -0
  84. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  85. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  86. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/chat_completion.py +0 -0
  87. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/chat_completion_tool_choice.py +0 -0
  88. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/embeddings_create.py +0 -0
  89. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/function_calling.py +0 -0
  90. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/images_edit.py +0 -0
  91. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/images_generate.py +0 -0
  92. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
  93. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/resources/mask.png +0 -0
  94. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/send_user_feedback.py +0 -0
  95. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/tool_calling.py +0 -0
  96. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  97. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  98. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/otlp_example/otlp_basic.py +0 -0
  99. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/otlp_example/otlp_with_langtrace.py +0 -0
  100. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/perplexity_example/basic.py +0 -0
  101. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/pinecone_example/__init__.py +0 -0
  102. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/pinecone_example/basic.py +0 -0
  103. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/qdrant_example/__init__.py +0 -0
  104. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/qdrant_example/basic.py +0 -0
  105. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/routellm_example/basic.py +0 -0
  106. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/vertexai_example/__init__.py +0 -0
  107. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/vertexai_example/main.py +0 -0
  108. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/weaviate_example/__init__.py +0 -0
  109. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/examples/weaviate_example/query_text.py +0 -0
  110. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/__init__.py +0 -0
  111. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  112. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  113. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  114. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  115. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  116. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
  117. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
  118. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/embedchain.py +0 -0
  119. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/gemini.py +0 -0
  120. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  121. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/mistral.py +0 -0
  122. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
  123. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  124. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  125. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  126. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/vertexai.py +0 -0
  127. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
  128. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  129. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
  130. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +0 -0
  131. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  132. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  133. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  134. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  135. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/anthropic/types.py +0 -0
  136. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/autogen/__init__.py +0 -0
  137. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/autogen/instrumentation.py +0 -0
  138. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/autogen/patch.py +0 -0
  139. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  140. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  141. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
  142. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  143. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
  144. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/crewai/__init__.py +0 -0
  145. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/crewai/instrumentation.py +0 -0
  146. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/crewai/patch.py +0 -0
  147. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +0 -0
  148. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +0 -0
  149. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/dspy/patch.py +0 -0
  150. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/embedchain/__init__.py +0 -0
  151. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/embedchain/instrumentation.py +0 -0
  152. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/embedchain/patch.py +0 -0
  153. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/gemini/__init__.py +0 -0
  154. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/gemini/instrumentation.py +0 -0
  155. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/gemini/patch.py +0 -0
  156. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  157. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  158. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
  159. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  160. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  161. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
  162. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  163. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  164. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
  165. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  166. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  167. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
  168. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  169. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  170. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
  171. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  172. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  173. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
  174. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/mistral/__init__.py +0 -0
  175. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/mistral/instrumentation.py +0 -0
  176. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/mistral/patch.py +0 -0
  177. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
  178. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
  179. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +0 -0
  180. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  181. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  182. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
  183. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/openai/types.py +0 -0
  184. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  185. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
  186. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
  187. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  188. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  189. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
  190. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/vertexai/__init__.py +0 -0
  191. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/vertexai/instrumentation.py +0 -0
  192. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/vertexai/patch.py +0 -0
  193. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
  194. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
  195. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
  196. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
  197. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
  198. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
  199. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
  200. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/types.py +0 -0
  201. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
  202. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/run_example.py +0 -0
  203. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/__init__.py +0 -0
  204. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  205. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  206. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  207. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/anthropic/conftest.py +0 -0
  208. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/anthropic/test_anthropic.py +0 -0
  209. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/chroma/conftest.py +0 -0
  210. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/chroma/test_chroma.py +0 -0
  211. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  212. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  213. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  214. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  215. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/conftest.py +0 -0
  216. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/test_cohere_chat.py +0 -0
  217. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/test_cohere_embed.py +0 -0
  218. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/cohere/test_cohere_rerank.py +0 -0
  219. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/conftest.py +0 -0
  220. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/groq/cassettes/test_async_chat_completion.yaml +0 -0
  221. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/groq/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  222. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/groq/cassettes/test_chat_completion.yaml +0 -0
  223. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/groq/cassettes/test_chat_completion_streaming.yaml +0 -0
  224. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/groq/conftest.py +0 -0
  225. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/groq/test_groq.py +0 -0
  226. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
  227. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/langchain/conftest.py +0 -0
  228. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/langchain/test_langchain.py +0 -0
  229. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  230. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  231. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  232. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  233. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  234. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/conftest.py +0 -0
  235. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/test_chat_completion.py +0 -0
  236. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/test_embeddings.py +0 -0
  237. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/openai/test_image_generation.py +0 -0
  238. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
  239. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
  240. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/pinecone/conftest.py +0 -0
  241. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/pinecone/test_pinecone.py +0 -0
  242. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/qdrant/conftest.py +0 -0
  243. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/src/tests/qdrant/test_qdrant.py +0 -0
  244. {langtrace_python_sdk-2.3.15 → langtrace_python_sdk-2.3.17}/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.3.15
3
+ Version: 2.3.17
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,45 @@
1
+ import cohere
2
+ from dotenv import find_dotenv, load_dotenv
3
+ from datetime import datetime
4
+
5
+ from langtrace_python_sdk import langtrace
6
+
7
+ # from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
8
+
9
+ _ = load_dotenv(find_dotenv())
10
+
11
+ langtrace.init()
12
+
13
+
14
+ co = cohere.Client()
15
+
16
+
17
+ # @with_langtrace_root_span("embed_create")
18
+ def rerank():
19
+ docs = [
20
+ {
21
+ "text": "Carson City is the capital city of the American state of Nevada.",
22
+ "date": datetime.now(),
23
+ },
24
+ {
25
+ "text": "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
26
+ "date": datetime(2020, 5, 17),
27
+ },
28
+ {
29
+ "text": "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.",
30
+ "date": datetime(1776, 7, 4),
31
+ },
32
+ {
33
+ "text": "Capital punishment (the death penalty) has existed in the United States since before the United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.",
34
+ "date": datetime(2023, 9, 14),
35
+ },
36
+ ]
37
+
38
+ response = co.rerank(
39
+ model="rerank-english-v2.0",
40
+ query="What is the capital of the United States?",
41
+ documents=docs,
42
+ top_n=3,
43
+ )
44
+ print(response)
45
+ return response
@@ -2,7 +2,7 @@ from examples.langchain_example.langchain_google_genai import basic_google_genai
2
2
  from .basic import basic_app, rag, load_and_split
3
3
  from langtrace_python_sdk import with_langtrace_root_span
4
4
 
5
- from .groq_example import groq_basic, groq_streaming
5
+ from .groq_example import groq_basic, groq_tool_choice, groq_streaming
6
6
  from .langgraph_example_tools import basic_graph_tools
7
7
 
8
8
 
@@ -20,3 +20,5 @@ class GroqRunner:
20
20
  @with_langtrace_root_span("Groq")
21
21
  def run(self):
22
22
  groq_streaming()
23
+ groq_basic()
24
+ groq_tool_choice()
@@ -0,0 +1,121 @@
1
+ import json
2
+
3
+ from dotenv import find_dotenv, load_dotenv
4
+ from groq import Groq
5
+
6
+ _ = load_dotenv(find_dotenv())
7
+
8
+ from langtrace_python_sdk import langtrace
9
+
10
+ # from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
11
+
12
+ _ = load_dotenv(find_dotenv())
13
+
14
+ langtrace.init()
15
+
16
+ client = Groq()
17
+
18
+
19
+ def groq_basic():
20
+ chat_completion = client.chat.completions.create(
21
+ messages=[
22
+ {
23
+ "role": "user",
24
+ "content": "Explain the importance of low latency LLMs",
25
+ }
26
+ ],
27
+ stream=False,
28
+ model="llama3-8b-8192",
29
+ )
30
+ return chat_completion
31
+
32
+
33
+ def groq_tool_choice():
34
+
35
+ user_prompt = "What is 25 * 4 + 10?"
36
+ MODEL = "llama3-groq-70b-8192-tool-use-preview"
37
+
38
+ def calculate(expression):
39
+ """Evaluate a mathematical expression"""
40
+ try:
41
+ result = eval(expression)
42
+ return json.dumps({"result": result})
43
+ except:
44
+ return json.dumps({"error": "Invalid expression"})
45
+
46
+ messages = [
47
+ {
48
+ "role": "system",
49
+ "content": "You are a calculator assistant. Use the calculate function to perform mathematical operations and provide the results.",
50
+ },
51
+ {
52
+ "role": "user",
53
+ "content": user_prompt,
54
+ },
55
+ ]
56
+ tools = [
57
+ {
58
+ "type": "function",
59
+ "function": {
60
+ "name": "calculate",
61
+ "description": "Evaluate a mathematical expression",
62
+ "parameters": {
63
+ "type": "object",
64
+ "properties": {
65
+ "expression": {
66
+ "type": "string",
67
+ "description": "The mathematical expression to evaluate",
68
+ }
69
+ },
70
+ "required": ["expression"],
71
+ },
72
+ },
73
+ }
74
+ ]
75
+ response = client.chat.completions.create(
76
+ model=MODEL,
77
+ messages=messages,
78
+ tools=tools,
79
+ tool_choice={"type": "function", "function": {"name": "calculate"}},
80
+ max_tokens=4096,
81
+ )
82
+
83
+ response_message = response.choices[0].message
84
+ tool_calls = response_message.tool_calls
85
+ if tool_calls:
86
+ available_functions = {
87
+ "calculate": calculate,
88
+ }
89
+ messages.append(response_message)
90
+ for tool_call in tool_calls:
91
+ function_name = tool_call.function.name
92
+ function_to_call = available_functions[function_name]
93
+ function_args = json.loads(tool_call.function.arguments)
94
+ function_response = function_to_call(
95
+ expression=function_args.get("expression")
96
+ )
97
+ messages.append(
98
+ {
99
+ "tool_call_id": tool_call.id,
100
+ "role": "tool",
101
+ "name": function_name,
102
+ "content": function_response,
103
+ }
104
+ )
105
+ second_response = client.chat.completions.create(model=MODEL, messages=messages)
106
+ return second_response.choices[0].message.content
107
+
108
+
109
+ def groq_streaming():
110
+ chat_completion = client.chat.completions.create(
111
+ messages=[
112
+ {
113
+ "role": "user",
114
+ "content": "Explain the importance of low latency LLMs",
115
+ }
116
+ ],
117
+ stream=True,
118
+ model="llama3-8b-8192",
119
+ )
120
+ for chunk in chat_completion:
121
+ print(chunk)
@@ -27,6 +27,7 @@ from langtrace_python_sdk.utils.llm import (
27
27
  )
28
28
  from langtrace.trace_attributes import Event, LLMSpanAttributes
29
29
  from langtrace_python_sdk.utils import set_span_attribute
30
+ from langtrace_python_sdk.utils.misc import datetime_encoder
30
31
  from opentelemetry.trace import SpanKind
31
32
  from opentelemetry.trace.status import Status, StatusCode
32
33
 
@@ -50,7 +51,9 @@ def rerank(original_method, version, tracer):
50
51
  SpanAttributes.LLM_REQUEST_MODEL: kwargs.get("model") or "command-r-plus",
51
52
  SpanAttributes.LLM_URL: APIS["RERANK"]["URL"],
52
53
  SpanAttributes.LLM_PATH: APIS["RERANK"]["ENDPOINT"],
53
- SpanAttributes.LLM_REQUEST_DOCUMENTS: json.dumps(kwargs.get("documents")),
54
+ SpanAttributes.LLM_REQUEST_DOCUMENTS: json.dumps(
55
+ kwargs.get("documents"), cls=datetime_encoder
56
+ ),
54
57
  SpanAttributes.LLM_COHERE_RERANK_QUERY: kwargs.get("query"),
55
58
  **get_extra_attributes(),
56
59
  }
@@ -16,8 +16,7 @@ limitations under the License.
16
16
 
17
17
  import os
18
18
  import sys
19
- from typing import Optional
20
- import importlib.util
19
+ from typing import Any, Optional
21
20
  from colorama import Fore
22
21
  from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME, SENTRY_DSN
23
22
  from opentelemetry import trace
@@ -62,7 +61,12 @@ from langtrace_python_sdk.types import (
62
61
  InstrumentationMethods,
63
62
  InstrumentationType,
64
63
  )
65
- from langtrace_python_sdk.utils import check_if_sdk_is_outdated, get_sdk_version
64
+ from langtrace_python_sdk.utils import (
65
+ check_if_sdk_is_outdated,
66
+ get_sdk_version,
67
+ is_package_installed,
68
+ validate_instrumentations,
69
+ )
66
70
  from langtrace_python_sdk.utils.langtrace_sampler import LangtraceSampler
67
71
  import sentry_sdk
68
72
 
@@ -193,10 +197,10 @@ def init(
193
197
 
194
198
  def init_instrumentations(
195
199
  disable_instrumentations: Optional[DisableInstrumentations],
196
- all_instrumentations: dict
200
+ all_instrumentations: dict,
197
201
  ):
198
202
  if disable_instrumentations is None:
199
- for idx, (name, v) in enumerate(all_instrumentations.items()):
203
+ for name, v in all_instrumentations.items():
200
204
  if is_package_installed(name):
201
205
  v.instrument()
202
206
 
@@ -205,61 +209,19 @@ def init_instrumentations(
205
209
  validate_instrumentations(disable_instrumentations)
206
210
 
207
211
  for key in disable_instrumentations:
208
- for vendor in disable_instrumentations[key]:
209
- if key == "only":
210
- filtered_dict = {
211
- k: v
212
- for k, v in all_instrumentations.items()
213
- if k != vendor.value
214
- }
215
- for _, v in filtered_dict.items():
216
- v.instrument()
217
- else:
218
- filtered_dict = {
219
- k: v
220
- for k, v in all_instrumentations.items()
221
- if k == vendor.value
222
- }
223
-
224
- for _, v in filtered_dict.items():
225
- v.instrument()
226
-
227
-
228
- def validate_instrumentations(disable_instrumentations):
229
- if disable_instrumentations is not None:
230
- for key, value in disable_instrumentations.items():
231
- if isinstance(value, str):
232
- # Convert single string to list of enum values
233
- disable_instrumentations[key] = [InstrumentationType.from_string(value)]
234
- elif isinstance(value, list):
235
- # Convert list of strings to list of enum values
236
- disable_instrumentations[key] = [
237
- (
238
- InstrumentationType.from_string(item)
239
- if isinstance(item, str)
240
- else item
241
- )
242
- for item in value
243
- ]
244
- # Validate all items are of enum type
245
- if not all(
246
- isinstance(item, InstrumentationType)
247
- for item in disable_instrumentations[key]
248
- ):
249
- raise TypeError(
250
- f"All items in {key} must be of type InstrumentationType"
251
- )
252
- if (
253
- disable_instrumentations.get("all_except") is not None
254
- and disable_instrumentations.get("only") is not None
255
- ):
256
- raise ValueError(
257
- "Cannot specify both only and all_except in disable_instrumentations"
258
- )
259
-
260
-
261
- def is_package_installed(package_name):
262
- import pkg_resources
263
-
264
- installed_packages = {p.key for p in pkg_resources.working_set}
265
- return package_name in installed_packages
212
+ vendors = [k.value for k in disable_instrumentations[key]]
213
+
214
+ key = next(iter(disable_instrumentations))
215
+ filtered_dict = {}
216
+ if key == "all_except":
217
+ filtered_dict = {
218
+ k: v for k, v in all_instrumentations.items() if k in vendors
219
+ }
220
+ elif key == "only":
221
+ filtered_dict = {
222
+ k: v for k, v in all_instrumentations.items() if k not in vendors
223
+ }
224
+
225
+ for name, v in filtered_dict.items():
226
+ if is_package_installed(name):
227
+ v.instrument()
@@ -8,16 +8,22 @@ class InstrumentationType(Enum):
8
8
  ANTHROPIC = "anthropic"
9
9
  GROQ = "groq"
10
10
  MISTRAL = "mistral"
11
- PINECONE = "pinecone"
12
- LLAMAINDEX = "llamaindex"
11
+ PINECONE = "pinecone-client"
12
+ LLAMAINDEX = "llama-index"
13
13
  CHROMADB = "chromadb"
14
14
  QDRANT = "qdrant"
15
15
  LANGCHAIN = "langchain"
16
- LANGCHAIN_CORE = "langchain_core"
17
- LANGCHAIN_COMMUNITY = "langchain_community"
16
+ LANGCHAIN_CORE = "langchain-core"
17
+ LANGCHAIN_COMMUNITY = "langchain-community"
18
18
  LANGGRAPH = "langgraph"
19
19
  WEAVIATE = "weaviate"
20
20
  OLLAMA = "ollama"
21
+ AUTOGEN = "autogen"
22
+ DSPY = "dspy-ai"
23
+ CREWAI = "crewai"
24
+ GEMINI = "google-generativeai"
25
+ VERTEXAI = "google-cloud-aiplatform"
26
+ MISTRALAI = "mistralai"
21
27
 
22
28
  @staticmethod
23
29
  def from_string(value: str):
@@ -112,7 +118,10 @@ class InstrumentationMethods(TypedDict):
112
118
  cohere: List[VendorMethods.CohereMethods]
113
119
  weaviate: List[str]
114
120
 
121
+
115
122
  _T = TypeVar("_T")
123
+
124
+
116
125
  class NotGiven:
117
126
  """
118
127
  A sentinel singleton class used to distinguish omitted keyword arguments
@@ -139,4 +148,4 @@ class NotGiven:
139
148
 
140
149
 
141
150
  NotGivenOr = Union[_T, NotGiven]
142
- NOT_GIVEN = NotGiven()
151
+ NOT_GIVEN = NotGiven()
@@ -0,0 +1,92 @@
1
+ from langtrace_python_sdk.types import NOT_GIVEN, InstrumentationType
2
+ from .sdk_version_checker import SDKVersionChecker
3
+ from opentelemetry.trace import Span
4
+ from langtrace.trace_attributes import SpanAttributes
5
+ import inspect
6
+ import os
7
+
8
+
9
+ def set_span_attribute(span: Span, name, value):
10
+ if value is not None:
11
+ if value != "" or value != NOT_GIVEN:
12
+ if name == SpanAttributes.LLM_PROMPTS:
13
+ set_event_prompt(span, value)
14
+ else:
15
+ span.set_attribute(name, value)
16
+ return
17
+
18
+
19
+ def set_event_prompt(span: Span, prompt):
20
+ enabled = os.environ.get("TRACE_PROMPT_COMPLETION_DATA", "true")
21
+ if enabled.lower() == "false":
22
+ return
23
+
24
+ span.add_event(
25
+ name=SpanAttributes.LLM_CONTENT_PROMPT,
26
+ attributes={
27
+ SpanAttributes.LLM_PROMPTS: prompt,
28
+ },
29
+ )
30
+
31
+
32
+ def deduce_args_and_kwargs(func, *args, **kwargs):
33
+ sig = inspect.signature(func)
34
+ bound_args = sig.bind(*args, **kwargs)
35
+ bound_args.apply_defaults()
36
+
37
+ all_params = {}
38
+ for param_name, param in sig.parameters.items():
39
+ if param_name in bound_args.arguments:
40
+ all_params[param_name] = bound_args.arguments[param_name]
41
+
42
+ return all_params
43
+
44
+
45
+ def check_if_sdk_is_outdated():
46
+ SDKVersionChecker().check()
47
+ return
48
+
49
+
50
+ def get_sdk_version():
51
+ return SDKVersionChecker().get_sdk_version()
52
+
53
+
54
+ def validate_instrumentations(disable_instrumentations):
55
+ if disable_instrumentations is not None:
56
+ if (
57
+ disable_instrumentations.get("all_except") is not None
58
+ and disable_instrumentations.get("only") is not None
59
+ ):
60
+ raise ValueError(
61
+ "Cannot specify both only and all_except in disable_instrumentations"
62
+ )
63
+
64
+ for key, value in disable_instrumentations.items():
65
+ if isinstance(value, str):
66
+ # Convert single string to list of enum values
67
+ disable_instrumentations[key] = [InstrumentationType.from_string(value)]
68
+ elif isinstance(value, list):
69
+ # Convert list of strings to list of enum values
70
+ disable_instrumentations[key] = [
71
+ (
72
+ InstrumentationType.from_string(item)
73
+ if isinstance(item, str)
74
+ else item
75
+ )
76
+ for item in value
77
+ ]
78
+ # Validate all items are of enum type
79
+ if not all(
80
+ isinstance(item, InstrumentationType)
81
+ for item in disable_instrumentations[key]
82
+ ):
83
+ raise TypeError(
84
+ f"All items in {key} must be of type InstrumentationType"
85
+ )
86
+
87
+
88
+ def is_package_installed(package_name):
89
+ import pkg_resources
90
+
91
+ installed_packages = {p.key for p in pkg_resources.working_set}
92
+ return package_name in installed_packages
@@ -124,6 +124,7 @@ def get_llm_request_attributes(kwargs, prompts=None, model=None, operation_name=
124
124
 
125
125
  top_p = kwargs.get("p", None) or kwargs.get("top_p", None)
126
126
  tools = kwargs.get("tools", None)
127
+ tool_choice = kwargs.get("tool_choice", None)
127
128
  return {
128
129
  SpanAttributes.LLM_OPERATION_NAME: operation_name,
129
130
  SpanAttributes.LLM_REQUEST_MODEL: model
@@ -141,7 +142,7 @@ def get_llm_request_attributes(kwargs, prompts=None, model=None, operation_name=
141
142
  SpanAttributes.LLM_FREQUENCY_PENALTY: kwargs.get("frequency_penalty"),
142
143
  SpanAttributes.LLM_REQUEST_SEED: kwargs.get("seed"),
143
144
  SpanAttributes.LLM_TOOLS: json.dumps(tools) if tools else None,
144
- SpanAttributes.LLM_TOOL_CHOICE: kwargs.get("tool_choice"),
145
+ SpanAttributes.LLM_TOOL_CHOICE: json.dumps(tool_choice) if tool_choice else None,
145
146
  SpanAttributes.LLM_REQUEST_LOGPROPS: kwargs.get("logprobs"),
146
147
  SpanAttributes.LLM_REQUEST_LOGITBIAS: kwargs.get("logit_bias"),
147
148
  SpanAttributes.LLM_REQUEST_TOP_LOGPROPS: kwargs.get("top_logprobs"),
@@ -60,3 +60,11 @@ def serialize_args(*args):
60
60
 
61
61
  # Convert to string representation
62
62
  return json.dumps(serializable_args)
63
+
64
+
65
+ class datetime_encoder(json.JSONEncoder):
66
+ def default(self, o):
67
+ if isinstance(o, datetime):
68
+ return o.isoformat()
69
+
70
+ return json.JSONEncoder.default(self, o)
@@ -0,0 +1 @@
1
+ __version__ = "2.3.17"
@@ -1,32 +0,0 @@
1
- import cohere
2
- from dotenv import find_dotenv, load_dotenv
3
-
4
- from langtrace_python_sdk import langtrace
5
-
6
- # from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
7
-
8
- _ = load_dotenv(find_dotenv())
9
-
10
- langtrace.init()
11
-
12
-
13
- co = cohere.Client()
14
-
15
-
16
- # @with_langtrace_root_span("embed_create")
17
- def rerank():
18
- docs = [
19
- "Carson City is the capital city of the American state of Nevada.",
20
- "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
21
- "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.",
22
- "Capital punishment (the death penalty) 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.",
23
- ]
24
-
25
- response = co.rerank(
26
- model="rerank-english-v2.0",
27
- query="What is the capital of the United States?",
28
- documents=docs,
29
- top_n=3,
30
- )
31
- print(response)
32
- return response
@@ -1,45 +0,0 @@
1
- from dotenv import find_dotenv, load_dotenv
2
- from langchain_core.prompts import ChatPromptTemplate
3
- from langchain_groq import ChatGroq
4
- from groq import Groq
5
-
6
- _ = load_dotenv(find_dotenv())
7
-
8
- from langtrace_python_sdk import langtrace
9
-
10
- # from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
11
-
12
- _ = load_dotenv(find_dotenv())
13
-
14
- langtrace.init()
15
-
16
- client = Groq()
17
-
18
-
19
- def groq_basic():
20
- chat_completion = client.chat.completions.create(
21
- messages=[
22
- {
23
- "role": "user",
24
- "content": "Explain the importance of low latency LLMs",
25
- }
26
- ],
27
- stream=False,
28
- model="llama3-8b-8192",
29
- )
30
- return chat_completion
31
-
32
-
33
- def groq_streaming():
34
- chat_completion = client.chat.completions.create(
35
- messages=[
36
- {
37
- "role": "user",
38
- "content": "Explain the importance of low latency LLMs",
39
- }
40
- ],
41
- stream=True,
42
- model="llama3-8b-8192",
43
- )
44
- for chunk in chat_completion:
45
- print(chunk)
@@ -1,51 +0,0 @@
1
- from langtrace_python_sdk.types import NOT_GIVEN
2
- from .sdk_version_checker import SDKVersionChecker
3
- from opentelemetry.trace import Span
4
- from langtrace.trace_attributes import SpanAttributes
5
- import inspect
6
- import os
7
-
8
-
9
- def set_span_attribute(span: Span, name, value):
10
- if value is not None:
11
- if value != "" or value != NOT_GIVEN:
12
- if name == SpanAttributes.LLM_PROMPTS:
13
- set_event_prompt(span, value)
14
- else:
15
- span.set_attribute(name, value)
16
- return
17
-
18
-
19
- def set_event_prompt(span: Span, prompt):
20
- enabled = os.environ.get("TRACE_PROMPT_COMPLETION_DATA", "true")
21
- if enabled.lower() == "false":
22
- return
23
-
24
- span.add_event(
25
- name=SpanAttributes.LLM_CONTENT_PROMPT,
26
- attributes={
27
- SpanAttributes.LLM_PROMPTS: prompt,
28
- },
29
- )
30
-
31
-
32
- def deduce_args_and_kwargs(func, *args, **kwargs):
33
- sig = inspect.signature(func)
34
- bound_args = sig.bind(*args, **kwargs)
35
- bound_args.apply_defaults()
36
-
37
- all_params = {}
38
- for param_name, param in sig.parameters.items():
39
- if param_name in bound_args.arguments:
40
- all_params[param_name] = bound_args.arguments[param_name]
41
-
42
- return all_params
43
-
44
-
45
- def check_if_sdk_is_outdated():
46
- SDKVersionChecker().check()
47
- return
48
-
49
-
50
- def get_sdk_version():
51
- return SDKVersionChecker().get_sdk_version()
@@ -1 +0,0 @@
1
- __version__ = "2.3.15"