futureagi 0.5.3__tar.gz → 0.5.4__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 (236) hide show
  1. {futureagi-0.5.3 → futureagi-0.5.4}/PKG-INFO +1 -1
  2. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/_wrappers.py +9 -3
  3. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/__init__.py +86 -0
  4. futureagi-0.5.4/fi/integrations/otel/frameworks/dspy/examples/embedding.py +28 -0
  5. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/_request_attributes_extractor.py +28 -8
  6. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/_tracer.py +0 -1
  7. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/language_agent_tree_search.py +1 -0
  8. futureagi-0.5.4/fi/integrations/otel/frameworks/langchain/examples/rerank.py +102 -0
  9. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/litellm/__init__.py +4 -2
  10. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/litellm/examples/litellm_test.py +27 -2
  11. futureagi-0.5.4/fi/integrations/otel/frameworks/litellm/examples/rerank.py +36 -0
  12. futureagi-0.5.4/fi/integrations/otel/frameworks/llama_index/examples/rerank.py +76 -0
  13. futureagi-0.5.4/fi/integrations/otel/frameworks/llama_index/examples/retriever.py +64 -0
  14. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/_request_attributes_extractor.py +23 -6
  15. futureagi-0.5.4/fi/integrations/otel/frameworks/mistralai/examples/new-1.py +107 -0
  16. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/_wrapper.py +22 -2
  17. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/audio_transcription.py +3 -1
  18. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/audio_understanding.py +3 -1
  19. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/basic_generation.py +3 -1
  20. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/chat.py +3 -1
  21. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/document_understanding.py +3 -1
  22. futureagi-0.5.4/fi/integrations/otel/frameworks/vertexai/examples/embedding.py +47 -0
  23. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/function_calling.py +3 -1
  24. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/image_from_cloud_storage.py +3 -1
  25. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/system_instructions.py +3 -1
  26. futureagi-0.5.4/fi/integrations/otel/frameworks/vertexai/examples/tool_calling.py +106 -0
  27. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/vertexai.model.generate_content.py +5 -1
  28. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/video_and_audio_understanding.py +3 -1
  29. {futureagi-0.5.3 → futureagi-0.5.4}/fi/prompt/client.py +8 -14
  30. {futureagi-0.5.3 → futureagi-0.5.4}/pyproject.toml +1 -1
  31. {futureagi-0.5.3 → futureagi-0.5.4}/LICENSE.md +0 -0
  32. {futureagi-0.5.3 → futureagi-0.5.4}/README.md +0 -0
  33. {futureagi-0.5.3 → futureagi-0.5.4}/fi/__init__.py +0 -0
  34. {futureagi-0.5.3 → futureagi-0.5.4}/fi/api/__init__.py +0 -0
  35. {futureagi-0.5.3 → futureagi-0.5.4}/fi/api/apikeys.py +0 -0
  36. {futureagi-0.5.3 → futureagi-0.5.4}/fi/api/auth.py +0 -0
  37. {futureagi-0.5.3 → futureagi-0.5.4}/fi/api/types.py +0 -0
  38. {futureagi-0.5.3 → futureagi-0.5.4}/fi/client.py +0 -0
  39. {futureagi-0.5.3 → futureagi-0.5.4}/fi/datasets/__init__.py +0 -0
  40. {futureagi-0.5.3 → futureagi-0.5.4}/fi/datasets/client.py +0 -0
  41. {futureagi-0.5.3 → futureagi-0.5.4}/fi/datasets/types.py +0 -0
  42. {futureagi-0.5.3 → futureagi-0.5.4}/fi/evals/__init__.py +0 -0
  43. {futureagi-0.5.3 → futureagi-0.5.4}/fi/evals/evaluator.py +0 -0
  44. {futureagi-0.5.3 → futureagi-0.5.4}/fi/evals/protect.py +0 -0
  45. {futureagi-0.5.3 → futureagi-0.5.4}/fi/evals/templates.py +0 -0
  46. {futureagi-0.5.3 → futureagi-0.5.4}/fi/evals/types.py +0 -0
  47. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/__init__.py +0 -0
  48. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/__init__.py +0 -0
  49. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/__init__.py +0 -0
  50. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/_stream.py +0 -0
  51. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/_utils.py +0 -0
  52. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/_with_span.py +0 -0
  53. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/anthropic.sh +0 -0
  54. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/anthropic_examples.py +0 -0
  55. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/chat_completions.py +0 -0
  56. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/end_to_end_tool_use.py +0 -0
  57. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/multiple_tool_calling.py +0 -0
  58. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/requirements.txt +0 -0
  59. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/sync_completions.py +0 -0
  60. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/examples/sync_messages.py +0 -0
  61. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/anthropic/version.py +0 -0
  62. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/__generated__/__init__.py +0 -0
  63. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/__generated__/anthropic/__init__.py +0 -0
  64. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/__generated__/anthropic/_types.py +0 -0
  65. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/__init__.py +0 -0
  66. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/_proxy.py +0 -0
  67. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/_wrappers.py +0 -0
  68. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/examples/bedrock.sh +0 -0
  69. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/examples/bedrock_1.py +0 -0
  70. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/examples/bedrock_2.py +0 -0
  71. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/examples/bedrock_converse.py +0 -0
  72. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/examples/bedrock_multimodal.py +0 -0
  73. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/package.py +0 -0
  74. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/py.typed +0 -0
  75. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/utils/__init__.py +0 -0
  76. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/utils/anthropic/__init__.py +0 -0
  77. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/utils/anthropic/_messages.py +0 -0
  78. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/bedrock/version.py +0 -0
  79. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/crewai/__init__.py +0 -0
  80. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/crewai/_wrappers.py +0 -0
  81. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/crewai/examples/crew_ai.py +0 -0
  82. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/crewai/version.py +0 -0
  83. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/examples/dspy.sh +0 -0
  84. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/examples/dspy_basic_qa.py +0 -0
  85. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/examples/lm.py +0 -0
  86. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/examples/rag_module.py +0 -0
  87. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/examples/requirements.txt +0 -0
  88. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/package.py +0 -0
  89. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/py.typed +0 -0
  90. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/dspy/version.py +0 -0
  91. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/__init__.py +0 -0
  92. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/_response_attributes_extractor.py +0 -0
  93. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/_utils.py +0 -0
  94. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/_with_span.py +0 -0
  95. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/_wrappers.py +0 -0
  96. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/examples/async_chat_completions.py +0 -0
  97. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/examples/chat_completions.py +0 -0
  98. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/examples/chat_completions_with_tool.py +0 -0
  99. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/examples/groq.sh +0 -0
  100. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/groq/version.py +0 -0
  101. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/__init__.py +0 -0
  102. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/_wrappers.py +0 -0
  103. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/building_fallbacks_with_conditional_routing.py +0 -0
  104. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/cohere_reranker.py +0 -0
  105. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/filtering_documents_with_metadata.py +0 -0
  106. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/haystack.sh +0 -0
  107. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/haystack_rag_pipeline.py +0 -0
  108. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/qa_rag_pipeline.py +0 -0
  109. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/requirements.txt +0 -0
  110. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/tool_calling.py +0 -0
  111. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/examples/web_questions.py +0 -0
  112. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/haystack/version.py +0 -0
  113. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/instructor/__init__.py +0 -0
  114. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/instructor/_wrappers.py +0 -0
  115. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/instructor/examples/test_instructor.py +0 -0
  116. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/instructor/version.py +0 -0
  117. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/__init__.py +0 -0
  118. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/chain_metadata.py +0 -0
  119. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/chat_prompt_template.py +0 -0
  120. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/custom_retriever.py +0 -0
  121. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/documents/2402.03300v3.pdf +0 -0
  122. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/documents/2501.04519v1.pdf +0 -0
  123. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/documents/2501.19393v2.pdf +0 -0
  124. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/exchange_rate_tool.py +0 -0
  125. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/langchain.sh +0 -0
  126. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/langgraph_agent_supervisor.py +0 -0
  127. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/multimodal.py +0 -0
  128. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/openai_chat_stream.py +0 -0
  129. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/pathway_retriever.py +0 -0
  130. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/rag.py +0 -0
  131. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/requirements.txt +0 -0
  132. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/sqlagent.py +0 -0
  133. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/examples/tool_calling_agent.py +0 -0
  134. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/package.py +0 -0
  135. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/langchain/version.py +0 -0
  136. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/litellm/package.py +0 -0
  137. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/litellm/py.typed +0 -0
  138. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/litellm/version.py +0 -0
  139. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/__init__.py +0 -0
  140. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/_callback.py +0 -0
  141. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/_handler.py +0 -0
  142. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/agent_calculator_tools.py +0 -0
  143. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/chat_engine_stream.py +0 -0
  144. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/chroma_query_engine.py +0 -0
  145. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/ingestion_pipeline.py +0 -0
  146. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/llama_index.sh +0 -0
  147. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/multimodal_stream_chat.py +0 -0
  148. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/openai_stream_chat.py +0 -0
  149. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/requirements.txt +0 -0
  150. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/text_to_sql.py +0 -0
  151. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/examples/workflow.py +0 -0
  152. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/package.py +0 -0
  153. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/py.typed +0 -0
  154. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/llama_index/version.py +0 -0
  155. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/__init__.py +0 -0
  156. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/_chat_wrapper.py +0 -0
  157. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/_response_accumulator.py +0 -0
  158. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/_response_attributes_extractor.py +0 -0
  159. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/_stream.py +0 -0
  160. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/_utils.py +0 -0
  161. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/_with_span.py +0 -0
  162. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/examples/agent_completions.py +0 -0
  163. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/examples/chat_completions.py +0 -0
  164. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/examples/chat_completions_async.py +0 -0
  165. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/examples/chat_completions_async_streaming.py +0 -0
  166. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/examples/chat_completions_streaming.py +0 -0
  167. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/examples/mistralai.sh +0 -0
  168. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/examples/requirements.txt +0 -0
  169. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/package.py +0 -0
  170. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/py.typed +0 -0
  171. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/mistralai/version.py +0 -0
  172. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/__init__.py +0 -0
  173. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_request.py +0 -0
  174. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_request_attributes_extractor.py +0 -0
  175. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_response_accumulator.py +0 -0
  176. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_response_attributes_extractor.py +0 -0
  177. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_span_io_handler.py +0 -0
  178. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_stream.py +0 -0
  179. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_utils.py +0 -0
  180. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/_with_span.py +0 -0
  181. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions.py +0 -0
  182. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_async_stream.py +0 -0
  183. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_async_stream_with_raw_response.py +0 -0
  184. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_multimodal.py +0 -0
  185. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_stream.py +0 -0
  186. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_stream_with_raw_response.py +0 -0
  187. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_with_function_calling.py +0 -0
  188. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_with_raw_response.py +0 -0
  189. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/chat_completions_with_streaming_response.py +0 -0
  190. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/embeddings.py +0 -0
  191. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/openai.sh +0 -0
  192. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/openai_tool.py +0 -0
  193. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/examples/requirements.txt +0 -0
  194. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/package.py +0 -0
  195. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/py.typed +0 -0
  196. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/test-requirements.txt +0 -0
  197. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/openai/version.py +0 -0
  198. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/__init__.py +0 -0
  199. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/_accumulator.py +0 -0
  200. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/_instrumentation_status.py +0 -0
  201. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/_proxy.py +0 -0
  202. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/requirements.txt +0 -0
  203. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/vertexai.model.count_tokens.py +0 -0
  204. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/examples/vertexai.sh +0 -0
  205. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/package.py +0 -0
  206. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/py.typed +0 -0
  207. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/frameworks/vertexai/version.py +0 -0
  208. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/instrumentation/.gitignore +0 -0
  209. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/instrumentation/__init__.py +0 -0
  210. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/instrumentation/config.py +0 -0
  211. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/instrumentation/context_attributes.py +0 -0
  212. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/instrumentation/helpers.py +0 -0
  213. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/instrumentation/logging.py +0 -0
  214. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/instrumentation/version.py +0 -0
  215. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/otel.py +0 -0
  216. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/settings.py +0 -0
  217. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/otel/types.py +0 -0
  218. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/providers/__init__.py +0 -0
  219. {futureagi-0.5.3 → futureagi-0.5.4}/fi/integrations/providers/types.py +0 -0
  220. {futureagi-0.5.3 → futureagi-0.5.4}/fi/prompt/__init__.py +0 -0
  221. {futureagi-0.5.3 → futureagi-0.5.4}/fi/prompt/types.py +0 -0
  222. {futureagi-0.5.3 → futureagi-0.5.4}/fi/test/eval_tags.py +0 -0
  223. {futureagi-0.5.3 → futureagi-0.5.4}/fi/testcases/__init__.py +0 -0
  224. {futureagi-0.5.3 → futureagi-0.5.4}/fi/testcases/conversational_test_case.py +0 -0
  225. {futureagi-0.5.3 → futureagi-0.5.4}/fi/testcases/general.py +0 -0
  226. {futureagi-0.5.3 → futureagi-0.5.4}/fi/testcases/llm_test_case.py +0 -0
  227. {futureagi-0.5.3 → futureagi-0.5.4}/fi/testcases/mllm_test_case.py +0 -0
  228. {futureagi-0.5.3 → futureagi-0.5.4}/fi/testcases/utils.py +0 -0
  229. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/__init__.py +0 -0
  230. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/constants.py +0 -0
  231. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/errors.py +0 -0
  232. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/executor.py +0 -0
  233. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/logging.py +0 -0
  234. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/routes.py +0 -0
  235. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/types.py +0 -0
  236. {futureagi-0.5.3 → futureagi-0.5.4}/fi/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: futureagi
