langtrace-python-sdk 2.3.21__tar.gz → 2.3.27__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/PKG-INFO +15 -3
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/README.md +10 -1
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/pyproject.toml +4 -2
- langtrace_python_sdk-2.3.27/src/examples/dspy_example/optimizers/bootstrap_fewshot.py +89 -0
- langtrace_python_sdk-2.3.27/src/examples/openai_example/chat_completion.py +47 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/common.py +1 -0
- langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/constants/instrumentation/litellm.py +18 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/__init__.py +2 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/dspy/patch.py +18 -8
- langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/instrumentation/litellm/__init__.py +5 -0
- langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/instrumentation/litellm/instrumentation.py +87 -0
- langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/instrumentation/litellm/patch.py +651 -0
- langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/instrumentation/openai/types.py +170 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/langtrace.py +10 -2
- langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/version.py +1 -0
- langtrace_python_sdk-2.3.21/src/examples/openai_example/chat_completion.py +0 -44
- langtrace_python_sdk-2.3.21/src/langtrace_python_sdk/version.py +0 -1
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/.gitignore +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/LICENSE +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/anthropic_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/anthropic_example/completion.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/autogen_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/autogen_example/main.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/azureopenai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/azureopenai_example/completion.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/chroma_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/chroma_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/cohere_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/cohere_example/chat.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/cohere_example/chat_stream.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/cohere_example/embed.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/cohere_example/rerank.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/cohere_example/tools.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/instagram_post/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/instagram_post/agents.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/instagram_post/main.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/instagram_post/tasks.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/instagram_post/tools/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/instagram_post/tools/browser_tools.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/simple_agent/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/simple_agent/agents.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/simple_agent/main.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/simple_agent/tasks.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/trip_planner/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/trip_planner/agents.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/trip_planner/main.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/trip_planner/tasks.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/trip_planner/tools/calculator.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/crewai_example/trip_planner/tools/search_tools.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/QA_basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/QA_basic_with_chain_of_thought.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/QA_basic_with_signature.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/math_problems_cot.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/math_problems_cot_parallel.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/program_of_thought_basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/quiz_gen.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/dspy_example/react.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/embedchain_example/simple.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/fastapi_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/fastapi_example/basic_route.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/gemini_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/gemini_example/function_tools.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/gemini_example/main.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/hiveagent_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/inspect_ai_example/basic_eval.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/groq_example.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/langchain_google_example.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/langgraph_example.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/langgraph_example_tools.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/sagemaker.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/langchain_example/tool.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/litellm_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/llamaindex_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/llamaindex_example/agent.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/llamaindex_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/llamaindex_example/data/abramov.txt +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/mistral_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/mistral_example/complete.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/mistral_example/complete_async.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/mistral_example/embeddings.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/ollama_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/ollama_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/chat_completion_tool_choice.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/embeddings_create.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/function_calling.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/images_edit.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/images_generate.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/resources/mask.png +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/send_user_feedback.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/tool_calling.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/openai_example/tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/otlp_example/otlp_basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/otlp_example/otlp_with_langtrace.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/perplexity_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/pinecone_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/pinecone_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/qdrant_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/qdrant_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/routellm_example/basic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/vertexai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/vertexai_example/main.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/weaviate_example/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/examples/weaviate_example/query_text.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/embedchain.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/gemini.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/mistral.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/vertexai.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/anthropic/types.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/autogen/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/autogen/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/autogen/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/crewai/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/crewai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/crewai/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/embedchain/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/embedchain/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/embedchain/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/gemini/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/gemini/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/gemini/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
- {langtrace_python_sdk-2.3.21/src/langtrace_python_sdk/instrumentation/openai → langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/instrumentation/litellm}/types.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/mistral/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/mistral/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/mistral/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/vertexai/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/vertexai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/vertexai/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/types/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/llm.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/misc.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/types.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/run_example.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/__init__.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/anthropic/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/anthropic/test_anthropic.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/chroma/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/chroma/test_chroma.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/test_cohere_chat.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/test_cohere_embed.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/cohere/test_cohere_rerank.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/groq/cassettes/test_async_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/groq/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/groq/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/groq/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/groq/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/groq/test_groq.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/langchain/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/langchain/test_langchain.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/test_chat_completion.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/test_embeddings.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/openai/test_image_generation.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/pinecone/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/pinecone/test_pinecone.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/qdrant/conftest.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/qdrant/test_qdrant.py +0 -0
- {langtrace_python_sdk-2.3.21 → langtrace_python_sdk-2.3.27}/src/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: langtrace-python-sdk
|
3
|
-
Version: 2.3.
|
3
|
+
Version: 2.3.27
|
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>
|
@@ -23,6 +23,7 @@ Requires-Dist: sqlalchemy
|
|
23
23
|
Requires-Dist: tiktoken>=0.1.1
|
24
24
|
Requires-Dist: trace-attributes==7.0.4
|
25
25
|
Requires-Dist: transformers>=4.11.3
|
26
|
+
Requires-Dist: ujson>=5.10.0
|
26
27
|
Provides-Extra: dev
|
27
28
|
Requires-Dist: anthropic; extra == 'dev'
|
28
29
|
Requires-Dist: chromadb; extra == 'dev'
|
@@ -34,12 +35,14 @@ Requires-Dist: groq; extra == 'dev'
|
|
34
35
|
Requires-Dist: langchain; extra == 'dev'
|
35
36
|
Requires-Dist: langchain-community; extra == 'dev'
|
36
37
|
Requires-Dist: langchain-openai; extra == 'dev'
|
38
|
+
Requires-Dist: litellm==1.48.7; extra == 'dev'
|
37
39
|
Requires-Dist: mistralai; extra == 'dev'
|
38
40
|
Requires-Dist: ollama; extra == 'dev'
|
39
|
-
Requires-Dist: openai==1.
|
41
|
+
Requires-Dist: openai==1.45.0; extra == 'dev'
|
40
42
|
Requires-Dist: pinecone-client; extra == 'dev'
|
41
43
|
Requires-Dist: python-dotenv; extra == 'dev'
|
42
44
|
Requires-Dist: qdrant-client; extra == 'dev'
|
45
|
+
Requires-Dist: typing-extensions; extra == 'dev'
|
43
46
|
Requires-Dist: weaviate-client; extra == 'dev'
|
44
47
|
Provides-Extra: test
|
45
48
|
Requires-Dist: pytest; extra == 'test'
|
@@ -287,6 +290,14 @@ By default, prompt and completion data are captured. If you would like to opt ou
|
|
287
290
|
|
288
291
|
`TRACE_PROMPT_COMPLETION_DATA=false`
|
289
292
|
|
293
|
+
### Enable/Disable checkpoint tracing for DSPy
|
294
|
+
|
295
|
+
By default, checkpoints are traced for DSPy pipelines. If you would like to disable it, set the following env var,
|
296
|
+
|
297
|
+
`TRACE_DSPY_CHECKPOINT=false`
|
298
|
+
|
299
|
+
Note: Checkpoint tracing will increase the latency of executions as the state is serialized. Please disable it in production.
|
300
|
+
|
290
301
|
## Supported integrations
|
291
302
|
|
292
303
|
Langtrace automatically captures traces from the following vendors:
|
@@ -302,8 +313,9 @@ Langtrace automatically captures traces from the following vendors:
|
|
302
313
|
| Gemini | LLM | :x: | :white_check_mark: |
|
303
314
|
| Mistral | LLM | :x: | :white_check_mark: |
|
304
315
|
| Langchain | Framework | :x: | :white_check_mark: |
|
305
|
-
| LlamaIndex | Framework | :white_check_mark: | :white_check_mark: |
|
306
316
|
| Langgraph | Framework | :x: | :white_check_mark: |
|
317
|
+
| LlamaIndex | Framework | :white_check_mark: | :white_check_mark: |
|
318
|
+
| LiteLLM | Framework | :x: | :white_check_mark: |
|
307
319
|
| DSPy | Framework | :x: | :white_check_mark: |
|
308
320
|
| CrewAI | Framework | :x: | :white_check_mark: |
|
309
321
|
| Ollama | Framework | :x: | :white_check_mark: |
|
@@ -238,6 +238,14 @@ By default, prompt and completion data are captured. If you would like to opt ou
|
|
238
238
|
|
239
239
|
`TRACE_PROMPT_COMPLETION_DATA=false`
|
240
240
|
|
241
|
+
### Enable/Disable checkpoint tracing for DSPy
|
242
|
+
|
243
|
+
By default, checkpoints are traced for DSPy pipelines. If you would like to disable it, set the following env var,
|
244
|
+
|
245
|
+
`TRACE_DSPY_CHECKPOINT=false`
|
246
|
+
|
247
|
+
Note: Checkpoint tracing will increase the latency of executions as the state is serialized. Please disable it in production.
|
248
|
+
|
241
249
|
## Supported integrations
|
242
250
|
|
243
251
|
Langtrace automatically captures traces from the following vendors:
|
@@ -253,8 +261,9 @@ Langtrace automatically captures traces from the following vendors:
|
|
253
261
|
| Gemini | LLM | :x: | :white_check_mark: |
|
254
262
|
| Mistral | LLM | :x: | :white_check_mark: |
|
255
263
|
| Langchain | Framework | :x: | :white_check_mark: |
|
256
|
-
| LlamaIndex | Framework | :white_check_mark: | :white_check_mark: |
|
257
264
|
| Langgraph | Framework | :x: | :white_check_mark: |
|
265
|
+
| LlamaIndex | Framework | :white_check_mark: | :white_check_mark: |
|
266
|
+
| LiteLLM | Framework | :x: | :white_check_mark: |
|
258
267
|
| DSPy | Framework | :x: | :white_check_mark: |
|
259
268
|
| CrewAI | Framework | :x: | :white_check_mark: |
|
260
269
|
| Ollama | Framework | :x: | :white_check_mark: |
|
@@ -31,13 +31,14 @@ dependencies = [
|
|
31
31
|
'fsspec>=2024.6.0',
|
32
32
|
"transformers>=4.11.3",
|
33
33
|
"sentry-sdk>=2.14.0",
|
34
|
+
"ujson>=5.10.0",
|
34
35
|
]
|
35
36
|
|
36
37
|
requires-python = ">=3.9"
|
37
38
|
|
38
39
|
[project.optional-dependencies]
|
39
40
|
dev = [
|
40
|
-
"openai==1.
|
41
|
+
"openai==1.45.0",
|
41
42
|
"anthropic",
|
42
43
|
"chromadb",
|
43
44
|
"qdrant-client",
|
@@ -46,7 +47,7 @@ dev = [
|
|
46
47
|
"langchain",
|
47
48
|
"langchain-community",
|
48
49
|
"langchain-openai",
|
49
|
-
"
|
50
|
+
"litellm==1.48.7",
|
50
51
|
"chromadb",
|
51
52
|
"cohere",
|
52
53
|
"qdrant_client",
|
@@ -57,6 +58,7 @@ dev = [
|
|
57
58
|
"google-cloud-aiplatform",
|
58
59
|
"mistralai",
|
59
60
|
"embedchain",
|
61
|
+
"typing-extensions",
|
60
62
|
]
|
61
63
|
|
62
64
|
test = ["pytest", "pytest-vcr", "pytest-asyncio"]
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import dspy
|
2
|
+
from dotenv import find_dotenv, load_dotenv
|
3
|
+
from dspy.datasets import HotPotQA
|
4
|
+
from dspy.teleprompt import BootstrapFewShot
|
5
|
+
|
6
|
+
from langtrace_python_sdk import inject_additional_attributes, langtrace
|
7
|
+
|
8
|
+
_ = load_dotenv(find_dotenv())
|
9
|
+
|
10
|
+
langtrace.init()
|
11
|
+
|
12
|
+
turbo = dspy.LM('openai/gpt-4o-mini')
|
13
|
+
colbertv2_wiki17_abstracts = dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
|
14
|
+
|
15
|
+
dspy.settings.configure(lm=turbo, rm=colbertv2_wiki17_abstracts)
|
16
|
+
|
17
|
+
|
18
|
+
# Load the dataset.
|
19
|
+
dataset = HotPotQA(train_seed=1, train_size=20, eval_seed=2023, dev_size=50, test_size=0)
|
20
|
+
|
21
|
+
# Tell DSPy that the 'question' field is the input. Any other fields are labels and/or metadata.
|
22
|
+
trainset = [x.with_inputs('question') for x in dataset.train]
|
23
|
+
devset = [x.with_inputs('question') for x in dataset.dev]
|
24
|
+
|
25
|
+
|
26
|
+
class GenerateAnswer(dspy.Signature):
|
27
|
+
"""Answer questions with short factoid answers."""
|
28
|
+
|
29
|
+
context = dspy.InputField(desc="may contain relevant facts")
|
30
|
+
question = dspy.InputField()
|
31
|
+
answer = dspy.OutputField(desc="often between 1 and 5 words")
|
32
|
+
|
33
|
+
|
34
|
+
class RAG(dspy.Module):
|
35
|
+
def __init__(self, num_passages=3):
|
36
|
+
super().__init__()
|
37
|
+
|
38
|
+
self.retrieve = dspy.Retrieve(k=num_passages)
|
39
|
+
self.generate_answer = dspy.ChainOfThought(GenerateAnswer)
|
40
|
+
|
41
|
+
def forward(self, question):
|
42
|
+
context = self.retrieve(question).passages
|
43
|
+
prediction = self.generate_answer(context=context, question=question)
|
44
|
+
return dspy.Prediction(context=context, answer=prediction.answer)
|
45
|
+
|
46
|
+
|
47
|
+
# Validation logic: check that the predicted answer is correct.
|
48
|
+
# Also check that the retrieved context does actually contain that answer.
|
49
|
+
def validate_context_and_answer(example, prediction, trace=None):
|
50
|
+
answer_em = dspy.evaluate.answer_exact_match(example, prediction)
|
51
|
+
answer_pm = dspy.evaluate.answer_passage_match(example, prediction)
|
52
|
+
return answer_em and answer_pm
|
53
|
+
|
54
|
+
|
55
|
+
# Set up a basic optimizer, which will compile our RAG program.
|
56
|
+
optimizer = BootstrapFewShot(metric=validate_context_and_answer)
|
57
|
+
|
58
|
+
# Compile!
|
59
|
+
compiled_rag = optimizer.compile(RAG(), trainset=trainset)
|
60
|
+
|
61
|
+
# Ask any question you like to this simple RAG program.
|
62
|
+
my_question = "Who was the hero of the movie peraanmai?"
|
63
|
+
|
64
|
+
# Get the prediction. This contains `pred.context` and `pred.answer`.
|
65
|
+
# pred = compiled_rag(my_question)
|
66
|
+
pred = inject_additional_attributes(lambda: compiled_rag(my_question), {'experiment': 'experiment 6', 'description': 'trying additional stuff', 'run_id': 'run_1'})
|
67
|
+
# compiled_rag.save('compiled_rag_v1.json')
|
68
|
+
|
69
|
+
# Print the contexts and the answer.
|
70
|
+
print(f"Question: {my_question}")
|
71
|
+
print(f"Predicted Answer: {pred.answer}")
|
72
|
+
print(f"Retrieved Contexts (truncated): {[c[:200] + '...' for c in pred.context]}")
|
73
|
+
|
74
|
+
# print("Inspecting the history of the optimizer:")
|
75
|
+
# turbo.inspect_history(n=1)
|
76
|
+
|
77
|
+
from dspy.evaluate import Evaluate
|
78
|
+
|
79
|
+
|
80
|
+
def validate_answer(example, pred, trace=None):
|
81
|
+
return True
|
82
|
+
|
83
|
+
|
84
|
+
# Set up the evaluator, which can be used multiple times.
|
85
|
+
evaluate = Evaluate(devset=devset, metric=validate_answer, num_threads=4, display_progress=True, display_table=0)
|
86
|
+
|
87
|
+
|
88
|
+
# Evaluate our `optimized_cot` program.
|
89
|
+
evaluate(compiled_rag)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
2
|
+
from openai import OpenAI
|
3
|
+
|
4
|
+
from langtrace_python_sdk import langtrace
|
5
|
+
from langtrace_python_sdk.utils.with_root_span import (
|
6
|
+
with_additional_attributes,
|
7
|
+
with_langtrace_root_span,
|
8
|
+
)
|
9
|
+
|
10
|
+
_ = load_dotenv(find_dotenv())
|
11
|
+
|
12
|
+
langtrace.init()
|
13
|
+
client = OpenAI()
|
14
|
+
|
15
|
+
|
16
|
+
def api():
|
17
|
+
response = client.chat.completions.create(
|
18
|
+
model="o1-mini",
|
19
|
+
messages=[
|
20
|
+
# {"role": "system", "content": "Talk like a pirate"},
|
21
|
+
{"role": "user", "content": "How many r's are in strawberry?"},
|
22
|
+
],
|
23
|
+
# stream=True,
|
24
|
+
stream=False,
|
25
|
+
)
|
26
|
+
return response
|
27
|
+
|
28
|
+
|
29
|
+
@with_langtrace_root_span("Chat Completion")
|
30
|
+
def chat_completion():
|
31
|
+
response = api()
|
32
|
+
# print(response)
|
33
|
+
# Uncomment this for streaming
|
34
|
+
# result = []
|
35
|
+
# for chunk in response:
|
36
|
+
# if chunk.choices[0].delta.content is not None:
|
37
|
+
# content = [
|
38
|
+
# choice.delta.content if choice.delta and choice.delta.content else ""
|
39
|
+
# for choice in chunk.choices
|
40
|
+
# ]
|
41
|
+
# result.append(content[0] if len(content) > 0 else "")
|
42
|
+
|
43
|
+
# # print("".join(result))
|
44
|
+
print(response)
|
45
|
+
return response
|
46
|
+
|
47
|
+
chat_completion()
|
@@ -0,0 +1,18 @@
|
|
1
|
+
APIS = {
|
2
|
+
"CHAT_COMPLETION": {
|
3
|
+
"METHOD": "chat.completions.create",
|
4
|
+
"ENDPOINT": "/chat/completions",
|
5
|
+
},
|
6
|
+
"IMAGES_GENERATION": {
|
7
|
+
"METHOD": "images.generate",
|
8
|
+
"ENDPOINT": "/images/generations",
|
9
|
+
},
|
10
|
+
"IMAGES_EDIT": {
|
11
|
+
"METHOD": "images.edit",
|
12
|
+
"ENDPOINT": "/images/edits",
|
13
|
+
},
|
14
|
+
"EMBEDDINGS_CREATE": {
|
15
|
+
"METHOD": "embeddings.create",
|
16
|
+
"ENDPOINT": "/embeddings",
|
17
|
+
},
|
18
|
+
}
|
@@ -19,6 +19,7 @@ from .vertexai import VertexAIInstrumentation
|
|
19
19
|
from .gemini import GeminiInstrumentation
|
20
20
|
from .mistral import MistralInstrumentation
|
21
21
|
from .embedchain import EmbedchainInstrumentation
|
22
|
+
from .litellm import LiteLLMInstrumentation
|
22
23
|
|
23
24
|
__all__ = [
|
24
25
|
"AnthropicInstrumentation",
|
@@ -31,6 +32,7 @@ __all__ = [
|
|
31
32
|
"LangchainCommunityInstrumentation",
|
32
33
|
"LangchainCoreInstrumentation",
|
33
34
|
"LanggraphInstrumentation",
|
35
|
+
"LiteLLMInstrumentation",
|
34
36
|
"LlamaindexInstrumentation",
|
35
37
|
"OpenAIInstrumentation",
|
36
38
|
"PineconeInstrumentation",
|
@@ -1,6 +1,19 @@
|
|
1
1
|
import json
|
2
|
+
import os
|
3
|
+
|
4
|
+
import ujson
|
5
|
+
from colorama import Fore
|
2
6
|
from importlib_metadata import version as v
|
7
|
+
from langtrace.trace_attributes import FrameworkSpanAttributes
|
8
|
+
from opentelemetry import baggage
|
9
|
+
from opentelemetry.trace import SpanKind
|
10
|
+
from opentelemetry.trace.status import Status, StatusCode
|
11
|
+
|
3
12
|
from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
|
13
|
+
from langtrace_python_sdk.constants.instrumentation.common import (
|
14
|
+
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
|
15
|
+
SERVICE_PROVIDERS,
|
16
|
+
)
|
4
17
|
from langtrace_python_sdk.utils import set_span_attribute
|
5
18
|
from langtrace_python_sdk.utils.llm import (
|
6
19
|
get_extra_attributes,
|
@@ -9,14 +22,6 @@ from langtrace_python_sdk.utils.llm import (
|
|
9
22
|
set_span_attributes,
|
10
23
|
)
|
11
24
|
from langtrace_python_sdk.utils.silently_fail import silently_fail
|
12
|
-
from langtrace_python_sdk.constants.instrumentation.common import (
|
13
|
-
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
|
14
|
-
SERVICE_PROVIDERS,
|
15
|
-
)
|
16
|
-
from opentelemetry import baggage
|
17
|
-
from langtrace.trace_attributes import FrameworkSpanAttributes
|
18
|
-
from opentelemetry.trace import SpanKind
|
19
|
-
from opentelemetry.trace.status import Status, StatusCode
|
20
25
|
|
21
26
|
|
22
27
|
def patch_bootstrapfewshot_optimizer(operation_name, version, tracer):
|
@@ -115,6 +120,8 @@ def patch_signature(operation_name, version, tracer):
|
|
115
120
|
**get_extra_attributes(),
|
116
121
|
}
|
117
122
|
|
123
|
+
trace_checkpoint = os.environ.get("TRACE_DSPY_CHECKPOINT", "true").lower()
|
124
|
+
|
118
125
|
if instance.__class__.__name__:
|
119
126
|
span_attributes["dspy.signature.name"] = instance.__class__.__name__
|
120
127
|
span_attributes["dspy.signature"] = str(instance.signature)
|
@@ -136,6 +143,9 @@ def patch_signature(operation_name, version, tracer):
|
|
136
143
|
"dspy.signature.result",
|
137
144
|
json.dumps(result.toDict()),
|
138
145
|
)
|
146
|
+
if trace_checkpoint == "true":
|
147
|
+
print(Fore.RED + "Note: DSPy checkpoint tracing is enabled in Langtrace. To disable it, set the env var, TRACE_DSPY_CHECKPOINT to false" + Fore.RESET)
|
148
|
+
set_span_attribute(span, "dspy.checkpoint", ujson.dumps(instance.dump_state(False), indent=2))
|
139
149
|
span.set_status(Status(StatusCode.OK))
|
140
150
|
|
141
151
|
span.end()
|
langtrace_python_sdk-2.3.27/src/langtrace_python_sdk/instrumentation/litellm/instrumentation.py
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
"""
|
2
|
+
Copyright (c) 2024 Scale3 Labs
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
12
|
+
"""
|
13
|
+
|
14
|
+
from typing import Collection, Optional, Any
|
15
|
+
import importlib.metadata
|
16
|
+
import logging
|
17
|
+
|
18
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
19
|
+
from opentelemetry.trace import get_tracer, TracerProvider
|
20
|
+
from wrapt import wrap_function_wrapper
|
21
|
+
|
22
|
+
from langtrace_python_sdk.instrumentation.litellm.patch import (
|
23
|
+
async_chat_completions_create,
|
24
|
+
async_embeddings_create,
|
25
|
+
async_images_generate,
|
26
|
+
chat_completions_create,
|
27
|
+
embeddings_create,
|
28
|
+
images_generate,
|
29
|
+
)
|
30
|
+
|
31
|
+
logging.basicConfig(level=logging.FATAL)
|
32
|
+
|
33
|
+
|
34
|
+
class LiteLLMInstrumentation(BaseInstrumentor): # type: ignore
|
35
|
+
|
36
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
37
|
+
return ["litellm >= 1.48.0", "trace-attributes >= 4.0.5"]
|
38
|
+
|
39
|
+
def _instrument(self, **kwargs: Any) -> None:
|
40
|
+
tracer_provider: Optional[TracerProvider] = kwargs.get("tracer_provider")
|
41
|
+
tracer = get_tracer(__name__, "", tracer_provider)
|
42
|
+
version: str = importlib.metadata.version("openai")
|
43
|
+
|
44
|
+
wrap_function_wrapper(
|
45
|
+
"litellm",
|
46
|
+
"completion",
|
47
|
+
chat_completions_create(version, tracer),
|
48
|
+
)
|
49
|
+
|
50
|
+
wrap_function_wrapper(
|
51
|
+
"litellm",
|
52
|
+
"text_completion",
|
53
|
+
chat_completions_create(version, tracer),
|
54
|
+
)
|
55
|
+
|
56
|
+
wrap_function_wrapper(
|
57
|
+
"litellm.main",
|
58
|
+
"acompletion",
|
59
|
+
async_chat_completions_create(version, tracer),
|
60
|
+
)
|
61
|
+
|
62
|
+
wrap_function_wrapper(
|
63
|
+
"litellm.main",
|
64
|
+
"image_generation",
|
65
|
+
images_generate(version, tracer),
|
66
|
+
)
|
67
|
+
|
68
|
+
wrap_function_wrapper(
|
69
|
+
"litellm.main",
|
70
|
+
"aimage_generation",
|
71
|
+
async_images_generate(version, tracer),
|
72
|
+
)
|
73
|
+
|
74
|
+
wrap_function_wrapper(
|
75
|
+
"litellm.main",
|
76
|
+
"embedding",
|
77
|
+
embeddings_create(version, tracer),
|
78
|
+
)
|
79
|
+
|
80
|
+
wrap_function_wrapper(
|
81
|
+
"litellm.main",
|
82
|
+
"aembedding",
|
83
|
+
async_embeddings_create(version, tracer),
|
84
|
+
)
|
85
|
+
|
86
|
+
def _uninstrument(self, **kwargs: Any) -> None:
|
87
|
+
pass
|