langtrace-python-sdk 2.2.7__tar.gz → 2.2.9__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.2.7 → langtrace_python_sdk-2.2.9}/PKG-INFO +9 -3
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/README.md +8 -2
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/inspect_ai_example/basic_eval.py +4 -2
- langtrace_python_sdk-2.2.9/src/examples/openai_example/send_user_feedback.py +40 -0
- langtrace_python_sdk-2.2.9/src/examples/routellm_example/basic.py +41 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +28 -4
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +2 -4
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +2 -4
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/groq/patch.py +9 -9
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +4 -12
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/__init__.py +15 -6
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/llm.py +14 -18
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/with_root_span.py +17 -1
- langtrace_python_sdk-2.2.9/src/langtrace_python_sdk/version.py +1 -0
- langtrace_python_sdk-2.2.7/src/langtrace_python_sdk/version.py +0 -1
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/.gitignore +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/LICENSE +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/pyproject.toml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/anthropic_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/anthropic_example/completion.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/chroma_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/chroma_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/chat.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/chat_stream.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/embed.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/rerank.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/tools.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/crewai_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/dspy_example/math_problems_cot.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/dspy_example/math_problems_cot_parallel.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/dspy_example/program_of_thought_basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/dspy_example/quiz_gen.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/dspy_example/react.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/fastapi_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/fastapi_example/basic_route.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/gemini_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/gemini_example/function_tools.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/gemini_example/main.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/hiveagent_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/groq_example.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/langgraph_example.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/tool.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/llamaindex_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/llamaindex_example/agent.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/llamaindex_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/llamaindex_example/data/abramov.txt +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/ollama_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/ollama_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/chat_completion.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/chat_completion_tool_choice.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/embeddings_create.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/function_calling.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/images_edit.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/images_generate.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/resources/mask.png +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/tool_calling.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/otlp_example/otlp_basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/otlp_example/otlp_with_langtrace.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/perplexity_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/pinecone_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/pinecone_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/qdrant_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/qdrant_example/basic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/vertexai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/vertexai_example/main.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/weaviate_example/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/weaviate_example/query_text.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/gemini.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/vertexai.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/crewai/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/crewai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/crewai/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/dspy/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/gemini/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/gemini/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/gemini/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/vertexai/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/vertexai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/vertexai/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/langtrace.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/types/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/misc.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/types.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/run_example.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/__init__.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/anthropic/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/anthropic/test_anthropic.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/chroma/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/chroma/test_chroma.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/test_cohere_chat.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/test_cohere_embed.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/cohere/test_cohere_rerank.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/groq/cassettes/test_async_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/groq/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/groq/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/groq/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/groq/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/groq/test_groq.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/langchain/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/langchain/test_langchain.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/test_chat_completion.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/test_embeddings.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/openai/test_image_generation.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/pinecone/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/pinecone/test_pinecone.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/qdrant/conftest.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/tests/qdrant/test_qdrant.py +0 -0
- {langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/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.2.
|
|
3
|
+
Version: 2.2.9
|
|
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>
|
|
@@ -239,7 +239,7 @@ def main():
|
|
|
239
239
|
from langtrace_python_sdk import with_langtrace_root_span, with_additional_attributes
|
|
240
240
|
|
|
241
241
|
|
|
242
|
-
@with_additional_attributes({"user.id": "1234"
|
|
242
|
+
@with_additional_attributes({"user.id": "1234"})
|
|
243
243
|
def api_call1():
|
|
244
244
|
response = client.chat.completions.create(
|
|
245
245
|
model="gpt-4",
|
|
@@ -249,7 +249,7 @@ def api_call1():
|
|
|
249
249
|
return response
|
|
250
250
|
|
|
251
251
|
|
|
252
|
-
@with_additional_attributes({"user.id": "5678"
|
|
252
|
+
@with_additional_attributes({"user.id": "5678"})
|
|
253
253
|
def api_call2():
|
|
254
254
|
response = client.chat.completions.create(
|
|
255
255
|
model="gpt-4",
|
|
@@ -273,6 +273,11 @@ from langtrace_python_sdk import get_prompt_from_registry
|
|
|
273
273
|
prompt = get_prompt_from_registry(<Registry ID>, options={"prompt_version": 1, "variables": {"foo": "bar"} })
|
|
274
274
|
```
|
|
275
275
|
|
|
276
|
+
### Opt out of tracing prompt and completion data
|
|
277
|
+
By default, prompt and completion data are captured. If you would like to opt out of it, set the following env var,
|
|
278
|
+
|
|
279
|
+
`TRACE_PROMPT_COMPLETION_DATA=false`
|
|
280
|
+
|
|
276
281
|
## Supported integrations
|
|
277
282
|
|
|
278
283
|
Langtrace automatically captures traces from the following vendors:
|
|
@@ -293,6 +298,7 @@ Langtrace automatically captures traces from the following vendors:
|
|
|
293
298
|
| CrewAI | Framework | :x: | :white_check_mark: |
|
|
294
299
|
| Ollama | Framework | :x: | :white_check_mark: |
|
|
295
300
|
| VertexAI | Framework | :x: | :white_check_mark: |
|
|
301
|
+
| Vercel AI SDK| Framework | :white_check_mark: | :x: |
|
|
296
302
|
| Pinecone | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
297
303
|
| ChromaDB | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
298
304
|
| QDrant | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
@@ -194,7 +194,7 @@ def main():
|
|
|
194
194
|
from langtrace_python_sdk import with_langtrace_root_span, with_additional_attributes
|
|
195
195
|
|
|
196
196
|
|
|
197
|
-
@with_additional_attributes({"user.id": "1234"
|
|
197
|
+
@with_additional_attributes({"user.id": "1234"})
|
|
198
198
|
def api_call1():
|
|
199
199
|
response = client.chat.completions.create(
|
|
200
200
|
model="gpt-4",
|
|
@@ -204,7 +204,7 @@ def api_call1():
|
|
|
204
204
|
return response
|
|
205
205
|
|
|
206
206
|
|
|
207
|
-
@with_additional_attributes({"user.id": "5678"
|
|
207
|
+
@with_additional_attributes({"user.id": "5678"})
|
|
208
208
|
def api_call2():
|
|
209
209
|
response = client.chat.completions.create(
|
|
210
210
|
model="gpt-4",
|
|
@@ -228,6 +228,11 @@ from langtrace_python_sdk import get_prompt_from_registry
|
|
|
228
228
|
prompt = get_prompt_from_registry(<Registry ID>, options={"prompt_version": 1, "variables": {"foo": "bar"} })
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
+
### Opt out of tracing prompt and completion data
|
|
232
|
+
By default, prompt and completion data are captured. If you would like to opt out of it, set the following env var,
|
|
233
|
+
|
|
234
|
+
`TRACE_PROMPT_COMPLETION_DATA=false`
|
|
235
|
+
|
|
231
236
|
## Supported integrations
|
|
232
237
|
|
|
233
238
|
Langtrace automatically captures traces from the following vendors:
|
|
@@ -248,6 +253,7 @@ Langtrace automatically captures traces from the following vendors:
|
|
|
248
253
|
| CrewAI | Framework | :x: | :white_check_mark: |
|
|
249
254
|
| Ollama | Framework | :x: | :white_check_mark: |
|
|
250
255
|
| VertexAI | Framework | :x: | :white_check_mark: |
|
|
256
|
+
| Vercel AI SDK| Framework | :white_check_mark: | :x: |
|
|
251
257
|
| Pinecone | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
252
258
|
| ChromaDB | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
253
259
|
| QDrant | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import fsspec
|
|
2
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
3
|
from inspect_ai import Task, task
|
|
3
4
|
from inspect_ai.dataset import csv_dataset, Sample
|
|
4
5
|
from inspect_ai.scorer import model_graded_qa
|
|
5
6
|
from inspect_ai.solver import chain_of_thought, self_critique
|
|
6
7
|
from langtrace_python_sdk.extensions.langtrace_filesystem import LangTraceFileSystem
|
|
7
8
|
|
|
9
|
+
_ = load_dotenv(find_dotenv())
|
|
8
10
|
|
|
9
11
|
# Manually register the filesystem with fsspec
|
|
10
12
|
# Note: This is only necessary because the filesystem is not registered.
|
|
@@ -24,9 +26,9 @@ def hydrate_with_question(record):
|
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
@task
|
|
27
|
-
def
|
|
29
|
+
def basic_eval():
|
|
28
30
|
return Task(
|
|
29
|
-
dataset=csv_dataset("langtracefs://
|
|
31
|
+
dataset=csv_dataset("langtracefs://clz0p4i1t000fwv0xjtlvkxyx"),
|
|
30
32
|
plan=[chain_of_thought(), self_critique()],
|
|
31
33
|
scorer=model_graded_qa(),
|
|
32
34
|
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from openai import OpenAI
|
|
3
|
+
from langtrace_python_sdk import langtrace, with_langtrace_root_span, SendUserFeedback
|
|
4
|
+
|
|
5
|
+
_ = load_dotenv(find_dotenv())
|
|
6
|
+
|
|
7
|
+
# Initialize Langtrace SDK
|
|
8
|
+
langtrace.init()
|
|
9
|
+
client = OpenAI()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def api(span_id, trace_id):
|
|
13
|
+
response = client.chat.completions.create(
|
|
14
|
+
model="gpt-4o-mini",
|
|
15
|
+
messages=[
|
|
16
|
+
{"role": "user", "content": "What is the best place to live in the US?"},
|
|
17
|
+
],
|
|
18
|
+
stream=False,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Collect user feedback and send it to Langtrace
|
|
22
|
+
user_score = 1 # Example user score
|
|
23
|
+
user_id = 'user_1234' # Example user ID
|
|
24
|
+
data = {
|
|
25
|
+
"userScore": user_score,
|
|
26
|
+
"userId": user_id,
|
|
27
|
+
"spanId": span_id,
|
|
28
|
+
"traceId": trace_id
|
|
29
|
+
}
|
|
30
|
+
SendUserFeedback().evaluate(data=data)
|
|
31
|
+
|
|
32
|
+
# Return the response
|
|
33
|
+
return response.choices[0].message.content
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# wrap the API call with the Langtrace root span
|
|
37
|
+
wrapped_api = with_langtrace_root_span()(api)
|
|
38
|
+
|
|
39
|
+
# Call the wrapped API
|
|
40
|
+
wrapped_api()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
sys.path.insert(0, "/Users/karthikkalyanaraman/work/langtrace/langtrace-python-sdk/src")
|
|
4
|
+
|
|
5
|
+
from langtrace_python_sdk import langtrace
|
|
6
|
+
from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
|
|
7
|
+
from routellm.controller import Controller
|
|
8
|
+
from dotenv import load_dotenv
|
|
9
|
+
|
|
10
|
+
load_dotenv()
|
|
11
|
+
|
|
12
|
+
langtrace.init()
|
|
13
|
+
|
|
14
|
+
# litellm.set_verbose=True
|
|
15
|
+
client = Controller(
|
|
16
|
+
routers=["mf"],
|
|
17
|
+
strong_model="claude-3-opus-20240229",
|
|
18
|
+
weak_model="claude-3-opus-20240229",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@with_langtrace_root_span("Routellm")
|
|
23
|
+
def Routellm(prompt):
|
|
24
|
+
try:
|
|
25
|
+
|
|
26
|
+
response = client.chat.completions.create(
|
|
27
|
+
model="router-mf-0.11593", messages=[{"role": "user", "content": prompt}]
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
for chunk in response:
|
|
31
|
+
if hasattr(chunk, "choices"):
|
|
32
|
+
print(chunk.choices[0].delta.content or "", end="")
|
|
33
|
+
else:
|
|
34
|
+
print(chunk)
|
|
35
|
+
|
|
36
|
+
except Exception as e:
|
|
37
|
+
print(f"An error occurred: {e}")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Routellm("what is the square root of 12182382932.99")
|
|
41
|
+
Routellm("Write me a short story")
|
|
@@ -27,13 +27,25 @@ 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
31
|
def __init__(self, fs: "LangTraceFileSystem", path: str, mode: OpenMode):
|
|
33
32
|
super().__init__()
|
|
34
33
|
self.fs = fs
|
|
35
34
|
self.path = path
|
|
36
35
|
self.mode = mode
|
|
36
|
+
self._host: str = os.environ.get("LANGTRACE_API_HOST", LANGTRACE_REMOTE_URL)
|
|
37
|
+
self._api_key: str = os.environ.get("LANGTRACE_API_KEY", None)
|
|
38
|
+
if self._host.endswith("/api/trace"):
|
|
39
|
+
self._host = self._host.replace("/api/trace", "")
|
|
40
|
+
|
|
41
|
+
if self._api_key is None:
|
|
42
|
+
print(Fore.RED)
|
|
43
|
+
print(
|
|
44
|
+
f"Missing Langtrace API key, proceed to {self._host} to create one"
|
|
45
|
+
)
|
|
46
|
+
print("Set the API key as an environment variable LANGTRACE_API_KEY")
|
|
47
|
+
print(Fore.RESET)
|
|
48
|
+
return
|
|
37
49
|
|
|
38
50
|
def close(self) -> None:
|
|
39
51
|
if not self.closed:
|
|
@@ -71,7 +83,7 @@ class LangTraceFile(io.BytesIO):
|
|
|
71
83
|
data=json.dumps(data),
|
|
72
84
|
headers={
|
|
73
85
|
"Content-Type": "application/json",
|
|
74
|
-
"x-api-key":
|
|
86
|
+
"x-api-key": self._api_key,
|
|
75
87
|
},
|
|
76
88
|
timeout=20,
|
|
77
89
|
)
|
|
@@ -82,7 +94,6 @@ class LangTraceFile(io.BytesIO):
|
|
|
82
94
|
|
|
83
95
|
|
|
84
96
|
class LangTraceFileSystem(AbstractFileSystem):
|
|
85
|
-
_host: str = os.environ.get("LANGTRACE_API_HOST", None) or LANGTRACE_REMOTE_URL
|
|
86
97
|
protocol = "langtracefs"
|
|
87
98
|
sep = "/"
|
|
88
99
|
|
|
@@ -90,6 +101,19 @@ class LangTraceFileSystem(AbstractFileSystem):
|
|
|
90
101
|
super().__init__(*args, **kwargs)
|
|
91
102
|
self.files = {}
|
|
92
103
|
self.dirs = set()
|
|
104
|
+
self._host: str = os.environ.get("LANGTRACE_API_HOST", LANGTRACE_REMOTE_URL)
|
|
105
|
+
self._api_key: str = os.environ.get("LANGTRACE_API_KEY", None)
|
|
106
|
+
if self._host.endswith("/api/trace"):
|
|
107
|
+
self._host = self._host.replace("/api/trace", "")
|
|
108
|
+
|
|
109
|
+
if self._api_key is None:
|
|
110
|
+
print(Fore.RED)
|
|
111
|
+
print(
|
|
112
|
+
f"Missing Langtrace API key, proceed to {self._host} to create one"
|
|
113
|
+
)
|
|
114
|
+
print("Set the API key as an environment variable LANGTRACE_API_KEY")
|
|
115
|
+
print(Fore.RESET)
|
|
116
|
+
return
|
|
93
117
|
|
|
94
118
|
def open(
|
|
95
119
|
self,
|
|
@@ -118,7 +142,7 @@ class LangTraceFileSystem(AbstractFileSystem):
|
|
|
118
142
|
url=f"{self._host}/api/dataset/download?id={dataset_id}",
|
|
119
143
|
headers={
|
|
120
144
|
"Content-Type": "application/json",
|
|
121
|
-
"x-api-key":
|
|
145
|
+
"x-api-key": self._api_key,
|
|
122
146
|
},
|
|
123
147
|
timeout=20,
|
|
124
148
|
)
|
|
@@ -25,6 +25,7 @@ from langtrace_python_sdk.utils.llm import (
|
|
|
25
25
|
get_llm_url,
|
|
26
26
|
is_streaming,
|
|
27
27
|
set_event_completion,
|
|
28
|
+
set_event_completion_chunk,
|
|
28
29
|
set_usage_attributes,
|
|
29
30
|
)
|
|
30
31
|
from opentelemetry.trace import SpanKind
|
|
@@ -119,10 +120,7 @@ def messages_create(original_method, version, tracer):
|
|
|
119
120
|
# Assuming span.add_event is part of a larger logging or event system
|
|
120
121
|
# Add event for each chunk of content
|
|
121
122
|
if content:
|
|
122
|
-
span.
|
|
123
|
-
Event.STREAM_OUTPUT.value,
|
|
124
|
-
{SpanAttributes.LLM_CONTENT_COMPLETION_CHUNK: "".join(content)},
|
|
125
|
-
)
|
|
123
|
+
set_event_completion_chunk(span, "".join(content))
|
|
126
124
|
|
|
127
125
|
# Assuming this is part of a generator, yield chunk or aggregated content
|
|
128
126
|
yield content
|
|
@@ -22,6 +22,7 @@ from langtrace_python_sdk.utils.llm import (
|
|
|
22
22
|
get_extra_attributes,
|
|
23
23
|
get_llm_url,
|
|
24
24
|
set_event_completion,
|
|
25
|
+
set_event_completion_chunk,
|
|
25
26
|
set_usage_attributes,
|
|
26
27
|
)
|
|
27
28
|
from langtrace.trace_attributes import Event, LLMSpanAttributes
|
|
@@ -403,10 +404,7 @@ def chat_stream(original_method, version, tracer):
|
|
|
403
404
|
content = event.text
|
|
404
405
|
else:
|
|
405
406
|
content = ""
|
|
406
|
-
span.
|
|
407
|
-
Event.STREAM_OUTPUT.value,
|
|
408
|
-
{SpanAttributes.LLM_CONTENT_COMPLETION_CHUNK: "".join(content)},
|
|
409
|
-
)
|
|
407
|
+
set_event_completion_chunk(span, "".join(content))
|
|
410
408
|
|
|
411
409
|
if (
|
|
412
410
|
hasattr(event, "finish_reason")
|
|
@@ -30,6 +30,7 @@ from langtrace_python_sdk.utils.llm import (
|
|
|
30
30
|
get_llm_url,
|
|
31
31
|
get_langtrace_attributes,
|
|
32
32
|
set_event_completion,
|
|
33
|
+
set_event_completion_chunk,
|
|
33
34
|
set_usage_attributes,
|
|
34
35
|
)
|
|
35
36
|
from langtrace_python_sdk.constants.instrumentation.common import (
|
|
@@ -242,15 +243,14 @@ def chat_completions_create(original_method, version, tracer):
|
|
|
242
243
|
content = content + []
|
|
243
244
|
else:
|
|
244
245
|
content = []
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
},
|
|
246
|
+
|
|
247
|
+
set_event_completion_chunk(
|
|
248
|
+
span,
|
|
249
|
+
(
|
|
250
|
+
"".join(content)
|
|
251
|
+
if len(content) > 0 and content[0] is not None
|
|
252
|
+
else ""
|
|
253
|
+
),
|
|
254
254
|
)
|
|
255
255
|
result_content.append(content[0] if len(content) > 0 else "")
|
|
256
256
|
yield chunk
|
|
@@ -6,6 +6,7 @@ from langtrace_python_sdk.utils.llm import (
|
|
|
6
6
|
get_llm_request_attributes,
|
|
7
7
|
get_llm_url,
|
|
8
8
|
set_event_completion,
|
|
9
|
+
set_event_completion_chunk,
|
|
9
10
|
)
|
|
10
11
|
from langtrace_python_sdk.utils.silently_fail import silently_fail
|
|
11
12
|
from langtrace_python_sdk.constants.instrumentation.common import SERVICE_PROVIDERS
|
|
@@ -177,12 +178,8 @@ def _handle_streaming_response(span, response, api):
|
|
|
177
178
|
if api == "generate":
|
|
178
179
|
accumulated_tokens["response"] += chunk["response"]
|
|
179
180
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
SpanAttributes.LLM_CONTENT_COMPLETION_CHUNK: chunk.get("response")
|
|
184
|
-
or chunk.get("message").get("content"),
|
|
185
|
-
},
|
|
181
|
+
set_event_completion_chunk(
|
|
182
|
+
span, chunk.get("response") or chunk.get("message").get("content")
|
|
186
183
|
)
|
|
187
184
|
|
|
188
185
|
_set_response_attributes(span, chunk | accumulated_tokens)
|
|
@@ -211,12 +208,7 @@ async def _ahandle_streaming_response(span, response, api):
|
|
|
211
208
|
if api == "generate":
|
|
212
209
|
accumulated_tokens["response"] += chunk["response"]
|
|
213
210
|
|
|
214
|
-
span
|
|
215
|
-
Event.STREAM_OUTPUT.value,
|
|
216
|
-
{
|
|
217
|
-
SpanAttributes.LLM_CONTENT_COMPLETION_CHUNK: json.dumps(chunk),
|
|
218
|
-
},
|
|
219
|
-
)
|
|
211
|
+
set_event_completion_chunk(span, chunk)
|
|
220
212
|
_set_response_attributes(span, chunk | accumulated_tokens)
|
|
221
213
|
finally:
|
|
222
214
|
# Finalize span after processing all chunks
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/__init__.py
RENAMED
|
@@ -2,23 +2,32 @@ from openai import NOT_GIVEN
|
|
|
2
2
|
from .sdk_version_checker import SDKVersionChecker
|
|
3
3
|
from opentelemetry.trace import Span
|
|
4
4
|
from langtrace.trace_attributes import SpanAttributes
|
|
5
|
+
import os
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
def set_span_attribute(span: Span, name, value):
|
|
8
9
|
if value is not None:
|
|
9
10
|
if value != "" or value != NOT_GIVEN:
|
|
10
11
|
if name == SpanAttributes.LLM_PROMPTS:
|
|
11
|
-
span
|
|
12
|
-
name=SpanAttributes.LLM_CONTENT_PROMPT,
|
|
13
|
-
attributes={
|
|
14
|
-
SpanAttributes.LLM_PROMPTS: value,
|
|
15
|
-
},
|
|
16
|
-
)
|
|
12
|
+
set_event_prompt(span, value)
|
|
17
13
|
else:
|
|
18
14
|
span.set_attribute(name, value)
|
|
19
15
|
return
|
|
20
16
|
|
|
21
17
|
|
|
18
|
+
def set_event_prompt(span: Span, prompt):
|
|
19
|
+
enabled = os.environ.get("TRACE_PROMPT_COMPLETION_DATA", "true")
|
|
20
|
+
if enabled.lower() == "false":
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
span.add_event(
|
|
24
|
+
name=SpanAttributes.LLM_CONTENT_PROMPT,
|
|
25
|
+
attributes={
|
|
26
|
+
SpanAttributes.LLM_PROMPTS: prompt,
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
22
31
|
def check_if_sdk_is_outdated():
|
|
23
32
|
SDKVersionChecker().check()
|
|
24
33
|
return
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/langtrace_python_sdk/utils/llm.py
RENAMED
|
@@ -30,6 +30,7 @@ import json
|
|
|
30
30
|
from opentelemetry import baggage
|
|
31
31
|
from opentelemetry.trace import Span
|
|
32
32
|
from opentelemetry.trace.status import StatusCode
|
|
33
|
+
import os
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
def estimate_tokens(prompt):
|
|
@@ -42,6 +43,9 @@ def estimate_tokens(prompt):
|
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
def set_event_completion_chunk(span: Span, chunk):
|
|
46
|
+
enabled = os.environ.get("TRACE_PROMPT_COMPLETION_DATA", "true")
|
|
47
|
+
if enabled.lower() == "false":
|
|
48
|
+
return
|
|
45
49
|
span.add_event(
|
|
46
50
|
name=SpanAttributes.LLM_CONTENT_COMPLETION_CHUNK,
|
|
47
51
|
attributes={
|
|
@@ -203,6 +207,9 @@ def get_tool_calls(item):
|
|
|
203
207
|
|
|
204
208
|
|
|
205
209
|
def set_event_completion(span: Span, result_content):
|
|
210
|
+
enabled = os.environ.get("TRACE_PROMPT_COMPLETION_DATA", "true")
|
|
211
|
+
if enabled.lower() == "false":
|
|
212
|
+
return
|
|
206
213
|
|
|
207
214
|
span.add_event(
|
|
208
215
|
name=SpanAttributes.LLM_CONTENT_COMPLETION,
|
|
@@ -352,15 +359,9 @@ class StreamWrapper:
|
|
|
352
359
|
)
|
|
353
360
|
self.completion_tokens += token_counts
|
|
354
361
|
content.append(tool_call.function.arguments)
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
SpanAttributes.LLM_CONTENT_COMPLETION_CHUNK: (
|
|
359
|
-
"".join(content)
|
|
360
|
-
if len(content) > 0 and content[0] is not None
|
|
361
|
-
else ""
|
|
362
|
-
)
|
|
363
|
-
},
|
|
362
|
+
set_event_completion_chunk(
|
|
363
|
+
self.span,
|
|
364
|
+
"".join(content) if len(content) > 0 and content[0] is not None else "",
|
|
364
365
|
)
|
|
365
366
|
if content:
|
|
366
367
|
self.result_content.append(content[0])
|
|
@@ -369,16 +370,11 @@ class StreamWrapper:
|
|
|
369
370
|
token_counts = estimate_tokens(chunk.text)
|
|
370
371
|
self.completion_tokens += token_counts
|
|
371
372
|
content = [chunk.text]
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
SpanAttributes.LLM_CONTENT_COMPLETION_CHUNK: (
|
|
376
|
-
"".join(content)
|
|
377
|
-
if len(content) > 0 and content[0] is not None
|
|
378
|
-
else ""
|
|
379
|
-
)
|
|
380
|
-
},
|
|
373
|
+
set_event_completion_chunk(
|
|
374
|
+
self.span,
|
|
375
|
+
"".join(content) if len(content) > 0 and content[0] is not None else "",
|
|
381
376
|
)
|
|
377
|
+
|
|
382
378
|
if content:
|
|
383
379
|
self.result_content.append(content[0])
|
|
384
380
|
|
|
@@ -25,6 +25,9 @@ from opentelemetry import baggage, context, trace
|
|
|
25
25
|
from opentelemetry.trace import SpanKind
|
|
26
26
|
from opentelemetry.trace.propagation import set_span_in_context
|
|
27
27
|
|
|
28
|
+
from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
|
|
29
|
+
LANGTRACE_REMOTE_URL,
|
|
30
|
+
)
|
|
28
31
|
from langtrace_python_sdk.constants.instrumentation.common import (
|
|
29
32
|
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
|
|
30
33
|
)
|
|
@@ -142,7 +145,10 @@ class SendUserFeedback:
|
|
|
142
145
|
_langtrace_api_key: str
|
|
143
146
|
|
|
144
147
|
def __init__(self):
|
|
145
|
-
self._langtrace_host = os.environ
|
|
148
|
+
self._langtrace_host = os.environ.get("LANGTRACE_API_HOST", LANGTRACE_REMOTE_URL)
|
|
149
|
+
# When the host is set to /api/trace, remove the /api/trace
|
|
150
|
+
if self._langtrace_host.endswith("/api/trace"):
|
|
151
|
+
self._langtrace_host = self._langtrace_host.replace("/api/trace", "")
|
|
146
152
|
self._langtrace_api_key = os.environ.get("LANGTRACE_API_KEY", None)
|
|
147
153
|
|
|
148
154
|
def evaluate(self, data: EvaluationAPIData) -> None:
|
|
@@ -155,6 +161,16 @@ class SendUserFeedback:
|
|
|
155
161
|
print("Set the API key as an environment variable LANGTRACE_API_KEY")
|
|
156
162
|
print(Fore.RESET)
|
|
157
163
|
return
|
|
164
|
+
|
|
165
|
+
# convert spanId and traceId to hexadecimals
|
|
166
|
+
span_hex_number = hex(int(data["spanId"], 10))[2:] # Convert to hex and remove the '0x' prefix
|
|
167
|
+
formatted_span_hex_number = span_hex_number.zfill(16) # Pad with zeros to 16 characters
|
|
168
|
+
data["spanId"] = f"0x{formatted_span_hex_number}"
|
|
169
|
+
|
|
170
|
+
trace_hex_number = hex(int(data["traceId"], 10))[2:] # Convert to hex and remove the '0x' prefix
|
|
171
|
+
formatted_trace_hex_number = trace_hex_number.zfill(32) # Pad with zeros to 32 characters
|
|
172
|
+
data["traceId"] = f"0x{formatted_trace_hex_number}"
|
|
173
|
+
|
|
158
174
|
evaluation = self.get_evaluation(data["spanId"])
|
|
159
175
|
headers = {"x-api-key": self._langtrace_api_key}
|
|
160
176
|
if evaluation is not None:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.9"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.7"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/anthropic_example/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/chroma_example/__init__.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/chroma_example/basic.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/__init__.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/chat.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/chat_stream.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/embed.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/rerank.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/cohere_example/tools.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/crewai_example/basic.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/dspy_example/quiz_gen.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/dspy_example/react.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/fastapi_example/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/gemini_example/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/gemini_example/main.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/hiveagent_example/basic.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/__init__.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/basic.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/langchain_example/tool.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/llamaindex_example/agent.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/llamaindex_example/basic.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/ollama_example/__init__.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/ollama_example/basic.py
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/__init__.py
RENAMED
|
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.2.7 → langtrace_python_sdk-2.2.9}/src/examples/openai_example/images_edit.py
RENAMED
|
File without changes
|
|
File without changes
|