langtrace-python-sdk 3.3.20__tar.gz → 3.3.22__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/PKG-INFO +1 -1
  2. langtrace_python_sdk-3.3.22/src/examples/awsbedrock_examples/__init__.py +19 -0
  3. langtrace_python_sdk-3.3.22/src/examples/awsbedrock_examples/converse.py +174 -0
  4. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/aws_bedrock.py +4 -0
  5. langtrace_python_sdk-3.3.22/src/langtrace_python_sdk/instrumentation/aws_bedrock/bedrock_streaming_wrapper.py +43 -0
  6. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/aws_bedrock/instrumentation.py +8 -19
  7. langtrace_python_sdk-3.3.22/src/langtrace_python_sdk/instrumentation/aws_bedrock/patch.py +396 -0
  8. langtrace_python_sdk-3.3.22/src/langtrace_python_sdk/instrumentation/aws_bedrock/stream_body_wrapper.py +41 -0
  9. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +4 -2
  10. langtrace_python_sdk-3.3.22/src/langtrace_python_sdk/version.py +1 -0
  11. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/run_example.py +2 -2
  12. langtrace_python_sdk-3.3.20/src/examples/awsbedrock_examples/__init__.py +0 -10
  13. langtrace_python_sdk-3.3.20/src/examples/awsbedrock_examples/converse.py +0 -34
  14. langtrace_python_sdk-3.3.20/src/langtrace_python_sdk/instrumentation/aws_bedrock/patch.py +0 -157
  15. langtrace_python_sdk-3.3.20/src/langtrace_python_sdk/version.py +0 -1
  16. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/.gitignore +0 -0
  17. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/LICENSE +0 -0
  18. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/README.md +0 -0
  19. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/pyproject.toml +0 -0
  20. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/__init__.py +0 -0
  21. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/__init__.py +0 -0
  22. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/anthropic_example/__init__.py +0 -0
  23. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/anthropic_example/completion.py +0 -0
  24. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/autogen_example/__init__.py +0 -0
  25. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/autogen_example/main.py +0 -0
  26. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/azureopenai_example/__init__.py +0 -0
  27. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/azureopenai_example/completion.py +0 -0
  28. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cerebras_example/__init__.py +0 -0
  29. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cerebras_example/main.py +0 -0
  30. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/chroma_example/__init__.py +0 -0
  31. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/chroma_example/basic.py +0 -0
  32. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/__init__.py +0 -0
  33. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/chat.py +0 -0
  34. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/chat_stream.py +0 -0
  35. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/chat_streamv2.py +0 -0
  36. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/chatv2.py +0 -0
  37. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/embed.py +0 -0
  38. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/rerank.py +0 -0
  39. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/rerankv2.py +0 -0
  40. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/cohere_example/tools.py +0 -0
  41. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/__init__.py +0 -0
  42. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/basic.py +0 -0
  43. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/instagram_post/__init__.py +0 -0
  44. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/instagram_post/agents.py +0 -0
  45. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/instagram_post/main.py +0 -0
  46. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/instagram_post/tasks.py +0 -0
  47. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/instagram_post/tools/__init__.py +0 -0
  48. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/instagram_post/tools/browser_tools.py +0 -0
  49. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/simple_agent/__init__.py +0 -0
  50. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/simple_agent/agents.py +0 -0
  51. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/simple_agent/main.py +0 -0
  52. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/simple_agent/tasks.py +0 -0
  53. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/trip_planner/__init__.py +0 -0
  54. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/trip_planner/agents.py +0 -0
  55. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/trip_planner/main.py +0 -0
  56. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/trip_planner/tasks.py +0 -0
  57. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/trip_planner/tools/calculator.py +0 -0
  58. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/crewai_example/trip_planner/tools/search_tools.py +0 -0
  59. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/QA_basic.py +0 -0
  60. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/QA_basic_with_chain_of_thought.py +0 -0
  61. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/QA_basic_with_signature.py +0 -0
  62. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py +0 -0
  63. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/math_problems_cot.py +0 -0
  64. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/math_problems_cot_parallel.py +0 -0
  65. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/optimizers/bootstrap_fewshot.py +0 -0
  66. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/program_of_thought_basic.py +0 -0
  67. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/quiz_gen.py +0 -0
  68. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/dspy_example/react.py +0 -0
  69. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/embedchain_example/simple.py +0 -0
  70. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/fastapi_example/__init__.py +0 -0
  71. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/fastapi_example/basic_route.py +0 -0
  72. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/gemini_example/__init__.py +0 -0
  73. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/gemini_example/function_tools.py +0 -0
  74. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/gemini_example/main.py +0 -0
  75. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/hiveagent_example/basic.py +0 -0
  76. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/inspect_ai_example/basic_eval.py +0 -0
  77. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/__init__.py +0 -0
  78. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/basic.py +0 -0
  79. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/groq_example.py +0 -0
  80. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/langchain_google_example.py +0 -0
  81. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/langgraph_example.py +0 -0
  82. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/langgraph_example_tools.py +0 -0
  83. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/sagemaker.py +0 -0
  84. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langchain_example/tool.py +0 -0
  85. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/langgraph_example/main.py +0 -0
  86. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/litellm_example/basic.py +0 -0
  87. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/litellm_example/config.yaml +0 -0
  88. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/litellm_example/proxy_basic.py +0 -0
  89. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/llamaindex_example/__init__.py +0 -0
  90. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/llamaindex_example/agent.py +0 -0
  91. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/llamaindex_example/basic.py +0 -0
  92. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  93. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/milvus_example/main.py +0 -0
  94. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/mistral_example/__init__.py +0 -0
  95. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/mistral_example/complete.py +0 -0
  96. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/mistral_example/complete_async.py +0 -0
  97. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/mistral_example/embeddings.py +0 -0
  98. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/mongo_vector_search_example/main.py +0 -0
  99. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/ollama_example/__init__.py +0 -0
  100. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/ollama_example/basic.py +0 -0
  101. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/__init__.py +0 -0
  102. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
  103. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
  104. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/chat_completion.py +0 -0
  105. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/chat_completion_tool_choice.py +0 -0
  106. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/embeddings_create.py +0 -0
  107. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/function_calling.py +0 -0
  108. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/images_edit.py +0 -0
  109. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/images_generate.py +0 -0
  110. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
  111. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/resources/mask.png +0 -0
  112. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/send_user_feedback.py +0 -0
  113. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/tool_calling.py +0 -0
  114. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
  115. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/openai_example/tool_calling_streaming.py +0 -0
  116. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/otlp_example/otlp_basic.py +0 -0
  117. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/otlp_example/otlp_with_langtrace.py +0 -0
  118. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/perplexity_example/basic.py +0 -0
  119. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/pinecone_example/__init__.py +0 -0
  120. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/pinecone_example/basic.py +0 -0
  121. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/qdrant_example/__init__.py +0 -0
  122. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/qdrant_example/basic.py +0 -0
  123. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/routellm_example/basic.py +0 -0
  124. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/vertexai_example/__init__.py +0 -0
  125. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/vertexai_example/main.py +0 -0
  126. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/weaviate_example/__init__.py +0 -0
  127. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/examples/weaviate_example/query_text.py +0 -0
  128. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/__init__.py +0 -0
  129. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  130. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  131. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  132. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  133. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  134. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
  135. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
  136. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/embedchain.py +0 -0
  137. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/gemini.py +0 -0
  138. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
  139. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/litellm.py +0 -0
  140. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/milvus.py +0 -0
  141. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/mistral.py +0 -0
  142. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
  143. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  144. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  145. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/pymongo.py +0 -0
  146. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
  147. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/vertexai.py +0 -0
  148. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
  149. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  150. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
  151. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +0 -0
  152. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  153. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  154. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  155. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  156. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/anthropic/types.py +0 -0
  157. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/autogen/__init__.py +0 -0
  158. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/autogen/instrumentation.py +0 -0
  159. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/autogen/patch.py +0 -0
  160. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/aws_bedrock/__init__.py +0 -0
  161. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/cerebras/__init__.py +0 -0
  162. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/cerebras/instrumentation.py +0 -0
  163. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/cerebras/patch.py +0 -0
  164. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  165. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  166. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
  167. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
  168. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
  169. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +0 -0
  170. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/crewai/__init__.py +0 -0
  171. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/crewai/instrumentation.py +0 -0
  172. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/crewai/patch.py +0 -0
  173. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +0 -0
  174. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +0 -0
  175. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/dspy/patch.py +0 -0
  176. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/embedchain/__init__.py +0 -0
  177. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/embedchain/instrumentation.py +0 -0
  178. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/embedchain/patch.py +0 -0
  179. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/gemini/__init__.py +0 -0
  180. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/gemini/instrumentation.py +0 -0
  181. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/gemini/patch.py +0 -0
  182. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
  183. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
  184. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
  185. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  186. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  187. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
  188. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  189. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  190. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
  191. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  192. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  193. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
  194. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
  195. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
  196. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
  197. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/litellm/__init__.py +0 -0
  198. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/litellm/instrumentation.py +0 -0
  199. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/litellm/patch.py +0 -0
  200. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/litellm/types.py +0 -0
  201. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  202. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  203. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
  204. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/milvus/__init__.py +0 -0
  205. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/milvus/instrumentation.py +0 -0
  206. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/milvus/patch.py +0 -0
  207. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/mistral/__init__.py +0 -0
  208. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/mistral/instrumentation.py +0 -0
  209. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/mistral/patch.py +0 -0
  210. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
  211. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
  212. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +0 -0
  213. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  214. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  215. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
  216. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/openai/types.py +0 -0
  217. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  218. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
  219. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
  220. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/pymongo/__init__.py +0 -0
  221. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/pymongo/instrumentation.py +0 -0
  222. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/pymongo/patch.py +0 -0
  223. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
  224. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
  225. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
  226. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/vertexai/__init__.py +0 -0
  227. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/vertexai/instrumentation.py +0 -0
  228. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/vertexai/patch.py +0 -0
  229. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
  230. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
  231. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/langtrace.py +0 -0
  232. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/types/__init__.py +0 -0
  233. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/__init__.py +0 -0
  234. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
  235. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/llm.py +0 -0
  236. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/misc.py +0 -0
  237. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
  238. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
  239. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
  240. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/types.py +0 -0
  241. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
  242. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/__init__.py +0 -0
  243. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
  244. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
  245. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
  246. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/anthropic/conftest.py +0 -0
  247. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/anthropic/test_anthropic.py +0 -0
  248. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/chroma/conftest.py +0 -0
  249. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/chroma/test_chroma.py +0 -0
  250. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
  251. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
  252. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
  253. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
  254. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/conftest.py +0 -0
  255. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/test_cohere_chat.py +0 -0
  256. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/test_cohere_embed.py +0 -0
  257. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/cohere/test_cohere_rerank.py +0 -0
  258. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/conftest.py +0 -0
  259. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/groq/cassettes/test_async_chat_completion.yaml +0 -0
  260. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/groq/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  261. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/groq/cassettes/test_chat_completion.yaml +0 -0
  262. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/groq/cassettes/test_chat_completion_streaming.yaml +0 -0
  263. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/groq/conftest.py +0 -0
  264. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/groq/test_groq.py +0 -0
  265. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
  266. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/langchain/conftest.py +0 -0
  267. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/langchain/test_langchain.py +0 -0
  268. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
  269. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
  270. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
  271. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
  272. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/cassettes/test_embeddings_base_url.yaml +0 -0
  273. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
  274. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/conftest.py +0 -0
  275. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/test_chat_completion.py +0 -0
  276. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/test_embeddings.py +0 -0
  277. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/openai/test_image_generation.py +0 -0
  278. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
  279. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
  280. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/pinecone/conftest.py +0 -0
  281. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/pinecone/test_pinecone.py +0 -0
  282. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/qdrant/conftest.py +0 -0
  283. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/qdrant/test_qdrant.py +0 -0
  284. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/test_session_id.py +0 -0
  285. {langtrace_python_sdk-3.3.20 → langtrace_python_sdk-3.3.22}/src/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langtrace-python-sdk
