langtrace-python-sdk 2.1.19__tar.gz → 2.1.21__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.
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/PKG-INFO +1 -1
- langtrace_python_sdk-2.1.21/src/examples/dspy_example/math_problems_cot.py +42 -0
- langtrace_python_sdk-2.1.21/src/examples/dspy_example/program_of_thought_basic.py +35 -0
- langtrace_python_sdk-2.1.21/src/examples/dspy_example/quiz_gen.py +113 -0
- langtrace_python_sdk-2.1.21/src/examples/dspy_example/react.py +39 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/common.py +1 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +5 -2
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/__init__.py +2 -0
- langtrace_python_sdk-2.1.21/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +3 -0
- langtrace_python_sdk-2.1.21/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +85 -0
- langtrace_python_sdk-2.1.21/src/langtrace_python_sdk/instrumentation/dspy/patch.py +206 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/langtrace.py +2 -0
- langtrace_python_sdk-2.1.21/src/langtrace_python_sdk/version.py +1 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/run_example.py +1 -1
- langtrace_python_sdk-2.1.19/src/langtrace_python_sdk/version.py +0 -1
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/.gitignore +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/LICENSE +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/README.md +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/pyproject.toml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/anthropic_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/anthropic_example/completion.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/chroma_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/chroma_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/chat.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/chat_stream.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/embed.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/rerank.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/tools.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/fastapi_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/fastapi_example/basic_route.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/hiveagent_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/inspect_ai_example/basic_eval.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/langchain_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/langchain_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/langchain_example/groq_example.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/langchain_example/langgraph_example.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/langchain_example/tool.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/llamaindex_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/llamaindex_example/agent.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/llamaindex_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/llamaindex_example/data/abramov.txt +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/ollama_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/ollama_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/chat_completion.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/embeddings_create.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/function_calling.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/images_edit.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/images_generate.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/resources/mask.png +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/tool_calling.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/openai_example/tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/perplexity_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/pinecone_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/pinecone_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/qdrant_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/qdrant_example/basic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/weaviate_example/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/weaviate_example/query_text.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/types/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/llm.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/misc.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/types.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/__init__.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/anthropic/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/anthropic/test_anthropic.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/chroma/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/chroma/test_chroma.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/test_cohere_chat.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/test_cohere_embed.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/cohere/test_cohere_rerank.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/langchain/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/langchain/test_langchain.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/test_chat_completion.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/test_embeddings.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/openai/test_image_generation.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/pinecone/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/pinecone/test_pinecone.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/qdrant/conftest.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/qdrant/test_qdrant.py +0 -0
- {langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/tests/utils.py +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import dspy
|
|
2
|
+
from dspy.datasets.gsm8k import GSM8K, gsm8k_metric
|
|
3
|
+
from dspy.teleprompt import BootstrapFewShot
|
|
4
|
+
|
|
5
|
+
# flake8: noqa
|
|
6
|
+
from langtrace_python_sdk import langtrace, with_langtrace_root_span
|
|
7
|
+
|
|
8
|
+
langtrace.init()
|
|
9
|
+
|
|
10
|
+
turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250)
|
|
11
|
+
dspy.settings.configure(lm=turbo)
|
|
12
|
+
|
|
13
|
+
# Load math questions from the GSM8K dataset
|
|
14
|
+
gsm8k = GSM8K()
|
|
15
|
+
gsm8k_trainset, gsm8k_devset = gsm8k.train[:10], gsm8k.dev[:10]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CoT(dspy.Module):
|
|
19
|
+
def __init__(self):
|
|
20
|
+
super().__init__()
|
|
21
|
+
self.prog = dspy.ChainOfThought("question -> answer")
|
|
22
|
+
|
|
23
|
+
def forward(self, question):
|
|
24
|
+
return self.prog(question=question)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@with_langtrace_root_span(name="math_problems_cot_example")
|
|
28
|
+
def example():
|
|
29
|
+
|
|
30
|
+
# Set up the optimizer: we want to "bootstrap" (i.e., self-generate) 4-shot examples of our CoT program.
|
|
31
|
+
config = dict(max_bootstrapped_demos=4, max_labeled_demos=4)
|
|
32
|
+
|
|
33
|
+
# Optimize! Use the `gsm8k_metric` here. In general, the metric is going to tell the optimizer how well it's doing.
|
|
34
|
+
teleprompter = BootstrapFewShot(metric=gsm8k_metric, **config)
|
|
35
|
+
optimized_cot = teleprompter.compile(CoT(), trainset=gsm8k_trainset)
|
|
36
|
+
|
|
37
|
+
ans = optimized_cot(question="What is the sqrt of 345?")
|
|
38
|
+
print(ans)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if __name__ == "__main__":
|
|
42
|
+
example()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import dspy
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
from langtrace_python_sdk import langtrace, with_langtrace_root_span
|
|
5
|
+
|
|
6
|
+
langtrace.init()
|
|
7
|
+
|
|
8
|
+
turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250)
|
|
9
|
+
dspy.settings.configure(lm=turbo)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Define a simple signature for basic question answering
|
|
13
|
+
class BasicQA(dspy.Signature):
|
|
14
|
+
"""Answer questions with short factoid answers."""
|
|
15
|
+
|
|
16
|
+
question = dspy.InputField()
|
|
17
|
+
answer = dspy.OutputField(desc="often between 1 and 5 words")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@with_langtrace_root_span(name="pot_example")
|
|
21
|
+
def example():
|
|
22
|
+
|
|
23
|
+
# Pass signature to ProgramOfThought Module
|
|
24
|
+
pot = dspy.ProgramOfThought(BasicQA)
|
|
25
|
+
|
|
26
|
+
# Call the ProgramOfThought module on a particular input
|
|
27
|
+
question = "Sarah has 5 apples. She buys 7 more apples from the store. How many apples does Sarah have now?"
|
|
28
|
+
result = pot(question=question)
|
|
29
|
+
|
|
30
|
+
print(f"Question: {question}")
|
|
31
|
+
print(f"Final Predicted Answer (after ProgramOfThought process): {result.answer}")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
example()
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import dspy
|
|
2
|
+
import json
|
|
3
|
+
from dspy.datasets import HotPotQA
|
|
4
|
+
from dspy.teleprompt import BootstrapFewShot
|
|
5
|
+
from dspy.evaluate.evaluate import Evaluate
|
|
6
|
+
|
|
7
|
+
# flake8: noqa
|
|
8
|
+
from langtrace_python_sdk import langtrace, with_langtrace_root_span
|
|
9
|
+
|
|
10
|
+
langtrace.init()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
colbertv2_wiki17_abstracts = dspy.ColBERTv2(
|
|
14
|
+
url="http://20.102.90.50:2017/wiki17_abstracts"
|
|
15
|
+
)
|
|
16
|
+
dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
|
|
17
|
+
turbo = dspy.OpenAI(model="gpt-3.5-turbo-0613", max_tokens=500)
|
|
18
|
+
dspy.settings.configure(lm=turbo, trace=[], temperature=0.7)
|
|
19
|
+
|
|
20
|
+
dataset = HotPotQA(
|
|
21
|
+
train_seed=1,
|
|
22
|
+
train_size=300,
|
|
23
|
+
eval_seed=2023,
|
|
24
|
+
dev_size=300,
|
|
25
|
+
test_size=0,
|
|
26
|
+
keep_details=True,
|
|
27
|
+
)
|
|
28
|
+
trainset = [x.with_inputs("question", "answer") for x in dataset.train]
|
|
29
|
+
devset = [x.with_inputs("question", "answer") for x in dataset.dev]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class GenerateAnswerChoices(dspy.Signature):
|
|
33
|
+
"""Generate answer choices in JSON format that include the correct answer and plausible distractors for the specified question."""
|
|
34
|
+
|
|
35
|
+
question = dspy.InputField()
|
|
36
|
+
correct_answer = dspy.InputField()
|
|
37
|
+
number_of_choices = dspy.InputField()
|
|
38
|
+
answer_choices = dspy.OutputField(desc="JSON key-value pairs")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class QuizAnswerGenerator(dspy.Module):
|
|
42
|
+
def __init__(self):
|
|
43
|
+
super().__init__()
|
|
44
|
+
self.prog = dspy.ChainOfThought(GenerateAnswerChoices)
|
|
45
|
+
|
|
46
|
+
def forward(self, question, answer):
|
|
47
|
+
choices = self.prog(
|
|
48
|
+
question=question, correct_answer=answer, number_of_choices="4"
|
|
49
|
+
).answer_choices
|
|
50
|
+
# dspy.Suggest(
|
|
51
|
+
# format_checker(choices),
|
|
52
|
+
# "The format of the answer choices should be in JSON format. Please revise accordingly.",
|
|
53
|
+
# target_module=GenerateAnswerChoices,
|
|
54
|
+
# )
|
|
55
|
+
return dspy.Prediction(choices=choices)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def format_checker(choice_string):
|
|
59
|
+
try:
|
|
60
|
+
choices = json.loads(choice_string)
|
|
61
|
+
if isinstance(choices, dict) and all(
|
|
62
|
+
isinstance(key, str) and isinstance(value, str)
|
|
63
|
+
for key, value in choices.items()
|
|
64
|
+
):
|
|
65
|
+
return True
|
|
66
|
+
except json.JSONDecodeError:
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
return False
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def format_valid_metric(gold, pred, trace=None):
|
|
73
|
+
generated_choices = pred.choices
|
|
74
|
+
format_valid = format_checker(generated_choices)
|
|
75
|
+
score = format_valid
|
|
76
|
+
return score
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@with_langtrace_root_span(name="quiz_generator_1")
|
|
80
|
+
def quiz_generator_1():
|
|
81
|
+
quiz_generator = QuizAnswerGenerator()
|
|
82
|
+
|
|
83
|
+
example = devset[67]
|
|
84
|
+
print("Example Question: ", example.question)
|
|
85
|
+
print("Example Answer: ", example.answer)
|
|
86
|
+
# quiz_choices = quiz_generator(question=example.question, answer=example.answer)
|
|
87
|
+
# print("Generated Quiz Choices: ", quiz_choices.choices)
|
|
88
|
+
|
|
89
|
+
optimizer = BootstrapFewShot(
|
|
90
|
+
metric=format_valid_metric, max_bootstrapped_demos=4, max_labeled_demos=4
|
|
91
|
+
)
|
|
92
|
+
compiled_quiz_generator = optimizer.compile(
|
|
93
|
+
quiz_generator,
|
|
94
|
+
trainset=trainset,
|
|
95
|
+
)
|
|
96
|
+
quiz_choices = compiled_quiz_generator(
|
|
97
|
+
question=example.question, answer=example.answer
|
|
98
|
+
)
|
|
99
|
+
print("Generated Quiz Choices: ", quiz_choices.choices)
|
|
100
|
+
|
|
101
|
+
# Evaluate
|
|
102
|
+
evaluate = Evaluate(
|
|
103
|
+
metric=format_valid_metric,
|
|
104
|
+
devset=devset[67:70],
|
|
105
|
+
num_threads=1,
|
|
106
|
+
display_progress=True,
|
|
107
|
+
display_table=5,
|
|
108
|
+
)
|
|
109
|
+
evaluate(quiz_generator)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
quiz_generator_1()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import dspy
|
|
4
|
+
|
|
5
|
+
# Add the local src folder to the Python path
|
|
6
|
+
sys.path.insert(0, os.path.abspath('/Users/karthikkalyanaraman/work/langtrace/langtrace-python-sdk/src'))
|
|
7
|
+
|
|
8
|
+
# flake8: noqa
|
|
9
|
+
from langtrace_python_sdk import langtrace, with_langtrace_root_span
|
|
10
|
+
langtrace.init()
|
|
11
|
+
|
|
12
|
+
turbo = dspy.OpenAI(model='gpt-3.5-turbo', max_tokens=250)
|
|
13
|
+
dspy.settings.configure(lm=turbo)
|
|
14
|
+
|
|
15
|
+
colbertv2_wiki17_abstracts = dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
|
|
16
|
+
dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
|
|
17
|
+
retriever = dspy.Retrieve(k=3)
|
|
18
|
+
|
|
19
|
+
# Define a simple signature for basic question answering
|
|
20
|
+
class BasicQA(dspy.Signature):
|
|
21
|
+
"""Answer questions with short factoid answers."""
|
|
22
|
+
question = dspy.InputField()
|
|
23
|
+
answer = dspy.OutputField(desc="often between 1 and 5 words")
|
|
24
|
+
|
|
25
|
+
@with_langtrace_root_span(name="react_example")
|
|
26
|
+
def example():
|
|
27
|
+
|
|
28
|
+
# Pass signature to ReAct module
|
|
29
|
+
react_module = dspy.ReAct(BasicQA)
|
|
30
|
+
|
|
31
|
+
# Call the ReAct module on a particular input
|
|
32
|
+
question = 'Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?'
|
|
33
|
+
result = react_module(question=question)
|
|
34
|
+
|
|
35
|
+
print(f"Question: {question}")
|
|
36
|
+
print(f"Final Predicted Answer (after ReAct process): {result.answer}")
|
|
37
|
+
|
|
38
|
+
if __name__ == '__main__':
|
|
39
|
+
example()
|
|
@@ -27,6 +27,8 @@ class OpenMode(str):
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class LangTraceFile(io.BytesIO):
|
|
30
|
+
_host: str = os.environ.get("LANGTRACE_API_HOST", None) or LANGTRACE_REMOTE_URL
|
|
31
|
+
|
|
30
32
|
def __init__(self, fs: "LangTraceFileSystem", path: str, mode: OpenMode):
|
|
31
33
|
super().__init__()
|
|
32
34
|
self.fs = fs
|
|
@@ -65,7 +67,7 @@ class LangTraceFile(io.BytesIO):
|
|
|
65
67
|
else:
|
|
66
68
|
print(Fore.GREEN + "Sending results to Langtrace" + Fore.RESET)
|
|
67
69
|
response = requests.post(
|
|
68
|
-
url=f"{
|
|
70
|
+
url=f"{self._host}/api/run",
|
|
69
71
|
data=json.dumps(data),
|
|
70
72
|
headers={
|
|
71
73
|
"Content-Type": "application/json",
|
|
@@ -80,6 +82,7 @@ class LangTraceFile(io.BytesIO):
|
|
|
80
82
|
|
|
81
83
|
|
|
82
84
|
class LangTraceFileSystem(AbstractFileSystem):
|
|
85
|
+
_host: str = os.environ.get("LANGTRACE_API_HOST", None) or LANGTRACE_REMOTE_URL
|
|
83
86
|
protocol = "langtracefs"
|
|
84
87
|
sep = "/"
|
|
85
88
|
|
|
@@ -112,7 +115,7 @@ class LangTraceFileSystem(AbstractFileSystem):
|
|
|
112
115
|
+ Fore.RESET
|
|
113
116
|
)
|
|
114
117
|
response = requests.get(
|
|
115
|
-
url=f"{
|
|
118
|
+
url=f"{self._host}/api/dataset/download?id={dataset_id}",
|
|
116
119
|
headers={
|
|
117
120
|
"Content-Type": "application/json",
|
|
118
121
|
"x-api-key": os.environ.get("LANGTRACE_API_KEY"),
|
|
@@ -12,6 +12,7 @@ from .pinecone import PineconeInstrumentation
|
|
|
12
12
|
from .qdrant import QdrantInstrumentation
|
|
13
13
|
from .weaviate import WeaviateInstrumentation
|
|
14
14
|
from .ollama import OllamaInstrumentor
|
|
15
|
+
from .dspy import DspyInstrumentor
|
|
15
16
|
|
|
16
17
|
__all__ = [
|
|
17
18
|
"AnthropicInstrumentation",
|
|
@@ -28,4 +29,5 @@ __all__ = [
|
|
|
28
29
|
"QdrantInstrumentation",
|
|
29
30
|
"WeaviateInstrumentation",
|
|
30
31
|
"OllamaInstrumentor",
|
|
32
|
+
"DspyInstrumentor",
|
|
31
33
|
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright (c) 2024 Scale3 Labs
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
18
|
+
from opentelemetry.trace import get_tracer
|
|
19
|
+
from wrapt import wrap_function_wrapper as _W
|
|
20
|
+
from typing import Collection
|
|
21
|
+
from importlib_metadata import version as v
|
|
22
|
+
from .patch import patch_bootstrapfewshot_optimizer, patch_signature, patch_evaluate
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class DspyInstrumentor(BaseInstrumentor):
|
|
26
|
+
"""
|
|
27
|
+
The DspyInstrumentor class represents the DSPy instrumentation"""
|
|
28
|
+
|
|
29
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
|
30
|
+
return ["dspy >= 0.1.5"]
|
|
31
|
+
|
|
32
|
+
def _instrument(self, **kwargs):
|
|
33
|
+
tracer_provider = kwargs.get("tracer_provider")
|
|
34
|
+
tracer = get_tracer(__name__, "", tracer_provider)
|
|
35
|
+
version = v("dspy")
|
|
36
|
+
_W(
|
|
37
|
+
"dspy.teleprompt.bootstrap",
|
|
38
|
+
"BootstrapFewShot.compile",
|
|
39
|
+
patch_bootstrapfewshot_optimizer(
|
|
40
|
+
"BootstrapFewShot.compile", version, tracer
|
|
41
|
+
),
|
|
42
|
+
)
|
|
43
|
+
_W(
|
|
44
|
+
"dspy.predict.predict",
|
|
45
|
+
"Predict.forward",
|
|
46
|
+
patch_signature("Predict.forward", version, tracer),
|
|
47
|
+
)
|
|
48
|
+
_W(
|
|
49
|
+
"dspy.predict.chain_of_thought",
|
|
50
|
+
"ChainOfThought.forward",
|
|
51
|
+
patch_signature("ChainOfThought.forward", version, tracer),
|
|
52
|
+
)
|
|
53
|
+
_W(
|
|
54
|
+
"dspy.predict.chain_of_thought_with_hint",
|
|
55
|
+
"ChainOfThoughtWithHint.forward",
|
|
56
|
+
patch_signature("ChainOfThoughtWithHint.forward", version, tracer),
|
|
57
|
+
)
|
|
58
|
+
_W(
|
|
59
|
+
"dspy.predict.react",
|
|
60
|
+
"ReAct.forward",
|
|
61
|
+
patch_signature("ReAct.forward", version, tracer),
|
|
62
|
+
)
|
|
63
|
+
_W(
|
|
64
|
+
"dspy.predict.program_of_thought",
|
|
65
|
+
"ProgramOfThought.forward",
|
|
66
|
+
patch_signature("ProgramOfThought.forward", version, tracer),
|
|
67
|
+
)
|
|
68
|
+
_W(
|
|
69
|
+
"dspy.predict.multi_chain_comparison",
|
|
70
|
+
"MultiChainComparison.forward",
|
|
71
|
+
patch_signature("MultiChainComparison.forward", version, tracer),
|
|
72
|
+
)
|
|
73
|
+
_W(
|
|
74
|
+
"dspy.predict.retry",
|
|
75
|
+
"Retry.forward",
|
|
76
|
+
patch_signature("Retry.forward", version, tracer),
|
|
77
|
+
)
|
|
78
|
+
_W(
|
|
79
|
+
"dspy.evaluate.evaluate",
|
|
80
|
+
"Evaluate.__call__",
|
|
81
|
+
patch_evaluate("Evaluate", version, tracer),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def _uninstrument(self, **kwargs):
|
|
85
|
+
pass
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from importlib_metadata import version as v
|
|
3
|
+
from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
|
|
4
|
+
from langtrace_python_sdk.utils import set_span_attribute
|
|
5
|
+
from langtrace_python_sdk.utils.silently_fail import silently_fail
|
|
6
|
+
from langtrace_python_sdk.constants.instrumentation.common import (
|
|
7
|
+
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
|
|
8
|
+
SERVICE_PROVIDERS,
|
|
9
|
+
)
|
|
10
|
+
from opentelemetry import baggage
|
|
11
|
+
from langtrace.trace_attributes import FrameworkSpanAttributes
|
|
12
|
+
from opentelemetry.trace import SpanKind
|
|
13
|
+
from opentelemetry.trace.status import Status, StatusCode
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def patch_bootstrapfewshot_optimizer(operation_name, version, tracer):
|
|
17
|
+
def traced_method(wrapped, instance, args, kwargs):
|
|
18
|
+
|
|
19
|
+
service_provider = SERVICE_PROVIDERS["DSPY"]
|
|
20
|
+
extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY)
|
|
21
|
+
span_attributes = {
|
|
22
|
+
"langtrace.sdk.name": "langtrace-python-sdk",
|
|
23
|
+
"langtrace.service.name": service_provider,
|
|
24
|
+
"langtrace.service.type": "framework",
|
|
25
|
+
"langtrace.service.version": version,
|
|
26
|
+
"langtrace.version": v(LANGTRACE_SDK_NAME),
|
|
27
|
+
**(extra_attributes if extra_attributes is not None else {}),
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if instance.__class__.__name__:
|
|
31
|
+
span_attributes["dspy.optimizer"] = instance.__class__.__name__
|
|
32
|
+
if len(args) > 0:
|
|
33
|
+
span_attributes["dspy.optimizer.module"] = args[0].__class__.__name__
|
|
34
|
+
if args[0].prog:
|
|
35
|
+
prog = {
|
|
36
|
+
"name": args[0].prog.__class__.__name__,
|
|
37
|
+
"signature": str(args[0].prog.signature) if args[0].prog.signature else None,
|
|
38
|
+
}
|
|
39
|
+
span_attributes["dspy.optimizer.module.prog"] = json.dumps(prog)
|
|
40
|
+
if instance.metric:
|
|
41
|
+
span_attributes["dspy.optimizer.metric"] = instance.metric.__name__
|
|
42
|
+
if kwargs.get("trainset") and len(kwargs.get("trainset")) > 0:
|
|
43
|
+
span_attributes["dspy.optimizer.trainset"] = str(kwargs.get("trainset"))
|
|
44
|
+
config = {}
|
|
45
|
+
if instance.metric_threshold:
|
|
46
|
+
config["metric_threshold"] = instance.metric_threshold
|
|
47
|
+
if instance.teacher_settings:
|
|
48
|
+
config["teacher_settings"] = instance.teacher_settings
|
|
49
|
+
if instance.max_bootstrapped_demos:
|
|
50
|
+
config["max_bootstrapped_demos"] = instance.max_bootstrapped_demos
|
|
51
|
+
if instance.max_labeled_demos:
|
|
52
|
+
config["max_labeled_demos"] = instance.max_labeled_demos
|
|
53
|
+
if instance.max_rounds:
|
|
54
|
+
config["max_rounds"] = instance.max_rounds
|
|
55
|
+
if instance.max_errors:
|
|
56
|
+
config["max_errors"] = instance.max_errors
|
|
57
|
+
if instance.error_count:
|
|
58
|
+
config["error_count"] = instance.error_count
|
|
59
|
+
if config and len(config) > 0:
|
|
60
|
+
span_attributes["dspy.optimizer.config"] = json.dumps(config)
|
|
61
|
+
|
|
62
|
+
attributes = FrameworkSpanAttributes(**span_attributes)
|
|
63
|
+
with tracer.start_as_current_span(
|
|
64
|
+
operation_name, kind=SpanKind.CLIENT
|
|
65
|
+
) as span:
|
|
66
|
+
_set_input_attributes(span, kwargs, attributes)
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
result = wrapped(*args, **kwargs)
|
|
70
|
+
if result:
|
|
71
|
+
span.set_status(Status(StatusCode.OK))
|
|
72
|
+
|
|
73
|
+
span.end()
|
|
74
|
+
return result
|
|
75
|
+
|
|
76
|
+
except Exception as err:
|
|
77
|
+
# Record the exception in the span
|
|
78
|
+
span.record_exception(err)
|
|
79
|
+
|
|
80
|
+
# Set the span status to indicate an error
|
|
81
|
+
span.set_status(Status(StatusCode.ERROR, str(err)))
|
|
82
|
+
|
|
83
|
+
# Reraise the exception to ensure it's not swallowed
|
|
84
|
+
raise
|
|
85
|
+
|
|
86
|
+
return traced_method
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def patch_signature(operation_name, version, tracer):
|
|
90
|
+
def traced_method(wrapped, instance, args, kwargs):
|
|
91
|
+
|
|
92
|
+
service_provider = SERVICE_PROVIDERS["DSPY"]
|
|
93
|
+
extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY)
|
|
94
|
+
span_attributes = {
|
|
95
|
+
"langtrace.sdk.name": "langtrace-python-sdk",
|
|
96
|
+
"langtrace.service.name": service_provider,
|
|
97
|
+
"langtrace.service.type": "framework",
|
|
98
|
+
"langtrace.service.version": version,
|
|
99
|
+
"langtrace.version": v(LANGTRACE_SDK_NAME),
|
|
100
|
+
**(extra_attributes if extra_attributes is not None else {}),
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if instance.__class__.__name__:
|
|
104
|
+
span_attributes["dspy.signature.name"] = instance.__class__.__name__
|
|
105
|
+
span_attributes["dspy.signature"] = str(instance)
|
|
106
|
+
|
|
107
|
+
if kwargs and len(kwargs) > 0:
|
|
108
|
+
span_attributes["dspy.signature.args"] = str(kwargs)
|
|
109
|
+
|
|
110
|
+
attributes = FrameworkSpanAttributes(**span_attributes)
|
|
111
|
+
with tracer.start_as_current_span(
|
|
112
|
+
operation_name, kind=SpanKind.CLIENT
|
|
113
|
+
) as span:
|
|
114
|
+
_set_input_attributes(span, kwargs, attributes)
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
result = wrapped(*args, **kwargs)
|
|
118
|
+
if result:
|
|
119
|
+
set_span_attribute(span, "dspy.signature.result", str(result))
|
|
120
|
+
span.set_status(Status(StatusCode.OK))
|
|
121
|
+
|
|
122
|
+
span.end()
|
|
123
|
+
return result
|
|
124
|
+
|
|
125
|
+
except Exception as err:
|
|
126
|
+
# Record the exception in the span
|
|
127
|
+
span.record_exception(err)
|
|
128
|
+
|
|
129
|
+
# Set the span status to indicate an error
|
|
130
|
+
span.set_status(Status(StatusCode.ERROR, str(err)))
|
|
131
|
+
|
|
132
|
+
# Reraise the exception to ensure it's not swallowed
|
|
133
|
+
raise
|
|
134
|
+
|
|
135
|
+
return traced_method
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def patch_evaluate(operation_name, version, tracer):
|
|
139
|
+
def traced_method(wrapped, instance, args, kwargs):
|
|
140
|
+
|
|
141
|
+
service_provider = SERVICE_PROVIDERS["DSPY"]
|
|
142
|
+
extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY)
|
|
143
|
+
span_attributes = {
|
|
144
|
+
"langtrace.sdk.name": "langtrace-python-sdk",
|
|
145
|
+
"langtrace.service.name": service_provider,
|
|
146
|
+
"langtrace.service.type": "framework",
|
|
147
|
+
"langtrace.service.version": version,
|
|
148
|
+
"langtrace.version": v(LANGTRACE_SDK_NAME),
|
|
149
|
+
**(extra_attributes if extra_attributes is not None else {}),
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if instance.devset is not None:
|
|
153
|
+
span_attributes["dspy.evaluate.devset"] = str(instance.devset)
|
|
154
|
+
if instance.display is not None:
|
|
155
|
+
span_attributes["dspy.evaluate.display"] = str(instance.display)
|
|
156
|
+
if instance.num_threads is not None:
|
|
157
|
+
span_attributes["dspy.evaluate.num_threads"] = str(instance.num_threads)
|
|
158
|
+
if instance.return_outputs is not None:
|
|
159
|
+
span_attributes["dspy.evaluate.return_outputs"] = str(instance.return_outputs)
|
|
160
|
+
if instance.display_table is not None:
|
|
161
|
+
span_attributes["dspy.evaluate.display_table"] = str(instance.display_table)
|
|
162
|
+
if instance.display_progress is not None:
|
|
163
|
+
span_attributes["dspy.evaluate.display_progress"] = str(instance.display_progress)
|
|
164
|
+
if instance.metric is not None:
|
|
165
|
+
span_attributes["dspy.evaluate.metric"] = instance.metric.__name__
|
|
166
|
+
if instance.error_count is not None:
|
|
167
|
+
span_attributes["dspy.evaluate.error_count"] = str(instance.error_count)
|
|
168
|
+
if instance.error_lock is not None:
|
|
169
|
+
span_attributes["dspy.evaluate.error_lock"] = str(instance.error_lock)
|
|
170
|
+
if instance.max_errors is not None:
|
|
171
|
+
span_attributes["dspy.evaluate.max_errors"] = str(instance.max_errors)
|
|
172
|
+
if args and len(args) > 0:
|
|
173
|
+
span_attributes["dspy.evaluate.args"] = str(args)
|
|
174
|
+
|
|
175
|
+
attributes = FrameworkSpanAttributes(**span_attributes)
|
|
176
|
+
with tracer.start_as_current_span(
|
|
177
|
+
operation_name, kind=SpanKind.CLIENT
|
|
178
|
+
) as span:
|
|
179
|
+
_set_input_attributes(span, kwargs, attributes)
|
|
180
|
+
|
|
181
|
+
try:
|
|
182
|
+
result = wrapped(*args, **kwargs)
|
|
183
|
+
if result is not None:
|
|
184
|
+
set_span_attribute(span, "dspy.evaluate.result", str(result))
|
|
185
|
+
span.set_status(Status(StatusCode.OK))
|
|
186
|
+
|
|
187
|
+
span.end()
|
|
188
|
+
return result
|
|
189
|
+
|
|
190
|
+
except Exception as err:
|
|
191
|
+
# Record the exception in the span
|
|
192
|
+
span.record_exception(err)
|
|
193
|
+
|
|
194
|
+
# Set the span status to indicate an error
|
|
195
|
+
span.set_status(Status(StatusCode.ERROR, str(err)))
|
|
196
|
+
|
|
197
|
+
# Reraise the exception to ensure it's not swallowed
|
|
198
|
+
raise
|
|
199
|
+
|
|
200
|
+
return traced_method
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@silently_fail
|
|
204
|
+
def _set_input_attributes(span, kwargs, attributes):
|
|
205
|
+
for field, value in attributes.model_dump(by_alias=True).items():
|
|
206
|
+
set_span_attribute(span, field, value)
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/langtrace_python_sdk/langtrace.py
RENAMED
|
@@ -51,6 +51,7 @@ from langtrace_python_sdk.instrumentation import (
|
|
|
51
51
|
QdrantInstrumentation,
|
|
52
52
|
WeaviateInstrumentation,
|
|
53
53
|
OllamaInstrumentor,
|
|
54
|
+
DspyInstrumentor,
|
|
54
55
|
)
|
|
55
56
|
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
|
|
56
57
|
from colorama import Fore
|
|
@@ -108,6 +109,7 @@ def init(
|
|
|
108
109
|
"weaviate": WeaviateInstrumentation(),
|
|
109
110
|
"sqlalchemy": SQLAlchemyInstrumentor(),
|
|
110
111
|
"ollama": OllamaInstrumentor(),
|
|
112
|
+
"dspy": DspyInstrumentor(),
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
init_instrumentations(disable_instrumentations, all_instrumentations)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.1.21"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.1.19"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/chroma_example/__init__.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/chroma_example/basic.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/__init__.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/chat.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/embed.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/rerank.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/cohere_example/tools.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.1.19 → langtrace_python_sdk-2.1.21}/src/examples/fastapi_example/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|