3
- Version: 0.5.3
3
+ Version: 0.5.4
4
4
  Summary: We help GenAI teams maintain high-accuracy for their Models in production.
5
5
  Author: Future AGI
6
6
  Author-email: no-reply@futureagi.com
@@ -32,6 +32,7 @@ from fi.integrations.otel.types import (
32
32
  FiMimeTypeValues,
33
33
  FiSpanKindValues,
34
34
  MessageAttributes,
35
+ MessageContentAttributes,
35
36
  SpanAttributes,
36
37
  ToolAttributes,
37
38
  ToolCallAttributes,
@@ -669,7 +670,7 @@ def _get_llm_input_messages(messages: List[Dict[str, str]]) -> Any:
669
670
  if isinstance(content, str):
670
671
  yield f"{LLM_INPUT_MESSAGES}.{i}.{MESSAGE_CONTENT}", content
671
672
  elif isinstance(content, list):
672
- for block in content:
673
+ for block_index, block in enumerate(content):
673
674
  if isinstance(block, ToolUseBlock):
674
675
  if tool_call_id := block.id:
675
676
  yield (
@@ -686,7 +687,8 @@ def _get_llm_input_messages(messages: List[Dict[str, str]]) -> Any:
686
687
  )
687
688
  tool_index += 1
688
689
  elif isinstance(block, TextBlock):
689
- yield f"{LLM_INPUT_MESSAGES}.{i}.{MESSAGE_CONTENT}", block.text
690
+ yield f"{LLM_INPUT_MESSAGES}.{i}.{MESSAGE_CONTENT}.{block_index}.{MESSAGE_CONTENT_TYPE}", "text"
691
+ yield f"{LLM_INPUT_MESSAGES}.{i}.{MESSAGE_CONTENT}.{block_index}.{MESSAGE_CONTENT_TEXT}", block.text
690
692
  elif isinstance(block, dict):
691
693
  block_type = block.get("type")
692
694
  if block_type == "tool_use":
@@ -720,7 +722,8 @@ def _get_llm_input_messages(messages: List[Dict[str, str]]) -> Any:
720
722
  ),