3
- Version: 3.3.20
3
+ Version: 3.3.22
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,19 @@
1
+ from examples.awsbedrock_examples.converse import (
2
+ use_converse_stream,
3
+ use_converse,
4
+ use_invoke_model_anthropic,
5
+ use_invoke_model_cohere,
6
+ use_invoke_model_amazon,
7
+ )
8
+ from langtrace_python_sdk import langtrace, with_langtrace_root_span
9
+
10
+
11
+ class AWSBedrockRunner:
12
+ @with_langtrace_root_span("AWS_Bedrock")
13
+ def run(self):
14
+
15
+ use_converse_stream()
16
+ use_converse()
17
+ use_invoke_model_anthropic()
18
+ use_invoke_model_cohere()
19
+ use_invoke_model_amazon()
@@ -0,0 +1,174 @@
1
+ import boto3
2
+ import json
3
+ from langtrace_python_sdk import langtrace
4
+ from dotenv import load_dotenv
5
+ import botocore
6
+
7
+ load_dotenv()
8
+ langtrace.init(write_spans_to_console=False)
9
+
10
+ brt = boto3.client("bedrock-runtime", region_name="us-east-1")
11
+ brc = boto3.client("bedrock", region_name="us-east-1")
12
+
13
+
14
+ def use_converse_stream():
15
+ model_id = "anthropic.claude-3-haiku-20240307-v1:0"
16
+ conversation = [
17
+ {
18
+ "role": "user",
19
+ "content": [{"text": "what is the capital of France?"}],
20
+ }
21
+ ]
22
+
23
+ try:
24
+ response = brt.converse_stream(
25
+ modelId=model_id,
26
+ messages=conversation,
27
+ inferenceConfig={"maxTokens": 4096, "temperature": 0},
28
+ additionalModelRequestFields={"top_k": 250},
29
+ )
30
+ # response_text = response["output"]["message"]["content"][0]["text"]
31
+ print(response)
32
+
33
+ except Exception as e:
34
+ print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}")
35
+ exit(1)
36
+
37
+
38
+ def use_converse():
39
+ model_id = "anthropic.claude-3-haiku-20240307-v1:0"
40
+ conversation = [
41
+ {
42
+ "role": "user",
43
+ "content": [{"text": "what is the capital of France?"}],
44
+ }
45
+ ]
46
+
47
+ try:
48
+ response = brt.converse(
49
+ modelId=model_id,
50
+ messages=conversation,
51
+ inferenceConfig={"maxTokens": 4096, "temperature": 0},
52
+ additionalModelRequestFields={"top_k": 250},
53
+ )
54
+ response_text = response["output"]["message"]["content"][0]["text"]
55
+ print(response_text)
56
+
57
+ except Exception as e:
58
+ print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}")
59
+ exit(1)
60
+
61
+
62
+ def get_foundation_models():
63
+ for model in brc.list_foundation_models()["modelSummaries"]:
64
+ print(model["modelId"])
65
+
66
+
67
+ # Invoke Model API
68
+ # Amazon Titan Models
69
+ def use_invoke_model_titan(stream=False):
70
+ try:
71
+ prompt_data = "what's the capital of France?"
72
+ body = json.dumps(
73
+ {
74
+ "inputText": prompt_data,
75
+ "textGenerationConfig": {
76
+ "maxTokenCount": 1024,
77
+ "topP": 0.95,
78
+ "temperature": 0.2,
79
+ },
80
+ }
81
+ )
82
+ modelId = "amazon.titan-text-express-v1" # "amazon.titan-tg1-large"
83
+ accept = "application/json"
84
+ contentType = "application/json"
85
+
86
+ if stream:
87
+
88
+ response = brt.invoke_model_with_response_stream(
89
+ body=body, modelId=modelId, accept=accept, contentType=contentType
90
+ )
91
+ else:
92
+ response = brt.invoke_model(
93
+ body=body, modelId=modelId, accept=accept, contentType=contentType
94
+ )
95
+ response_body = json.loads(response.get("body").read())
96
+
97
+ except botocore.exceptions.ClientError as error:
98
+
99
+ if error.response["Error"]["Code"] == "AccessDeniedException":
100
+ print(
101
+ f"\x1b[41m{error.response['Error']['Message']}\
102
+ \nTo troubeshoot this issue please refer to the following resources.\
103
+ \nhttps://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_access-denied.html\
104
+ \nhttps://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html\x1b[0m\n"
105
+ )
106
+
107
+ else:
108
+ raise error
109
+
110
+
111
+ # Anthropic Models
112
+ def use_invoke_model_anthropic(stream=False):
113
+ body = json.dumps(
114
+ {
115
+ "anthropic_version": "bedrock-2023-05-31",
116
+ "max_tokens": 1024,
117
+ "temperature": 0.1,
118
+ "top_p": 0.9,
119
+ "messages": [{"role": "user", "content": "Hello, Claude"}],
120
+ }
121
+ )
122
+ modelId = "anthropic.claude-v2"
123
+ accept = "application/json"
124
+ contentType = "application/json"
125
+
126
+ if stream:
127
+ response = brt.invoke_model_with_response_stream(body=body, modelId=modelId)
128
+ stream_response = response.get("body")
129
+ if stream_response:
130
+ for event in stream_response:
131
+ chunk = event.get("chunk")
132
+ if chunk:
133
+ print(json.loads(chunk.get("bytes").decode()))
134
+
135
+ else:
136
+ response = brt.invoke_model(
137
+ body=body, modelId=modelId, accept=accept, contentType=contentType
138
+ )
139
+ response_body = json.loads(response.get("body").read())
140
+ # text
141
+ print(response_body.get("completion"))
142
+
143
+
144
+ def use_invoke_model_llama():
145
+ model_id = "meta.llama3-8b-instruct-v1:0"
146
+ prompt = "What is the capital of France?"
147
+ max_gen_len = 128
148
+ temperature = 0.1
149
+ top_p = 0.9
150
+
151
+ # Create request body.
152
+ body = json.dumps(
153
+ {
154
+ "prompt": prompt,
155
+ "max_gen_len": max_gen_len,
156
+ "temperature": temperature,
157
+ "top_p": top_p,
158
+ }
159
+ )
160
+ response = brt.invoke_model(body=body, modelId=model_id)
161
+
162
+ response_body = json.loads(response.get("body").read())
163
+
164
+ return response_body
165
+
166
+
167
+ # print(get_foundation_models())
168
+ def use_invoke_model_cohere():
169
+ model_id = "cohere.command-r-plus-v1"
170
+ prompt = "What is the capital of France?"
171
+ body = json.dumps({"prompt": prompt, "max_tokens": 1024, "temperature": 0.1})
172
+ response = brt.invoke_model(body=body, modelId=model_id)
173
+ response_body = json.loads(response.get("body").read())
174
+ print(response_body)
@@ -1,6 +1,10 @@
1
1
  from langtrace.trace_attributes import AWSBedrockMethods
2
2
 
3
3
  APIS = {
4
+ "INVOKE_MODEL": {
5
+ "METHOD": "aws_bedrock.invoke_model",
6
+ "ENDPOINT": "/invoke-model",
7
+ },
4
8
  "CONVERSE": {
5
9
  "METHOD": AWSBedrockMethods.CONVERSE.value,
6
10
  "ENDPOINT": "/converse",
@@ -0,0 +1,43 @@
1
+ import json
2
+ from wrapt import ObjectProxy
3
+
4
+
5
+ class StreamingWrapper(ObjectProxy):
6
+ def __init__(
7
+ self,
8
+ response,
9
+ stream_done_callback=None,
10
+ ):
11
+ super().__init__(response)
12
+
13
+ self._stream_done_callback = stream_done_callback
14
+ self._accumulating_body = {}
15
+
16
+ def __iter__(self):
17
+ for event in self.__wrapped__:
18
+ self._process_event(event)
19
+ yield event
20
+
21
+ def _process_event(self, event):
22
+ chunk = event.get("chunk")
23
+ if not chunk:
24
+ return
25
+
26
+ decoded_chunk = json.loads(chunk.get("bytes").decode())
27
+ type = decoded_chunk.get("type")
28
+
29
+ if type == "message_start":
30
+ self._accumulating_body = decoded_chunk.get("message")
31
+ elif type == "content_block_start":
32
+ self._accumulating_body["content"].append(
33
+ decoded_chunk.get("content_block")
34
+ )
35
+ elif type == "content_block_delta":
36
+ self._accumulating_body["content"][-1]["text"] += decoded_chunk.get(
37
+ "delta"
38
+ ).get("text")
39
+ elif type == "message_stop" and self._stream_done_callback:
40
+ self._accumulating_body["invocation_metrics"] = decoded_chunk.get(
41
+ "amazon-bedrock-invocationMetrics"
42
+ )
43
+ self._stream_done_callback(self._accumulating_body)
@@ -22,22 +22,13 @@ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
22
22
  from opentelemetry.trace import get_tracer
23
23
  from wrapt import wrap_function_wrapper as _W
24
24
 
25
- from langtrace_python_sdk.instrumentation.aws_bedrock.patch import (
26
- converse, converse_stream
27
- )
25
+ from langtrace_python_sdk.instrumentation.aws_bedrock.patch import patch_aws_bedrock
28
26
 
29
27
  logging.basicConfig(level=logging.FATAL)
30
28
 
31
- def _patch_client(client, version: str, tracer) -> None:
32
-
33
- # Store original methods
34
- original_converse = client.converse
35
-
36
- # Replace with wrapped versions
37
- client.converse = converse("aws_bedrock.converse", version, tracer)(original_converse)
38
29
 
39
30
  class AWSBedrockInstrumentation(BaseInstrumentor):
40
-
31
+
41
32
  def instrumentation_dependencies(self) -> Collection[str]:
42
33
  return ["boto3 >= 1.35.31"]
43
34
 
@@ -46,13 +37,11 @@ class AWSBedrockInstrumentation(BaseInstrumentor):
46
37
  tracer = get_tracer(__name__, "", tracer_provider)
47
38
  version = importlib.metadata.version("boto3")
48
39
 
49
- def wrap_create_client(wrapped, instance, args, kwargs):
50
- result = wrapped(*args, **kwargs)
51
- if args and args[0] == 'bedrock-runtime':
52
- _patch_client(result, version, tracer)
53
- return result
54
-
55
- _W("boto3", "client", wrap_create_client)
40
+ _W(
41
+ module="boto3",
42
+ name="client",
43
+ wrapper=patch_aws_bedrock(tracer, version),
44
+ )
56
45
 
57
46
  def _uninstrument(self, **kwargs):
58
- pass
47
+ pass
@@ -0,0 +1,396 @@
1
+ """
2
+ Copyright (c) 2024 Scale3 Labs
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
16
+
17
+ import json
18
+
19
+ from langtrace_python_sdk.instrumentation.aws_bedrock.bedrock_streaming_wrapper import (
20
+ StreamingWrapper,
21
+ )
22
+ from .stream_body_wrapper import BufferedStreamBody
23
+ from functools import wraps
24
+ from langtrace.trace_attributes import (
25
+ LLMSpanAttributes,
26
+ SpanAttributes,
27
+ )
28
+ from langtrace_python_sdk.utils import set_span_attribute
29
+ from langtrace_python_sdk.utils.silently_fail import silently_fail
30
+ from opentelemetry import trace
31
+ from opentelemetry.trace import SpanKind
32
+ from opentelemetry.trace.status import Status, StatusCode
33
+ from opentelemetry.trace.propagation import set_span_in_context
34
+ from langtrace_python_sdk.constants.instrumentation.common import (
35
+ SERVICE_PROVIDERS,
36
+ )
37
+ from langtrace_python_sdk.constants.instrumentation.aws_bedrock import APIS
38
+ from langtrace_python_sdk.utils.llm import (
39
+ get_extra_attributes,
40
+ get_langtrace_attributes,
41
+ get_llm_request_attributes,
42
+ get_llm_url,
43
+ get_span_name,
44
+ set_event_completion,
45
+ set_span_attributes,
46
+ set_usage_attributes,
47
+ )
48
+
49
+
50
+ def converse_stream(original_method, version, tracer):
51
+ def traced_method(wrapped, instance, args, kwargs):
52
+ service_provider = SERVICE_PROVIDERS["AWS_BEDROCK"]
53
+
54
+ span_attributes = {
55
+ **get_langtrace_attributes(version, service_provider, vendor_type="llm"),
56
+ **get_llm_request_attributes(kwargs),
57
+ **get_llm_url(instance),
58
+ SpanAttributes.LLM_PATH: APIS["CONVERSE_STREAM"]["ENDPOINT"],
59
+ **get_extra_attributes(),
60
+ }
61
+
62
+ attributes = LLMSpanAttributes(**span_attributes)
63
+
64
+ with tracer.start_as_current_span(
65
+ name=get_span_name(APIS["CONVERSE_STREAM"]["METHOD"]),
66
+ kind=SpanKind.CLIENT,
67
+ context=set_span_in_context(trace.get_current_span()),
68
+ ) as span:
69
+ set_span_attributes(span, attributes)
70
+ try:
71
+ result = wrapped(*args, **kwargs)
72
+ _set_response_attributes(span, kwargs, result)
73
+ span.set_status(StatusCode.OK)
74
+ return result
75
+ except Exception as err:
76
+ span.record_exception(err)
77
+ span.set_status(Status(StatusCode.ERROR, str(err)))
78
+ raise err
79
+
80
+ return traced_method
81
+
82
+
83
+ def patch_aws_bedrock(tracer, version):
84
+ def traced_method(wrapped, instance, args, kwargs):
85
+ if args and args[0] != "bedrock-runtime":
86
+ return wrapped(*args, **kwargs)
87
+
88
+ client = wrapped(*args, **kwargs)
89
+ client.invoke_model = patch_invoke_model(client.invoke_model, tracer, version)
90
+
91
+ client.converse = patch_converse(client.converse, tracer, version)
92
+ client.converse_stream = patch_converse_stream(
93
+ client.converse_stream, tracer, version
94
+ )
95
+
96
+ return client
97
+
98
+ return traced_method
99
+
100
+
101
+ def patch_converse_stream(original_method, tracer, version):
102
+ def traced_method(*args, **kwargs):
103
+ modelId = kwargs.get("modelId")
104
+ (vendor, _) = modelId.split(".")
105
+ input_content = [
106
+ {
107
+ "role": message.get("role", "user"),
108
+ "content": message.get("content", [])[0].get("text", ""),
109
+ }
110
+ for message in kwargs.get("messages", [])
111
+ ]
112
+
113
+ span_attributes = {
114
+ **get_langtrace_attributes(version, vendor, vendor_type="framework"),
115
+ **get_llm_request_attributes(kwargs, model=modelId, prompts=input_content),
116
+ **get_llm_url(args[0] if args else None),
117
+ **get_extra_attributes(),
118
+ }
119
+ with tracer.start_as_current_span(
120
+ name=get_span_name("aws_bedrock.converse"),
121
+ kind=SpanKind.CLIENT,
122
+ context=set_span_in_context(trace.get_current_span()),
123
+ ) as span:
124
+ set_span_attributes(span, span_attributes)
125
+ response = original_method(*args, **kwargs)
126
+
127
+ if span.is_recording():
128
+ set_span_streaming_response(span, response)
129
+ return response
130
+
131
+ return traced_method
132
+
133
+
134
+ def patch_converse(original_method, tracer, version):
135
+ def traced_method(*args, **kwargs):
136
+ modelId = kwargs.get("modelId")
137
+ (vendor, _) = modelId.split(".")
138
+ input_content = [
139
+ {
140
+ "role": message.get("role", "user"),
141
+ "content": message.get("content", [])[0].get("text", ""),
142
+ }
143
+ for message in kwargs.get("messages", [])
144
+ ]
145
+
146
+ span_attributes = {
147
+ **get_langtrace_attributes(version, vendor, vendor_type="framework"),
148
+ **get_llm_request_attributes(kwargs, model=modelId, prompts=input_content),
149
+ **get_llm_url(args[0] if args else None),
150
+ **get_extra_attributes(),
151
+ }
152
+ with tracer.start_as_current_span(
153
+ name=get_span_name("aws_bedrock.converse"),
154
+ kind=SpanKind.CLIENT,
155
+ context=set_span_in_context(trace.get_current_span()),
156
+ ) as span:
157
+ set_span_attributes(span, span_attributes)
158
+ response = original_method(*args, **kwargs)
159
+
160
+ if span.is_recording():
161
+ _set_response_attributes(span, kwargs, response)
162
+ return response
163
+
164
+ return traced_method
165
+
166
+
167
+ def patch_invoke_model(original_method, tracer, version):
168
+ def traced_method(*args, **kwargs):
169
+ modelId = kwargs.get("modelId")
170
+ (vendor, _) = modelId.split(".")
171
+ span_attributes = {
172
+ **get_langtrace_attributes(version, vendor, vendor_type="framework"),
173
+ **get_extra_attributes(),
174
+ }
175
+ with tracer.start_as_current_span(
176
+ name=get_span_name("aws_bedrock.invoke_model"),
177
+ kind=SpanKind.CLIENT,
178
+ context=set_span_in_context(trace.get_current_span()),
179
+ ) as span:
180
+ set_span_attributes(span, span_attributes)
181
+ response = original_method(*args, **kwargs)
182
+ if span.is_recording():
183
+ handle_call(span, kwargs, response)
184
+ return response
185
+
186
+ return traced_method
187
+
188
+
189
+ def handle_call(span, kwargs, response):
190
+ modelId = kwargs.get("modelId")
191
+ (vendor, model_name) = modelId.split(".")
192
+ response["body"] = BufferedStreamBody(
193
+ response["body"]._raw_stream, response["body"]._content_length
194
+ )
195
+ request_body = json.loads(kwargs.get("body"))
196
+ response_body = json.loads(response.get("body").read())
197
+
198
+ set_span_attribute(span, SpanAttributes.LLM_SYSTEM, vendor)
199
+ set_span_attribute(span, SpanAttributes.LLM_RESPONSE_MODEL, modelId)
200
+ set_span_attribute(span, SpanAttributes.LLM_REQUEST_MODEL, modelId)
201
+
202
+ if vendor == "amazon":
203
+ set_amazon_attributes(span, request_body, response_body)
204
+
205
+ if vendor == "anthropic":
206
+ if "prompt" in request_body:
207
+ set_anthropic_completions_attributes(span, request_body, response_body)
208
+ elif "messages" in request_body:
209
+ set_anthropic_messages_attributes(span, request_body, response_body)
210
+
211
+ if vendor == "meta":
212
+ set_llama_meta_attributes(span, request_body, response_body)
213
+
214
+
215
+ def set_llama_meta_attributes(span, request_body, response_body):
216
+ set_span_attribute(
217
+ span, SpanAttributes.LLM_REQUEST_TOP_P, request_body.get("top_p")
218
+ )
219
+ set_span_attribute(
220
+ span, SpanAttributes.LLM_REQUEST_TEMPERATURE, request_body.get("temperature")
221
+ )
222
+ set_span_attribute(
223
+ span, SpanAttributes.LLM_REQUEST_MAX_TOKENS, request_body.get("max_gen_len")
224
+ )
225
+
226
+ set_usage_attributes(
227
+ span,
228
+ {
229
+ "input_tokens": response_body.get("prompt_token_count"),
230
+ "output_tokens": response_body.get("generation_token_count"),
231
+ },
232
+ )
233
+
234
+ prompts = [
235
+ {
236
+ "role": "user",
237
+ "content": request_body.get("prompt"),
238
+ }
239
+ ]
240
+
241
+ completions = [
242
+ {
243
+ "role": "assistant",
244
+ "content": response_body.get("generation"),
245
+ }
246
+ ]
247
+ set_span_attribute(span, SpanAttributes.LLM_PROMPTS, json.dumps(prompts))
248
+ print(completions)
249
+ set_event_completion(span, completions)
250
+
251
+
252
+ def set_amazon_attributes(span, request_body, response_body):
253
+ config = request_body.get("textGenerationConfig", {})
254
+ prompts = [
255
+ {
256
+ "role": "user",
257
+ "content": request_body.get("inputText"),
258
+ }
259
+ ]
260
+ completions = [
261
+ {
262
+ "role": "assistant",
263
+ "content": result.get("outputText"),
264
+ }
265
+ for result in response_body.get("results")
266
+ ]
267
+ set_span_attribute(
268
+ span, SpanAttributes.LLM_REQUEST_MAX_TOKENS, config.get("maxTokenCount")
269
+ )
270
+ set_span_attribute(
271
+ span, SpanAttributes.LLM_REQUEST_TEMPERATURE, config.get("temperature")
272
+ )
273
+ set_span_attribute(span, SpanAttributes.LLM_REQUEST_TOP_P, config.get("topP"))
274
+ set_span_attribute(span, SpanAttributes.LLM_PROMPTS, json.dumps(prompts))
275
+ set_usage_attributes(
276
+ span,
277
+ {
278
+ "input_tokens": response_body.get("inputTextTokenCount"),
279
+ "output_tokens": sum(
280
+ int(result.get("tokenCount")) for result in response_body.get("results")
281
+ ),
282
+ },
283
+ )
284
+ set_event_completion(span, completions)
285
+
286
+
287
+ def set_anthropic_completions_attributes(span, request_body, response_body):
288
+ set_span_attribute(
289
+ span,
290
+ SpanAttributes.LLM_REQUEST_MAX_TOKENS,
291
+ request_body.get("max_tokens_to_sample"),
292
+ )
293
+ set_span_attribute(
294
+ span,
295
+ SpanAttributes.LLM_REQUEST_TEMPERATURE,
296
+ str(request_body.get("temperature")),
297
+ )
298
+ set_span_attribute(
299
+ span,
300
+ SpanAttributes.LLM_REQUEST_TOP_P,
301
+ str(request_body.get("top_p")),
302
+ )
303
+ prompts = [
304
+ {
305
+ "role": "user",
306
+ "content": request_body.get("prompt"),
307
+ }
308
+ ]
309
+ completions = [
310
+ {
311
+ "role": "assistant",
312
+ "content": response_body.get("completion"),
313
+ }
314
+ ]
315
+ set_span_attribute(span, SpanAttributes.LLM_PROMPTS, json.dumps(prompts))
316
+ set_event_completion(span, completions)
317
+
318
+
319
+ def set_anthropic_messages_attributes(span, request_body, response_body):
320
+ set_span_attribute(
321
+ span,
322
+ SpanAttributes.LLM_REQUEST_MAX_TOKENS,
323
+ request_body.get("max_tokens_to_sample"),
324
+ )
325
+ set_span_attribute(
326
+ span,
327
+ SpanAttributes.LLM_REQUEST_TEMPERATURE,
328
+ str(request_body.get("temperature")),
329
+ )
330
+ set_span_attribute(
331
+ span,
332
+ SpanAttributes.LLM_REQUEST_TOP_P,
333
+ str(request_body.get("top_p")),
334
+ )
335
+ set_span_attribute(
336
+ span, SpanAttributes.LLM_PROMPTS, json.dumps(request_body.get("messages"))
337
+ )
338
+ set_event_completion(span, response_body.get("content"))
339
+ set_usage_attributes(span, response_body.get("usage"))
340
+
341
+
342
+ @silently_fail
343
+ def _set_response_attributes(span, kwargs, result):
344
+ set_span_attribute(span, SpanAttributes.LLM_RESPONSE_MODEL, kwargs.get("modelId"))
345
+ set_span_attribute(
346
+ span,
347
+ SpanAttributes.LLM_TOP_K,
348
+ kwargs.get("additionalModelRequestFields", {}).get("top_k"),
349
+ )
350
+ content = result.get("output", {}).get("message", {}).get("content", [])
351
+ if len(content) > 0:
352
+ role = result.get("output", {}).get("message", {}).get("role", "assistant")
353
+ responses = [{"role": role, "content": c.get("text", "")} for c in content]
354
+ set_event_completion(span, responses)
355
+
356
+ if "usage" in result:
357
+ set_span_attributes(
358
+ span,
359
+ {
360
+ SpanAttributes.LLM_USAGE_COMPLETION_TOKENS: result["usage"].get(
361
+ "outputTokens"
362
+ ),
363
+ SpanAttributes.LLM_USAGE_PROMPT_TOKENS: result["usage"].get(
364
+ "inputTokens"
365
+ ),
366
+ SpanAttributes.LLM_USAGE_TOTAL_TOKENS: result["usage"].get(
367
+ "totalTokens"
368
+ ),
369
+ },
370
+ )
371
+
372
+
373
+ def set_span_streaming_response(span, response):
374
+ streaming_response = ""
375
+ role = None
376
+ for event in response["stream"]:
377
+ if "messageStart" in event:
378
+ role = event["messageStart"]["role"]
379
+ elif "contentBlockDelta" in event:
380
+ delta = event["contentBlockDelta"]["delta"]
381
+ if "text" in delta:
382
+ streaming_response += delta["text"]
383
+ elif "metadata" in event and "usage" in event["metadata"]:
384
+ usage = event["metadata"]["usage"]
385
+ set_usage_attributes(
386
+ span,
387
+ {
388
+ "input_tokens": usage.get("inputTokens"),
389
+ "output_tokens": usage.get("outputTokens"),
390
+ },
391
+ )
392
+
393
+ if streaming_response:
394
+ set_event_completion(
395
+ span, [{"role": role or "assistant", "content": streaming_response}]
396
+ )