721
723
  )
722
724
  elif block_type == "text":
723
- yield f"{LLM_INPUT_MESSAGES}.{i}.{MESSAGE_CONTENT}", block.get(
725
+ yield f"{LLM_INPUT_MESSAGES}.{i}.{MESSAGE_CONTENT}.{block_index}.{MESSAGE_CONTENT_TYPE}", "text"
726
+ yield f"{LLM_INPUT_MESSAGES}.{i}.{MESSAGE_CONTENT}.{block_index}.{MESSAGE_CONTENT_TEXT}", block.get(
724
727
  "text"
725
728
  )
726
729
 
@@ -840,3 +843,6 @@ LLM_PROVIDER = SpanAttributes.LLM_PROVIDER
840
843
  LLM_SYSTEM = SpanAttributes.LLM_SYSTEM
841
844
  LLM_PROVIDER_ANTHROPIC = FiLLMProviderValues.ANTHROPIC.value
842
845
  LLM_SYSTEM_ANTHROPIC = FiLLMSystemValues.ANTHROPIC.value
846
+ MESSAGE_CONTENT_TEXT = MessageContentAttributes.MESSAGE_CONTENT_TEXT
847
+ MESSAGE_CONTENT_IMAGE = MessageContentAttributes.MESSAGE_CONTENT_IMAGE
848
+ MESSAGE_CONTENT_TYPE = MessageContentAttributes.MESSAGE_CONTENT_TYPE
@@ -35,6 +35,7 @@ from fi.integrations.otel.instrumentation import (
35
35
  )
36
36
  from fi.integrations.otel.types import (
37
37
  DocumentAttributes,
38
+ EmbeddingAttributes,
38
39
  FiMimeTypeValues,
39
40
  FiSpanKindValues,
40
41
  MessageAttributes,
@@ -134,6 +135,13 @@ class DSPyInstrumentor(BaseInstrumentor): # type: ignore
134
135
  args=(_AdapterCallWrapper(self._tracer),),
135
136
  )
136
137
 
138
+ wrap_object(
139
+ module=_DSPY_MODULE,
140
+ name="Embedder.__call__",
141
+ factory=CopyableFunctionWrapper,
142
+ args=(_EmbedderCallWrapper(self._tracer),),
143
+ )
144
+
137
145
  def _uninstrument(self, **kwargs: Any) -> None:
138
146
  from dsp.modules.lm import LM
139
147
 
@@ -559,6 +567,55 @@ class _AdapterCallWrapper(_WithTracer):
559
567
  return response
560
568
 
561
569
 
570
+ class _EmbedderCallWrapper(_WithTracer):
571
+ """
572
+ Wrapper for __call__ method on dspy.Embedder
573
+ """
574
+
575
+ def __call__(
576
+ self,
577
+ wrapped: Callable[..., Any],
578
+ instance: Any,
579
+ args: Tuple[Any, ...],
580
+ kwargs: Mapping[str, Any],
581
+ ) -> Any:
582
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
583
+ return wrapped(*args, **kwargs)
584
+
585
+ arguments = _bind_arguments(wrapped, *args, **kwargs)
586
+ input_texts = arguments.get("texts") or args[0] # Get input texts
587
+ span_name = instance.__class__.__name__ + ".__call__"
588
+
589
+ with self._tracer.start_as_current_span(
590
+ span_name,
591
+ attributes=dict(
592
+ _flatten(
593
+ {
594
+ FI_SPAN_KIND: EMBEDDING,
595
+ INPUT_VALUE: safe_json_dumps(input_texts),
596
+ INPUT_MIME_TYPE: TEXT,
597
+ **dict(_raw_input(arguments)),
598
+ **dict(_embedder_model_name(instance)),
599
+ **dict(get_attributes_from_context()),
600
+ **dict(_get_embedding_input(input_texts)),
601
+ }
602
+ )
603
+ ),
604
+ ) as span:
605
+ response = wrapped(*args, **kwargs)
606
+ span.set_status(StatusCode.OK)
607
+ span.set_attributes(
608
+ dict(
609
+ _flatten(
610
+ {
611
+ **dict(_get_embedding_output(response)),
612
+ }
613
+ )
614
+ )
615
+ )
616
+ return response
617
+
618
+
562
619
  class DSPyJSONEncoder(json.JSONEncoder):
563
620
  """
564
621
  Provides support for non-JSON-serializable objects in DSPy.
@@ -786,9 +843,35 @@ def _bind_arguments(
786
843
  return bound_args.arguments
787
844
 
788
845
 
846
+ def _get_embedding_input(inputs: list) -> Iterator[Tuple[str, Any]]:
847
+ for index, embedding_text in enumerate(inputs):
848
+ yield f"{EMBEDDING_EMBEDDINGS}.{index}.{EMBEDDING_TEXT}", embedding_text
849
+
850
+
851
+ def _get_embedding_output(response: list) -> Iterator[Tuple[str, Any]]:
852
+ output = []
853
+ for index, embedding in enumerate(response):
854
+ embedding_vector = embedding.tolist()
855
+ yield f"{EMBEDDING_EMBEDDINGS}.{index}.{EMBEDDING_VECTOR}", embedding_vector
856
+ output.append(embedding_vector)
857
+
858
+ yield EMBEDDING_EMBEDDINGS, safe_json_dumps(output)
859
+ yield OUTPUT_MIME_TYPE, JSON
860
+ yield OUTPUT_VALUE, safe_json_dumps(safe_json_dumps(output))
861
+
862
+ raw_output = {"embeddings": output}
863
+ yield RAW_OUTPUT, safe_json_dumps(raw_output)
864
+
865
+
866
+ def _embedder_model_name(embedder: Any) -> Iterator[Tuple[str, Any]]:
867
+ if (model_name := getattr(embedder, "name", None)) is not None:
868
+ yield "embedder.model_name", model_name
869
+
870
+
789
871
  JSON = FiMimeTypeValues.JSON.value
790
872
  TEXT = FiMimeTypeValues.TEXT.value
791
873
  LLM = FiSpanKindValues.LLM
874
+ EMBEDDING = FiSpanKindValues.EMBEDDING
792
875
  FI_SPAN_KIND = SpanAttributes.FI_SPAN_KIND
793
876
  RETRIEVER = FiSpanKindValues.RETRIEVER
794
877
  CHAIN = FiSpanKindValues.CHAIN.value
@@ -808,3 +891,6 @@ LLM_PROMPTS = SpanAttributes.LLM_PROMPTS
808
891
  RETRIEVAL_DOCUMENTS = SpanAttributes.RETRIEVAL_DOCUMENTS
809
892
  MESSAGE_CONTENT = MessageAttributes.MESSAGE_CONTENT
810
893
  MESSAGE_ROLE = MessageAttributes.MESSAGE_ROLE
894
+ EMBEDDING_EMBEDDINGS = SpanAttributes.EMBEDDING_EMBEDDINGS
895
+ EMBEDDING_TEXT = EmbeddingAttributes.EMBEDDING_TEXT
896
+ EMBEDDING_VECTOR = EmbeddingAttributes.EMBEDDING_VECTOR
@@ -0,0 +1,28 @@
1
+ import dspy
2
+
3
+ from fi.integrations.otel import DSPyInstrumentor, register
4
+ from fi.integrations.otel.types import (
5
+ EvalName,
6
+ EvalSpanKind,
7
+ EvalTag,
8
+ EvalTagType,
9
+ ProjectType,
10
+ )
11
+
12
+ # Configure trace provider with custom evaluation tags
13
+ trace_provider = register(
14
+ project_type=ProjectType.EXPERIMENT,
15
+ project_name="FUTURE_AGI",
16
+ project_version_name="v1",
17
+ )
18
+
19
+ # Instrument DSPy with the trace provider
20
+ DSPyInstrumentor().instrument(tracer_provider=trace_provider)
21
+
22
+
23
+ embedder = dspy.Embedder("openai/text-embedding-3-small", batch_size=100)
24
+ embeddings = embedder(
25
+ ["hello", "world", "asre"],
26
+ )
27
+
28
+ # print("Embedding for 'hello':", embeddings[0].tolist())
@@ -13,6 +13,7 @@ from fi.integrations.otel.instrumentation import safe_json_dumps
13
13
  from fi.integrations.otel.types import (
14
14
  FiSpanKindValues,
15
15
  MessageAttributes,
16
+ MessageContentAttributes,
16
17
  SpanAttributes,
17
18
  ToolCallAttributes,
18
19
  )
@@ -70,10 +71,7 @@ class _RequestAttributesExtractor:
70
71
  if (input_messages := request_parameters.get("messages")) and isinstance(
71
72
  input_messages, Iterable
72
73
  ):
73
- for index, input_message in reversed(list(enumerate(input_messages))):
74
- # Use reversed() to get the last message first. This is because OTEL has a default
75
- # limit of 128 attributes per span, and flattening increases the number of
76
- # attributes very quickly.
74
+ for index, input_message in list(enumerate(input_messages)):
77
75
  for key, value in self._get_attributes_from_message_param(
78
76
  input_message
79
77
  ):
@@ -89,10 +87,16 @@ class _RequestAttributesExtractor:
89
87
  role.value if isinstance(role, Enum) else role,
90
88
  )
91
89
  if content := get_attribute(message, "content"):
92
- yield (
93
- MessageAttributes.MESSAGE_CONTENT,
94
- content,
95
- )
90
+ if isinstance(content, str):
91
+ yield (
92
+ MessageAttributes.MESSAGE_CONTENT,
93
+ content,
94
+ )
95
+ elif isinstance(content, Iterable):
96
+ for index, c in list(enumerate(content)):
97
+ for key, value in self._get_attributes_from_message_content(c):
98
+ yield f"{MessageAttributes.MESSAGE_CONTENTS}.{index}.{key}", value
99
+
96
100
  if name := get_attribute(message, "name"):
97
101
  yield MessageAttributes.MESSAGE_NAME, name
98
102
 
@@ -133,6 +137,22 @@ class _RequestAttributesExtractor:
133
137
  arguments,
134
138
  )
135
139
 
140
+ def _get_attributes_from_message_content(
141
+ self,
142
+ content: Mapping[str, Any],
143
+ ) -> Iterator[Tuple[str, AttributeValue]]:
144
+ content = dict(content)
145
+ type_ = content.pop("type")
146
+ if type_ == "text":
147
+ yield f"{MessageContentAttributes.MESSAGE_CONTENT_TYPE}", "text"
148
+ if text := content.pop("text"):
149
+ yield f"{MessageContentAttributes.MESSAGE_CONTENT_TEXT}", text
150
+ # elif type_ == "image_url":
151
+ # yield f"{MessageContentAttributes.MESSAGE_CONTENT_TYPE}", "image"
152
+ # if image := content.pop("image_url"):
153
+ # for key, value in self._get_attributes_from_image(image):
154
+ # yield f"{MessageContentAttributes.MESSAGE_CONTENT_IMAGE}.{key}", value
155
+
136
156
 
137
157
  T = TypeVar("T", bound=type)
138
158
 
@@ -168,7 +168,6 @@ class FiTracer(BaseTracer):
168
168
  # "input": cleaned_input,
169
169
  "output": cleaned_output,
170
170
  }
171
- print(f"Sending span data to API from FiTracer: {span_data}")
172
171
 
173
172
  # if cleaned_input is not None:
174
173
  # span.set_attributes({"fi.llm.input": str(cleaned_input)})
@@ -30,6 +30,7 @@ trace_provider = register(
30
30
  # Initialize the LangChain instrumentor
31
31
  LangChainInstrumentor().instrument(tracer_provider=trace_provider)
32
32
 
33
+
33
34
  # Define the reflection model for scoring responses
34
35
  class Reflection(BaseModel):
35
36
  reflections: str = Field(
@@ -0,0 +1,102 @@
1
+ import os
2
+
3
+ from langchain.embeddings import OpenAIEmbeddings
4
+ from langchain.retrievers import ContextualCompressionRetriever
5
+ from langchain.retrievers.document_compressors import CohereRerank
6
+ from langchain.schema import Document
7
+ from langchain.text_splitter import CharacterTextSplitter
8
+ from langchain.vectorstores import FAISS
9
+
10
+ from fi.integrations.otel import LangChainInstrumentor, register
11
+ from fi.integrations.otel.types import ProjectType
12
+
13
+ trace_provider = register(
14
+ project_type=ProjectType.EXPERIMENT,
15
+ project_name="SQL_AGENT",
16
+ project_version_name="V1",
17
+ )
18
+
19
+ LangChainInstrumentor().instrument(tracer_provider=trace_provider)
20
+
21
+ sample_docs = [
22
+ Document(
23
+ page_content="Artificial Intelligence (AI) is the simulation of human intelligence by machines. "
24
+ "It includes machine learning, natural language processing, and robotics. "
25
+ "AI systems can learn from experience, adjust to new inputs, and perform human-like tasks.",
26
+ metadata={"source": "AI Introduction"},
27
+ ),
28
+ Document(
29
+ page_content="Machine Learning is a subset of AI that enables systems to learn and improve "
30
+ "from experience without being explicitly programmed. Popular ML algorithms include "
31
+ "neural networks, decision trees, and random forests.",
32
+ metadata={"source": "ML Basics"},
33
+ ),
34
+ Document(
35
+ page_content="Python is a high-level programming language known for its simplicity and readability. "
36
+ "It's widely used in data science, web development, and automation. Python has a rich ecosystem "
37
+ "of libraries and frameworks.",
38
+ metadata={"source": "Python Guide"},
39
+ ),
40
+ Document(
41
+ page_content="Deep Learning is a type of machine learning based on artificial neural networks. "
42
+ "It's particularly effective in tasks like image recognition, natural language processing, "
43
+ "and speech recognition.",
44
+ metadata={"source": "Deep Learning Info"},
45
+ ),
46
+ Document(
47
+ page_content="Data Science combines statistics, programming, and domain expertise to extract "
48
+ "meaningful insights from data. It involves data collection, cleaning, analysis, and visualization. "
49
+ "Python is a popular language for data science.",
50
+ metadata={"source": "Data Science Overview"},
51
+ ),
52
+ ]
53
+
54
+
55
+ def create_vector_store(documents):
56
+ """Create a FAISS vector store from documents."""
57
+ embeddings = OpenAIEmbeddings()
58
+ vector_store = FAISS.from_documents(documents, embeddings)
59
+ return vector_store
60
+
61
+
62
+ def setup_reranker():
63
+ """Setup the Cohere reranker."""
64
+ compressor = CohereRerank(
65
+ model="rerank-english-v2.0", top_n=3 # Reduced to 3 for this example
66
+ )
67
+ return compressor
68
+
69
+
70
+ def main():
71
+ # Create vector store directly from sample documents
72
+ vector_store = create_vector_store(sample_docs)
73
+ base_retriever = vector_store.as_retriever(search_kwargs={"k": 5})
74
+
75
+ # Setup reranker
76
+ compressor = setup_reranker()
77
+
78
+ # Create compression retriever
79
+ compression_retriever = ContextualCompressionRetriever(
80
+ base_compressor=compressor, base_retriever=base_retriever
81
+ )
82
+
83
+ # Example queries
84
+ queries = [
85
+ "What is artificial intelligence?",
86
+ "How is Python used in data science?",
87
+ "Explain machine learning",
88
+ ]
89
+
90
+ # Get and print results for each query
91
+ for query in queries:
92
+ # print(f"\nQuery: {query}")
93
+ # print("\nReranked Results:")
94
+ compressed_docs = compression_retriever.get_relevant_documents(query)
95
+ for i, doc in enumerate(compressed_docs, 1):
96
+ print(f"\n{i}. Source: {doc.metadata['source']}")
97
+ print(f" Content: {doc.page_content}")
98
+ print("\n" + "=" * 50)
99
+
100
+
101
+ if __name__ == "__main__":
102
+ main()
@@ -162,7 +162,9 @@ def _instrument_func_type_embedding(
162
162
  span, SpanAttributes.EMBEDDING_MODEL_NAME, kwargs.get("model", "unknown_model")
163
163
  )
164
164
  _set_span_attribute(
165
- span, EmbeddingAttributes.EMBEDDING_TEXT, str(kwargs.get("input"))
165
+ span,
166
+ f"{SpanAttributes.EMBEDDING_EMBEDDINGS}.{0}.{EmbeddingAttributes.EMBEDDING_TEXT}",
167
+ str(kwargs.get("input")),
166
168
  )
167
169
  _set_span_attribute(span, SpanAttributes.INPUT_VALUE, str(kwargs.get("input")))
168
170
 
@@ -200,7 +202,7 @@ def _finalize_span(span: trace_api.Span, result: Any) -> None:
200
202
  first_embedding = result_data[0]
201
203
  _set_span_attribute(
202
204
  span,
203
- EmbeddingAttributes.EMBEDDING_VECTOR,
205
+ f"{SpanAttributes.EMBEDDING_EMBEDDINGS}.{0}.{EmbeddingAttributes.EMBEDDING_VECTOR}",
204
206
  json.dumps(first_embedding.get("embedding", [])),
205
207
  )
206
208
  _set_span_attribute(
@@ -36,8 +36,33 @@ eval_tags = [
36
36
  def simple_completion():
37
37
  return litellm.completion(
38
38
  model="gpt-3.5-turbo",
39
- messages=[{"content": "What's the capital of China?", "role": "user"}],
40
- stream=True,
39
+ messages=[
40
+ {
41
+ "content": "What's the capital of China? Get the weather there.",
42
+ "role": "user",
43
+ }
44
+ ],
45
+ tools=[
46
+ {
47
+ "type": "function",
48
+ "function": {
49
+ "name": "get_weather",
50
+ "description": "Get the current weather in a given location",
51
+ "parameters": {
52
+ "type": "object",
53
+ "properties": {
54
+ "location": {
55
+ "type": "string",
56
+ "description": "The city name",
57
+ }
58
+ },
59
+ "required": ["location"],
60
+ },
61
+ },
62
+ }
63
+ ],
64
+ tool_choice="auto",
65
+ stream=False,
41
66
  )
42
67
 
43
68
 
@@ -0,0 +1,36 @@
1
+ from litellm import rerank
2
+
3
+ from fi.integrations.otel import LiteLLMInstrumentor, register
4
+ from fi.integrations.otel.types import (
5
+ EvalName,
6
+ EvalSpanKind,
7
+ EvalTag,
8
+ EvalTagType,
9
+ ProjectType,
10
+ )
11
+
12
+ trace_provider = register(
13
+ project_type=ProjectType.EXPERIMENT,
14
+ project_name="FUTURE_AGI",
15
+ project_version_name="v1",
16
+ )
17
+
18
+ # Initialize the Lite LLM instrumentor
19
+ LiteLLMInstrumentor().instrument(tracer_provider=trace_provider)
20
+
21
+
22
+ query = "What is the capital of the United States?"
23
+ documents = [
24
+ "Carson City is the capital city of the American state of Nevada.",
25
+ "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
26
+ "Washington, D.C. is the capital of the United States.",
27
+ "Capital punishment has existed in the United States since before it was a country.",
28
+ ]
29
+
30
+ response = rerank(
31
+ model="cohere/rerank-english-v3.0",
32
+ query=query,
33
+ documents=documents,
34
+ top_n=3,
35
+ )
36
+ print(response)
@@ -0,0 +1,76 @@
1
+ import os
2
+
3
+ import requests
4
+ from llama_index.core import Document, VectorStoreIndex
5
+ from llama_index.postprocessor.cohere_rerank import CohereRerank
6
+
7
+ from fi.integrations.otel import LlamaIndexInstrumentor, register
8
+ from fi.integrations.otel.types import (
9
+ EvalName,
10
+ EvalSpanKind,
11
+ EvalTag,
12
+ EvalTagType,
13
+ ProjectType,
14
+ )
15
+
16
+ # Configure trace provider with custom evaluation tags
17
+ trace_provider = register(
18
+ project_type=ProjectType.EXPERIMENT,
19
+ project_name="FUTURE_AGI",
20
+ project_version_name="v1",
21
+ )
22
+ # Initialize the Llama Index instrumentor
23
+ LlamaIndexInstrumentor().instrument(tracer_provider=trace_provider)
24
+
25
+
26
+ def pprint_response(response, show_source=True):
27
+ """Pretty print the response and sources."""
28
+ print("Final Response:", response.response)
29
+ if show_source:
30
+ print("_" * 70)
31
+ for idx, source_node in enumerate(response.source_nodes):
32
+ print(f"Source Node {idx + 1}/{len(response.source_nodes)}")
33
+ print(f"Node ID: {source_node.node.node_id}")
34
+ print(f"Similarity: {source_node.score:.8f}")
35
+ print(f"Text: {source_node.node.text}")
36
+ print("_" * 70)
37
+
38
+
39
+ def main():
40
+ # Load document directly from URL using requests
41
+ url = "https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt"
42
+ response = requests.get(url)
43
+ text_content = response.text
44
+
45
+ # Create a Document object
46
+ documents = [Document(text=text_content)]
47
+
48
+ # Build index
49
+ index = VectorStoreIndex.from_documents(documents=documents)
50
+
51
+ # Example 1: With Cohere Rerank
52
+ print("\nExample 1: Using Cohere Rerank")
53
+ api_key = os.environ["COHERE_API_KEY"]
54
+ cohere_rerank = CohereRerank(api_key=api_key, top_n=2)
55
+ query_engine_rerank = index.as_query_engine(
56
+ similarity_top_k=10,
57
+ node_postprocessors=[cohere_rerank],
58
+ )
59
+ response_rerank = query_engine_rerank.query(
60
+ "What did Sam Altman do in this essay?",
61
+ )
62
+ pprint_response(response_rerank, show_source=True)
63
+
64
+ # Example 2: Without Cohere Rerank
65
+ print("\nExample 2: Direct Retrieval without Rerank")
66
+ query_engine_direct = index.as_query_engine(
67
+ similarity_top_k=2,
68
+ )
69
+ response_direct = query_engine_direct.query(
70
+ "What did Sam Altman do in this essay?",
71
+ )
72
+ pprint_response(response_direct, show_source=True)
73
+
74
+
75
+ if __name__ == "__main__":
76
+ main()
@@ -0,0 +1,64 @@
1
+ from llama_index import SimpleDirectoryReader, VectorStoreIndex
2
+ from llama_index.postprocessor import SimilarityPostprocessor
3
+ from llama_index.query_engine import RetrieverQueryEngine
4
+ from llama_index.retrievers import VectorIndexRetriever
5
+
6
+
7
+ def create_index(documents_path):
8
+ # Load documents from the specified directory
9
+ documents = SimpleDirectoryReader(documents_path).load_data()
10
+
11
+ # Create a vector store index
12
+ index = VectorStoreIndex.from_documents(documents)
13
+ return index
14
+
15
+
16
+ def setup_retriever_engine(index, similarity_cutoff=0.7, top_k=10):
17
+ # Configure the retriever
18
+ retriever = VectorIndexRetriever(index=index, similarity_top_k=top_k)
19
+
20
+ # Create a similarity postprocessor for reranking
21
+ postprocessor = SimilarityPostprocessor(similarity_cutoff=similarity_cutoff)
22
+
23
+ # Create the query engine with the retriever and postprocessor
24
+ query_engine = RetrieverQueryEngine(
25
+ retriever=retriever, node_postprocessors=[postprocessor]
26
+ )
27
+
28
+ return query_engine
29
+
30
+
31
+ def search_and_rerank(query_engine, query_text):
32
+ # Perform the search and reranking
33
+ response = query_engine.query(query_text)
34
+
35
+ # Get source nodes (retrieved documents)
36
+ source_nodes = response.source_nodes
37
+
38
+ # Print results
39
+ print(f"\nQuery: {query_text}")
40
+ print("\nRanked Results:")
41
+ for idx, node in enumerate(source_nodes, 1):
42
+ print(f"\n{idx}. Score: {node.score:.4f}")
43
+ print(f"Text: {node.node.text[:200]}...") # Show first 200 chars
44
+
45
+
46
+ def main():
47
+ # Initialize the system
48
+ documents_path = "path/to/your/documents"
49
+ index = create_index(documents_path)
50
+ query_engine = setup_retriever_engine(index, similarity_cutoff=0.7, top_k=5)
51
+
52
+ # Example queries
53
+ queries = [
54
+ "What is machine learning?",
55
+ "How does natural language processing work?",
56
+ ]
57
+
58
+ # Process each query
59
+ for query in queries:
60
+ search_and_rerank(query_engine, query)
61
+
62
+
63
+ if __name__ == "__main__":
64
+ main()
@@ -8,6 +8,7 @@ from opentelemetry.util.types import AttributeValue
8
8
  from fi.integrations.otel.instrumentation import safe_json_dumps
9
9
  from fi.integrations.otel.types import (
10
10
  MessageAttributes,
11
+ MessageContentAttributes,
11
12
  SpanAttributes,
12
13
  ToolCallAttributes,
13
14
  )
@@ -72,12 +73,10 @@ def _get_attributes_from_message_param(
72
73
  if isinstance(content, str):
73
74
  yield MessageAttributes.MESSAGE_CONTENT, content
74
75
  elif isinstance(content, List):
75
- try:
76
- json_string = safe_json_dumps(content)
77
- except Exception:
78
- logger.exception("Failed to serialize message content")
79
- else:
80
- yield MessageAttributes.MESSAGE_CONTENT, json_string
76
+ for index, c in enumerate(content):
77
+ for key, value in _get_attributes_from_message_content(c):
78
+ yield f"{MessageAttributes.MESSAGE_CONTENTS}.{index}.{key}", value
79
+
81
80
  if name := message.get("name"):
82
81
  yield MessageAttributes.MESSAGE_NAME, name
83
82
  if (function_call := message.get("function_call")) and hasattr(
@@ -107,3 +106,21 @@ def _get_attributes_from_message_param(
107
106
  f"{ToolCallAttributes.TOOL_CALL_FUNCTION_ARGUMENTS_JSON}",
108
107
  arguments,
109
108
  )
109
+
110
+
111
+ def _get_attributes_from_message_content(
112
+ content: Mapping[str, Any],
113
+ ) -> Iterator[Tuple[str, AttributeValue]]:
114
+ if not hasattr(content, "get"):
115
+ return
116
+ content_dict = dict(content)
117
+ type_ = content_dict.pop("type", None)
118
+ if type_ == "text":
119
+ yield f"{MessageContentAttributes.MESSAGE_CONTENT_TYPE}", "text"
120
+ if text := content_dict.get("text"):
121
+ yield f"{MessageContentAttributes.MESSAGE_CONTENT_TEXT}", text
122
+ # elif type_ == "image_url":
123
+ # yield f"{MessageContentAttributes.MESSAGE_CONTENT_TYPE}", "image"
124
+ # if image := content_dict.get("image_url"):
125
+ # for key, value in _get_attributes_from_image(image):
126
+ # yield f"{MessageContentAttributes.MESSAGE_CONTENT_IMAGE}.{key}", value