langtrace-python-sdk 3.3.14__tar.gz → 3.3.15__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/PKG-INFO +4 -3
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/__init__.py +6 -0
- langtrace_python_sdk-3.3.15/src/examples/cohere_example/chat_streamv2.py +17 -0
- langtrace_python_sdk-3.3.15/src/examples/cohere_example/chatv2.py +21 -0
- langtrace_python_sdk-3.3.15/src/examples/cohere_example/rerankv2.py +23 -0
- langtrace_python_sdk-3.3.15/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +2 -0
- langtrace_python_sdk-3.3.15/src/langtrace_python_sdk/constants/instrumentation/cohere.py +42 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +8 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +25 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +106 -8
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/dspy/patch.py +1 -1
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/patch.py +43 -4
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/langtrace.py +14 -6
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/llm.py +25 -3
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/with_root_span.py +11 -0
- langtrace_python_sdk-3.3.15/src/langtrace_python_sdk/version.py +1 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/run_example.py +2 -2
- langtrace_python_sdk-3.3.15/src/tests/openai/cassettes/test_embeddings_base_url.yaml +208 -0
- langtrace_python_sdk-3.3.15/src/tests/openai/test_embeddings.py +88 -0
- langtrace_python_sdk-3.3.15/src/tests/test_session_id.py +59 -0
- langtrace_python_sdk-3.3.14/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -1
- langtrace_python_sdk-3.3.14/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -22
- langtrace_python_sdk-3.3.14/src/langtrace_python_sdk/version.py +0 -1
- langtrace_python_sdk-3.3.14/src/tests/openai/test_embeddings.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/.gitignore +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/LICENSE +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/README.md +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/pyproject.toml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/anthropic_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/anthropic_example/completion.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/autogen_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/autogen_example/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/awsbedrock_examples/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/awsbedrock_examples/converse.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/azureopenai_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/azureopenai_example/completion.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cerebras_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cerebras_example/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/chroma_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/chroma_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/chat.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/chat_stream.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/embed.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/rerank.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/tools.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/agents.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/tasks.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/tools/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/instagram_post/tools/browser_tools.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/agents.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/simple_agent/tasks.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/agents.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/tasks.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/tools/calculator.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/crewai_example/trip_planner/tools/search_tools.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_basic_with_chain_of_thought.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_basic_with_signature.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/math_problems_cot.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/math_problems_cot_parallel.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/optimizers/bootstrap_fewshot.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/program_of_thought_basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/quiz_gen.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/dspy_example/react.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/embedchain_example/simple.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/fastapi_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/fastapi_example/basic_route.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/gemini_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/gemini_example/function_tools.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/gemini_example/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/hiveagent_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/inspect_ai_example/basic_eval.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/groq_example.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/langchain_google_example.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/langgraph_example.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/langgraph_example_tools.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/sagemaker.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langchain_example/tool.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/langgraph_example/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/litellm_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/litellm_example/config.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/litellm_example/proxy_basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/agent.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/llamaindex_example/data/abramov.txt +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/milvus_example/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/complete.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/complete_async.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/mistral_example/embeddings.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/mongo_vector_search_example/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/ollama_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/ollama_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/chat_completion.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/chat_completion_tool_choice.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/embeddings_create.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/function_calling.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/images_edit.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/images_generate.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/resources/lounge_flamingo.png +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/resources/mask.png +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/send_user_feedback.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/tool_calling.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/openai_example/tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/otlp_example/otlp_basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/otlp_example/otlp_with_langtrace.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/perplexity_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/pinecone_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/pinecone_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/qdrant_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/qdrant_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/routellm_example/basic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/vertexai_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/vertexai_example/main.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/weaviate_example/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/weaviate_example/query_text.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/aws_bedrock.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/embedchain.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/gemini.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/litellm.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/milvus.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/mistral.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/ollama.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/pymongo.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/vertexai.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/constants/instrumentation/weaviate.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/extensions/langtrace_filesystem.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/anthropic/types.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/autogen/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/autogen/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/autogen/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/aws_bedrock/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/aws_bedrock/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/aws_bedrock/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cerebras/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cerebras/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cerebras/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/crewai/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/crewai/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/crewai/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/dspy/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/embedchain/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/embedchain/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/embedchain/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/gemini/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/gemini/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/gemini/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/litellm/types.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/milvus/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/milvus/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/milvus/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/mistral/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/mistral/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/mistral/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/ollama/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/ollama/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/ollama/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/openai/types.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pymongo/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pymongo/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/pymongo/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/vertexai/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/vertexai/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/vertexai/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/weaviate/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/instrumentation/weaviate/patch.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/types/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/langtrace_sampler.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/misc.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/prompt_registry.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/sdk_version_checker.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/silently_fail.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/types.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/__init__.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/anthropic/test_anthropic.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/chroma/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/chroma/test_chroma.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_chat.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_embed.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/cassettes/test_cohere_rerank.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/test_cohere_chat.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/test_cohere_embed.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/cohere/test_cohere_rerank.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_async_chat_completion.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/groq/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/groq/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/groq/test_groq.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/langchain/cassettes/test_langchain.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/langchain/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/langchain/test_langchain.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/test_chat_completion.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/openai/test_image_generation.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/cassettes/test_query.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/cassettes/test_upsert.yaml +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/pinecone/test_pinecone.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/qdrant/conftest.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/qdrant/test_qdrant.py +0 -0
- {langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/tests/utils.py +0 -0
@@ -1,10 +1,11 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: langtrace-python-sdk
|
3
|
-
Version: 3.3.
|
3
|
+
Version: 3.3.15
|
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>
|
7
|
-
License: Apache-2.0
|
7
|
+
License-Expression: Apache-2.0
|
8
|
+
License-File: LICENSE
|
8
9
|
Classifier: License :: OSI Approved :: Apache Software License
|
9
10
|
Classifier: Operating System :: OS Independent
|
10
11
|
Classifier: Programming Language :: Python :: 3
|
{langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/examples/cohere_example/__init__.py
RENAMED
@@ -1,8 +1,11 @@
|
|
1
1
|
from examples.cohere_example.chat import chat_comp
|
2
|
+
from examples.cohere_example.chatv2 import chat_v2
|
3
|
+
from examples.cohere_example.chat_streamv2 import chat_stream_v2
|
2
4
|
from examples.cohere_example.chat_stream import chat_stream
|
3
5
|
from examples.cohere_example.tools import tool_calling
|
4
6
|
from examples.cohere_example.embed import embed
|
5
7
|
from examples.cohere_example.rerank import rerank
|
8
|
+
from examples.cohere_example.rerankv2 import rerank_v2
|
6
9
|
from langtrace_python_sdk import with_langtrace_root_span
|
7
10
|
|
8
11
|
|
@@ -10,8 +13,11 @@ class CohereRunner:
|
|
10
13
|
|
11
14
|
@with_langtrace_root_span("Cohere")
|
12
15
|
def run(self):
|
16
|
+
chat_v2()
|
17
|
+
chat_stream_v2()
|
13
18
|
chat_comp()
|
14
19
|
chat_stream()
|
15
20
|
tool_calling()
|
16
21
|
embed()
|
17
22
|
rerank()
|
23
|
+
rerank_v2()
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import os
|
2
|
+
from langtrace_python_sdk import langtrace
|
3
|
+
import cohere
|
4
|
+
|
5
|
+
langtrace.init(api_key=os.getenv("LANGTRACE_API_KEY"))
|
6
|
+
co = cohere.ClientV2(api_key=os.getenv("COHERE_API_KEY"))
|
7
|
+
|
8
|
+
def chat_stream_v2():
|
9
|
+
res = co.chat_stream(
|
10
|
+
model="command-r-plus-08-2024",
|
11
|
+
messages=[{"role": "user", "content": "Write a title for a blog post about API design. Only output the title text"}],
|
12
|
+
)
|
13
|
+
|
14
|
+
for event in res:
|
15
|
+
if event:
|
16
|
+
if event.type == "content-delta":
|
17
|
+
print(event.delta.message.content.text)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import os
|
2
|
+
from langtrace_python_sdk import langtrace
|
3
|
+
import cohere
|
4
|
+
|
5
|
+
langtrace.init(api_key=os.getenv("LANGTRACE_API_KEY"))
|
6
|
+
|
7
|
+
|
8
|
+
def chat_v2():
|
9
|
+
co = cohere.ClientV2(api_key=os.getenv("COHERE_API_KEY"))
|
10
|
+
|
11
|
+
res = co.chat(
|
12
|
+
model="command-r-plus-08-2024",
|
13
|
+
messages=[
|
14
|
+
{
|
15
|
+
"role": "user",
|
16
|
+
"content": "Write a title for a blog post about API design. Only output the title text.",
|
17
|
+
}
|
18
|
+
],
|
19
|
+
)
|
20
|
+
|
21
|
+
print(res.message.content[0].text)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import os
|
2
|
+
from langtrace_python_sdk import langtrace
|
3
|
+
import cohere
|
4
|
+
|
5
|
+
langtrace.init(api_key=os.getenv("LANGTRACE_API_KEY"))
|
6
|
+
co = cohere.ClientV2(api_key=os.getenv("COHERE_API_KEY"))
|
7
|
+
|
8
|
+
docs = [
|
9
|
+
"Carson City is the capital city of the American state of Nevada.",
|
10
|
+
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
|
11
|
+
"Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.",
|
12
|
+
"Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
|
13
|
+
"Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.",
|
14
|
+
]
|
15
|
+
|
16
|
+
def rerank_v2():
|
17
|
+
response = co.rerank(
|
18
|
+
model="rerank-v3.5",
|
19
|
+
query="What is the capital of the United States?",
|
20
|
+
documents=docs,
|
21
|
+
top_n=3,
|
22
|
+
)
|
23
|
+
print(response)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
APIS = {
|
2
|
+
"CHAT_CREATE": {
|
3
|
+
"URL": "https://api.cohere.ai",
|
4
|
+
"METHOD": "cohere.client.chat",
|
5
|
+
"ENDPOINT": "/v1/chat",
|
6
|
+
},
|
7
|
+
"CHAT_CREATE_V2": {
|
8
|
+
"URL": "https://api.cohere.ai",
|
9
|
+
"METHOD": "cohere.client_v2.chat",
|
10
|
+
"ENDPOINT": "/v2/chat",
|
11
|
+
},
|
12
|
+
"EMBED": {
|
13
|
+
"URL": "https://api.cohere.ai",
|
14
|
+
"METHOD": "cohere.client.embed",
|
15
|
+
"ENDPOINT": "/v1/embed",
|
16
|
+
},
|
17
|
+
"EMBED_V2": {
|
18
|
+
"URL": "https://api.cohere.ai",
|
19
|
+
"METHOD": "cohere.client_v2.embed",
|
20
|
+
"ENDPOINT": "/v2/embed",
|
21
|
+
},
|
22
|
+
"CHAT_STREAM": {
|
23
|
+
"URL": "https://api.cohere.ai",
|
24
|
+
"METHOD": "cohere.client.chat_stream",
|
25
|
+
"ENDPOINT": "/v1/chat",
|
26
|
+
},
|
27
|
+
"CHAT_STREAM_V2": {
|
28
|
+
"URL": "https://api.cohere.ai",
|
29
|
+
"METHOD": "cohere.client_v2.chat_stream",
|
30
|
+
"ENDPOINT": "/v2/chat",
|
31
|
+
},
|
32
|
+
"RERANK": {
|
33
|
+
"URL": "https://api.cohere.ai",
|
34
|
+
"METHOD": "cohere.client.rerank",
|
35
|
+
"ENDPOINT": "/v1/rerank",
|
36
|
+
},
|
37
|
+
"RERANK_V2": {
|
38
|
+
"URL": "https://api.cohere.ai",
|
39
|
+
"METHOD": "cohere.client_v2.rerank",
|
40
|
+
"ENDPOINT": "/v2/rerank",
|
41
|
+
},
|
42
|
+
}
|
@@ -9,6 +9,7 @@ from opentelemetry.trace.span import format_trace_id
|
|
9
9
|
|
10
10
|
from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
|
11
11
|
LANGTRACE_REMOTE_URL,
|
12
|
+
LANGTRACE_SESSION_ID_HEADER,
|
12
13
|
)
|
13
14
|
from colorama import Fore
|
14
15
|
from requests.exceptions import RequestException
|
@@ -51,12 +52,14 @@ class LangTraceExporter(SpanExporter):
|
|
51
52
|
api_key: str
|
52
53
|
api_host: str
|
53
54
|
disable_logging: bool
|
55
|
+
session_id: str
|
54
56
|
|
55
57
|
def __init__(
|
56
58
|
self,
|
57
59
|
api_host,
|
58
60
|
api_key: str = None,
|
59
61
|
disable_logging: bool = False,
|
62
|
+
session_id: str = None,
|
60
63
|
) -> None:
|
61
64
|
self.api_key = api_key or os.environ.get("LANGTRACE_API_KEY")
|
62
65
|
self.api_host = (
|
@@ -65,6 +68,7 @@ class LangTraceExporter(SpanExporter):
|
|
65
68
|
else api_host
|
66
69
|
)
|
67
70
|
self.disable_logging = disable_logging
|
71
|
+
self.session_id = session_id or os.environ.get("LANGTRACE_SESSION_ID")
|
68
72
|
|
69
73
|
def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
|
70
74
|
"""
|
@@ -82,6 +86,10 @@ class LangTraceExporter(SpanExporter):
|
|
82
86
|
"User-Agent": "LangtraceExporter",
|
83
87
|
}
|
84
88
|
|
89
|
+
# Add session ID if available
|
90
|
+
if self.session_id:
|
91
|
+
headers[LANGTRACE_SESSION_ID_HEADER] = self.session_id
|
92
|
+
|
85
93
|
# Check if the OTEL_EXPORTER_OTLP_HEADERS environment variable is set
|
86
94
|
otel_headers = os.getenv("OTEL_EXPORTER_OTLP_HEADERS", None)
|
87
95
|
if otel_headers:
|
@@ -23,6 +23,7 @@ from wrapt import wrap_function_wrapper
|
|
23
23
|
|
24
24
|
from langtrace_python_sdk.instrumentation.cohere.patch import (
|
25
25
|
chat_create,
|
26
|
+
chat_create_v2,
|
26
27
|
chat_stream,
|
27
28
|
embed,
|
28
29
|
rerank,
|
@@ -48,6 +49,18 @@ class CohereInstrumentation(BaseInstrumentor):
|
|
48
49
|
chat_create("cohere.client.chat", version, tracer),
|
49
50
|
)
|
50
51
|
|
52
|
+
wrap_function_wrapper(
|
53
|
+
"cohere.client_v2",
|
54
|
+
"ClientV2.chat",
|
55
|
+
chat_create_v2("cohere.client_v2.chat", version, tracer),
|
56
|
+
)
|
57
|
+
|
58
|
+
wrap_function_wrapper(
|
59
|
+
"cohere.client_v2",
|
60
|
+
"ClientV2.chat_stream",
|
61
|
+
chat_create_v2("cohere.client_v2.chat", version, tracer, stream=True),
|
62
|
+
)
|
63
|
+
|
51
64
|
wrap_function_wrapper(
|
52
65
|
"cohere.client",
|
53
66
|
"Client.chat_stream",
|
@@ -60,12 +73,24 @@ class CohereInstrumentation(BaseInstrumentor):
|
|
60
73
|
embed("cohere.client.embed", version, tracer),
|
61
74
|
)
|
62
75
|
|
76
|
+
wrap_function_wrapper(
|
77
|
+
"cohere.client_v2",
|
78
|
+
"ClientV2.embed",
|
79
|
+
embed("cohere.client.embed", version, tracer, v2=True),
|
80
|
+
)
|
81
|
+
|
63
82
|
wrap_function_wrapper(
|
64
83
|
"cohere.client",
|
65
84
|
"Client.rerank",
|
66
85
|
rerank("cohere.client.rerank", version, tracer),
|
67
86
|
)
|
68
87
|
|
88
|
+
wrap_function_wrapper(
|
89
|
+
"cohere.client_v2",
|
90
|
+
"ClientV2.rerank",
|
91
|
+
rerank("cohere.client.rerank", version, tracer, v2=True),
|
92
|
+
)
|
93
|
+
|
69
94
|
def _instrument_module(self, module_name):
|
70
95
|
pass
|
71
96
|
|
@@ -24,6 +24,7 @@ from langtrace_python_sdk.utils.llm import (
|
|
24
24
|
get_span_name,
|
25
25
|
set_event_completion,
|
26
26
|
set_usage_attributes,
|
27
|
+
StreamWrapper
|
27
28
|
)
|
28
29
|
from langtrace.trace_attributes import Event, LLMSpanAttributes
|
29
30
|
from langtrace_python_sdk.utils import set_span_attribute
|
@@ -38,7 +39,7 @@ from langtrace_python_sdk.constants.instrumentation.common import (
|
|
38
39
|
from langtrace.trace_attributes import SpanAttributes
|
39
40
|
|
40
41
|
|
41
|
-
def rerank(original_method, version, tracer):
|
42
|
+
def rerank(original_method, version, tracer, v2=False):
|
42
43
|
"""Wrap the `rerank` method."""
|
43
44
|
|
44
45
|
def traced_method(wrapped, instance, args, kwargs):
|
@@ -49,8 +50,8 @@ def rerank(original_method, version, tracer):
|
|
49
50
|
**get_llm_request_attributes(kwargs, operation_name="rerank"),
|
50
51
|
**get_llm_url(instance),
|
51
52
|
SpanAttributes.LLM_REQUEST_MODEL: kwargs.get("model") or "command-r-plus",
|
52
|
-
SpanAttributes.LLM_URL: APIS["RERANK"]["URL"],
|
53
|
-
SpanAttributes.LLM_PATH: APIS["RERANK"]["ENDPOINT"],
|
53
|
+
SpanAttributes.LLM_URL: APIS["RERANK" if not v2 else "RERANK_V2"]["URL"],
|
54
|
+
SpanAttributes.LLM_PATH: APIS["RERANK" if not v2 else "RERANK_V2"]["ENDPOINT"],
|
54
55
|
SpanAttributes.LLM_REQUEST_DOCUMENTS: json.dumps(
|
55
56
|
kwargs.get("documents"), cls=datetime_encoder
|
56
57
|
),
|
@@ -61,7 +62,7 @@ def rerank(original_method, version, tracer):
|
|
61
62
|
attributes = LLMSpanAttributes(**span_attributes)
|
62
63
|
|
63
64
|
span = tracer.start_span(
|
64
|
-
name=get_span_name(APIS["RERANK"]["METHOD"]), kind=SpanKind.CLIENT
|
65
|
+
name=get_span_name(APIS["RERANK" if not v2 else "RERANK_V2"]["METHOD"]), kind=SpanKind.CLIENT
|
65
66
|
)
|
66
67
|
for field, value in attributes.model_dump(by_alias=True).items():
|
67
68
|
set_span_attribute(span, field, value)
|
@@ -119,7 +120,7 @@ def rerank(original_method, version, tracer):
|
|
119
120
|
return traced_method
|
120
121
|
|
121
122
|
|
122
|
-
def embed(original_method, version, tracer):
|
123
|
+
def embed(original_method, version, tracer, v2=False):
|
123
124
|
"""Wrap the `embed` method."""
|
124
125
|
|
125
126
|
def traced_method(wrapped, instance, args, kwargs):
|
@@ -129,8 +130,8 @@ def embed(original_method, version, tracer):
|
|
129
130
|
**get_langtrace_attributes(version, service_provider),
|
130
131
|
**get_llm_request_attributes(kwargs, operation_name="embed"),
|
131
132
|
**get_llm_url(instance),
|
132
|
-
SpanAttributes.LLM_URL: APIS["EMBED"]["URL"],
|
133
|
-
SpanAttributes.LLM_PATH: APIS["EMBED"]["ENDPOINT"],
|
133
|
+
SpanAttributes.LLM_URL: APIS["EMBED" if not v2 else "EMBED_V2"]["URL"],
|
134
|
+
SpanAttributes.LLM_PATH: APIS["EMBED" if not v2 else "EMBED_V2"]["ENDPOINT"],
|
134
135
|
SpanAttributes.LLM_REQUEST_EMBEDDING_INPUTS: json.dumps(
|
135
136
|
kwargs.get("texts")
|
136
137
|
),
|
@@ -143,7 +144,7 @@ def embed(original_method, version, tracer):
|
|
143
144
|
attributes = LLMSpanAttributes(**span_attributes)
|
144
145
|
|
145
146
|
span = tracer.start_span(
|
146
|
-
name=get_span_name(APIS["EMBED"]["METHOD"]),
|
147
|
+
name=get_span_name(APIS["EMBED" if not v2 else "EMBED_V2"]["METHOD"]),
|
147
148
|
kind=SpanKind.CLIENT,
|
148
149
|
)
|
149
150
|
for field, value in attributes.model_dump(by_alias=True).items():
|
@@ -343,6 +344,103 @@ def chat_create(original_method, version, tracer):
|
|
343
344
|
return traced_method
|
344
345
|
|
345
346
|
|
347
|
+
def chat_create_v2(original_method, version, tracer, stream=False):
|
348
|
+
"""Wrap the `chat_create` method for Cohere API v2."""
|
349
|
+
|
350
|
+
def traced_method(wrapped, instance, args, kwargs):
|
351
|
+
service_provider = SERVICE_PROVIDERS["COHERE"]
|
352
|
+
|
353
|
+
messages = kwargs.get("messages", [])
|
354
|
+
if kwargs.get("preamble"):
|
355
|
+
messages = [{"role": "system", "content": kwargs["preamble"]}] + messages
|
356
|
+
|
357
|
+
span_attributes = {
|
358
|
+
**get_langtrace_attributes(version, service_provider),
|
359
|
+
**get_llm_request_attributes(kwargs, prompts=messages),
|
360
|
+
**get_llm_url(instance),
|
361
|
+
SpanAttributes.LLM_REQUEST_MODEL: kwargs.get("model") or "command-r-plus",
|
362
|
+
SpanAttributes.LLM_URL: APIS["CHAT_CREATE_V2"]["URL"],
|
363
|
+
SpanAttributes.LLM_PATH: APIS["CHAT_CREATE_V2"]["ENDPOINT"],
|
364
|
+
**get_extra_attributes(),
|
365
|
+
}
|
366
|
+
|
367
|
+
attributes = LLMSpanAttributes(**span_attributes)
|
368
|
+
|
369
|
+
for attr_name in ["max_input_tokens", "conversation_id", "connectors", "tools", "tool_results"]:
|
370
|
+
value = kwargs.get(attr_name)
|
371
|
+
if value is not None:
|
372
|
+
if attr_name == "max_input_tokens":
|
373
|
+
attributes.llm_max_input_tokens = str(value)
|
374
|
+
elif attr_name == "conversation_id":
|
375
|
+
attributes.conversation_id = value
|
376
|
+
else:
|
377
|
+
setattr(attributes, f"llm_{attr_name}", json.dumps(value))
|
378
|
+
|
379
|
+
span = tracer.start_span(
|
380
|
+
name=get_span_name(APIS["CHAT_CREATE_V2"]["METHOD"]),
|
381
|
+
kind=SpanKind.CLIENT
|
382
|
+
)
|
383
|
+
|
384
|
+
for field, value in attributes.model_dump(by_alias=True).items():
|
385
|
+
set_span_attribute(span, field, value)
|
386
|
+
|
387
|
+
try:
|
388
|
+
result = wrapped(*args, **kwargs)
|
389
|
+
|
390
|
+
if stream:
|
391
|
+
return StreamWrapper(
|
392
|
+
result,
|
393
|
+
span,
|
394
|
+
tool_calls=kwargs.get("tools") is not None,
|
395
|
+
)
|
396
|
+
else:
|
397
|
+
if hasattr(result, "id") and result.id is not None:
|
398
|
+
span.set_attribute(SpanAttributes.LLM_GENERATION_ID, result.id)
|
399
|
+
span.set_attribute(SpanAttributes.LLM_RESPONSE_ID, result.id)
|
400
|
+
|
401
|
+
if (hasattr(result, "message") and
|
402
|
+
hasattr(result.message, "content") and
|
403
|
+
len(result.message.content) > 0 and
|
404
|
+
hasattr(result.message.content[0], "text") and
|
405
|
+
result.message.content[0].text is not None and
|
406
|
+
result.message.content[0].text != ""):
|
407
|
+
responses = [{
|
408
|
+
"role": result.message.role,
|
409
|
+
"content": result.message.content[0].text
|
410
|
+
}]
|
411
|
+
set_event_completion(span, responses)
|
412
|
+
if hasattr(result, "tool_calls") and result.tool_calls is not None:
|
413
|
+
tool_calls = [tool_call.json() for tool_call in result.tool_calls]
|
414
|
+
span.set_attribute(
|
415
|
+
SpanAttributes.LLM_TOOL_RESULTS,
|
416
|
+
json.dumps(tool_calls)
|
417
|
+
)
|
418
|
+
if hasattr(result, "usage") and result.usage is not None:
|
419
|
+
if (hasattr(result.usage, "billed_units") and
|
420
|
+
result.usage.billed_units is not None):
|
421
|
+
usage = result.usage.billed_units
|
422
|
+
for metric, value in {
|
423
|
+
"input": usage.input_tokens or 0,
|
424
|
+
"output": usage.output_tokens or 0,
|
425
|
+
"total": (usage.input_tokens or 0) + (usage.output_tokens or 0),
|
426
|
+
}.items():
|
427
|
+
span.set_attribute(
|
428
|
+
f"gen_ai.usage.{metric}_tokens",
|
429
|
+
int(value)
|
430
|
+
)
|
431
|
+
span.set_status(StatusCode.OK)
|
432
|
+
span.end()
|
433
|
+
return result
|
434
|
+
|
435
|
+
except Exception as error:
|
436
|
+
span.record_exception(error)
|
437
|
+
span.set_status(Status(StatusCode.ERROR, str(error)))
|
438
|
+
span.end()
|
439
|
+
raise
|
440
|
+
|
441
|
+
return traced_method
|
442
|
+
|
443
|
+
|
346
444
|
def chat_stream(original_method, version, tracer):
|
347
445
|
"""Wrap the `messages_stream` method."""
|
348
446
|
|
@@ -50,7 +50,7 @@ def patch_bootstrapfewshot_optimizer(operation_name, version, tracer):
|
|
50
50
|
),
|
51
51
|
}
|
52
52
|
span_attributes["dspy.optimizer.module.prog"] = json.dumps(prog)
|
53
|
-
if hasattr(instance, "metric"):
|
53
|
+
if hasattr(instance, "metric") and getattr(instance, "metric") is not None:
|
54
54
|
span_attributes["dspy.optimizer.metric"] = getattr(
|
55
55
|
instance, "metric"
|
56
56
|
).__name__
|
@@ -342,8 +342,12 @@ def async_chat_completions_create(version: str, tracer: Tracer) -> Callable:
|
|
342
342
|
service_provider = SERVICE_PROVIDERS["PPLX"]
|
343
343
|
elif "azure" in get_base_url(instance):
|
344
344
|
service_provider = SERVICE_PROVIDERS["AZURE"]
|
345
|
+
elif "groq" in get_base_url(instance):
|
346
|
+
service_provider = SERVICE_PROVIDERS["GROQ"]
|
345
347
|
elif "x.ai" in get_base_url(instance):
|
346
348
|
service_provider = SERVICE_PROVIDERS["XAI"]
|
349
|
+
elif "deepseek" in get_base_url(instance):
|
350
|
+
service_provider = SERVICE_PROVIDERS["DEEPSEEK"]
|
347
351
|
llm_prompts = []
|
348
352
|
for item in kwargs.get("messages", []):
|
349
353
|
tools = get_tool_calls(item)
|
@@ -431,6 +435,18 @@ def embeddings_create(version: str, tracer: Tracer) -> Callable:
|
|
431
435
|
kwargs: EmbeddingsCreateKwargs,
|
432
436
|
) -> Any:
|
433
437
|
service_provider = SERVICE_PROVIDERS["OPENAI"]
|
438
|
+
base_url = get_base_url(instance)
|
439
|
+
|
440
|
+
if "perplexity" in base_url:
|
441
|
+
service_provider = SERVICE_PROVIDERS["PPLX"]
|
442
|
+
elif "azure" in base_url:
|
443
|
+
service_provider = SERVICE_PROVIDERS["AZURE"]
|
444
|
+
elif "groq" in base_url:
|
445
|
+
service_provider = SERVICE_PROVIDERS["GROQ"]
|
446
|
+
elif "x.ai" in base_url:
|
447
|
+
service_provider = SERVICE_PROVIDERS["XAI"]
|
448
|
+
elif "deepseek" in base_url:
|
449
|
+
service_provider = SERVICE_PROVIDERS["DEEPSEEK"]
|
434
450
|
|
435
451
|
span_attributes = {
|
436
452
|
**get_langtrace_attributes(version, service_provider, vendor_type="llm"),
|
@@ -469,7 +485,6 @@ def embeddings_create(version: str, tracer: Tracer) -> Callable:
|
|
469
485
|
kind=SpanKind.CLIENT,
|
470
486
|
context=set_span_in_context(trace.get_current_span()),
|
471
487
|
) as span:
|
472
|
-
|
473
488
|
set_span_attributes(span, attributes)
|
474
489
|
try:
|
475
490
|
# Attempt to call the original method
|
@@ -507,17 +522,27 @@ def async_embeddings_create(version: str, tracer: Tracer) -> Callable:
|
|
507
522
|
) -> Awaitable[Any]:
|
508
523
|
|
509
524
|
service_provider = SERVICE_PROVIDERS["OPENAI"]
|
525
|
+
base_url = get_base_url(instance)
|
526
|
+
if "perplexity" in base_url:
|
527
|
+
service_provider = SERVICE_PROVIDERS["PPLX"]
|
528
|
+
elif "azure" in base_url:
|
529
|
+
service_provider = SERVICE_PROVIDERS["AZURE"]
|
530
|
+
elif "groq" in base_url:
|
531
|
+
service_provider = SERVICE_PROVIDERS["GROQ"]
|
532
|
+
elif "x.ai" in base_url:
|
533
|
+
service_provider = SERVICE_PROVIDERS["XAI"]
|
534
|
+
elif "deepseek" in base_url:
|
535
|
+
service_provider = SERVICE_PROVIDERS["DEEPSEEK"]
|
510
536
|
|
511
537
|
span_attributes = {
|
512
538
|
**get_langtrace_attributes(version, service_provider, vendor_type="llm"),
|
513
539
|
**get_llm_request_attributes(kwargs, operation_name="embed"),
|
540
|
+
**get_llm_url(instance),
|
514
541
|
SpanAttributes.LLM_PATH: APIS["EMBEDDINGS_CREATE"]["ENDPOINT"],
|
515
542
|
SpanAttributes.LLM_REQUEST_DIMENSIONS: kwargs.get("dimensions"),
|
516
543
|
**get_extra_attributes(), # type: ignore
|
517
544
|
}
|
518
545
|
|
519
|
-
attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
|
520
|
-
|
521
546
|
encoding_format = kwargs.get("encoding_format")
|
522
547
|
if encoding_format is not None:
|
523
548
|
if not isinstance(encoding_format, list):
|
@@ -530,17 +555,31 @@ def async_embeddings_create(version: str, tracer: Tracer) -> Callable:
|
|
530
555
|
span_attributes[SpanAttributes.LLM_REQUEST_EMBEDDING_INPUTS] = json.dumps(
|
531
556
|
[kwargs.get("input", "")]
|
532
557
|
)
|
558
|
+
span_attributes[SpanAttributes.LLM_PROMPTS] = json.dumps(
|
559
|
+
[
|
560
|
+
{
|
561
|
+
"role": "user",
|
562
|
+
"content": kwargs.get("input"),
|
563
|
+
}
|
564
|
+
]
|
565
|
+
)
|
566
|
+
|
567
|
+
attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
|
533
568
|
|
534
569
|
with tracer.start_as_current_span(
|
535
570
|
name=get_span_name(APIS["EMBEDDINGS_CREATE"]["METHOD"]),
|
536
571
|
kind=SpanKind.CLIENT,
|
537
572
|
context=set_span_in_context(trace.get_current_span()),
|
538
573
|
) as span:
|
539
|
-
|
540
574
|
set_span_attributes(span, attributes)
|
541
575
|
try:
|
542
576
|
# Attempt to call the original method
|
543
577
|
result = await wrapped(*args, **kwargs)
|
578
|
+
usage = getattr(result, "usage", None)
|
579
|
+
if usage:
|
580
|
+
set_usage_attributes(
|
581
|
+
span, {"prompt_tokens": getattr(usage, "prompt_tokens", 0)}
|
582
|
+
)
|
544
583
|
span.set_status(StatusCode.OK)
|
545
584
|
return result
|
546
585
|
except Exception as err:
|
{langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/langtrace.py
RENAMED
@@ -39,6 +39,7 @@ from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
|
|
39
39
|
)
|
40
40
|
from langtrace_python_sdk.constants.exporter.langtrace_exporter import (
|
41
41
|
LANGTRACE_REMOTE_URL,
|
42
|
+
LANGTRACE_SESSION_ID_HEADER,
|
42
43
|
)
|
43
44
|
from langtrace_python_sdk.instrumentation import (
|
44
45
|
AnthropicInstrumentation,
|
@@ -98,6 +99,7 @@ class LangtraceConfig:
|
|
98
99
|
or os.environ.get("LANGTRACE_HEADERS")
|
99
100
|
or os.environ.get("OTEL_EXPORTER_OTLP_HEADERS")
|
100
101
|
)
|
102
|
+
self.session_id = kwargs.get("session_id") or os.environ.get("LANGTRACE_SESSION_ID")
|
101
103
|
|
102
104
|
|
103
105
|
def get_host(config: LangtraceConfig) -> str:
|
@@ -134,15 +136,19 @@ def setup_tracer_provider(config: LangtraceConfig, host: str) -> TracerProvider:
|
|
134
136
|
|
135
137
|
|
136
138
|
def get_headers(config: LangtraceConfig):
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
139
|
+
headers = {
|
140
|
+
"x-api-key": config.api_key,
|
141
|
+
}
|
142
|
+
|
143
|
+
if config.session_id:
|
144
|
+
headers[LANGTRACE_SESSION_ID_HEADER] = config.session_id
|
141
145
|
|
142
146
|
if isinstance(config.headers, str):
|
143
|
-
|
147
|
+
headers.update(parse_env_headers(config.headers, liberal=True))
|
148
|
+
elif config.headers:
|
149
|
+
headers.update(config.headers)
|
144
150
|
|
145
|
-
return
|
151
|
+
return headers
|
146
152
|
|
147
153
|
|
148
154
|
def get_exporter(config: LangtraceConfig, host: str):
|
@@ -215,6 +221,7 @@ def init(
|
|
215
221
|
service_name: Optional[str] = None,
|
216
222
|
disable_logging: bool = False,
|
217
223
|
headers: Dict[str, str] = {},
|
224
|
+
session_id: Optional[str] = None,
|
218
225
|
):
|
219
226
|
|
220
227
|
check_if_sdk_is_outdated()
|
@@ -229,6 +236,7 @@ def init(
|
|
229
236
|
service_name=service_name,
|
230
237
|
disable_logging=disable_logging,
|
231
238
|
headers=headers,
|
239
|
+
session_id=session_id,
|
232
240
|
)
|
233
241
|
|
234
242
|
if config.disable_logging:
|
{langtrace_python_sdk-3.3.14 → langtrace_python_sdk-3.3.15}/src/langtrace_python_sdk/utils/llm.py
RENAMED
@@ -162,11 +162,12 @@ def get_llm_url(instance):
|
|
162
162
|
|
163
163
|
|
164
164
|
def get_base_url(instance):
|
165
|
-
|
165
|
+
base_url = (
|
166
166
|
str(instance._client._base_url)
|
167
167
|
if hasattr(instance, "_client") and hasattr(instance._client, "_base_url")
|
168
168
|
else ""
|
169
169
|
)
|
170
|
+
return base_url
|
170
171
|
|
171
172
|
|
172
173
|
def is_streaming(kwargs):
|
@@ -393,8 +394,19 @@ class StreamWrapper:
|
|
393
394
|
if hasattr(chunk, "text") and chunk.text is not None:
|
394
395
|
content = [chunk.text]
|
395
396
|
|
397
|
+
# CohereV2
|
398
|
+
if (hasattr(chunk, "delta") and
|
399
|
+
chunk.delta is not None and
|
400
|
+
hasattr(chunk.delta, "message") and
|
401
|
+
chunk.delta.message is not None and
|
402
|
+
hasattr(chunk.delta.message, "content") and
|
403
|
+
chunk.delta.message.content is not None and
|
404
|
+
hasattr(chunk.delta.message.content, "text") and
|
405
|
+
chunk.delta.message.content.text is not None):
|
406
|
+
content = [chunk.delta.message.content.text]
|
407
|
+
|
396
408
|
# Anthropic
|
397
|
-
if hasattr(chunk, "delta") and chunk.delta is not None:
|
409
|
+
if hasattr(chunk, "delta") and chunk.delta is not None and not hasattr(chunk.delta, "message"):
|
398
410
|
content = [chunk.delta.text] if hasattr(chunk.delta, "text") else []
|
399
411
|
|
400
412
|
if isinstance(chunk, dict):
|
@@ -408,7 +420,17 @@ class StreamWrapper:
|
|
408
420
|
|
409
421
|
# Anthropic & OpenAI
|
410
422
|
if hasattr(chunk, "type") and chunk.type == "message_start":
|
411
|
-
|
423
|
+
if hasattr(chunk.message, "usage") and chunk.message.usage is not None:
|
424
|
+
self.prompt_tokens = chunk.message.usage.input_tokens
|
425
|
+
|
426
|
+
# CohereV2
|
427
|
+
if hasattr(chunk, "type") and chunk.type == "message-end":
|
428
|
+
if (hasattr(chunk, "delta") and chunk.delta is not None and
|
429
|
+
hasattr(chunk.delta, "usage") and chunk.delta.usage is not None and
|
430
|
+
hasattr(chunk.delta.usage, "billed_units") and chunk.delta.usage.billed_units is not None):
|
431
|
+
usage = chunk.delta.usage.billed_units
|
432
|
+
self.completion_tokens = int(usage.output_tokens)
|
433
|
+
self.prompt_tokens = int(usage.input_tokens)
|
412
434
|
|
413
435
|
if hasattr(chunk, "usage") and chunk.usage is not None:
|
414
436
|
if hasattr(chunk.usage, "output_tokens"):
|
@@ -61,6 +61,11 @@ def with_langtrace_root_span(
|
|
61
61
|
span_id = str(span.get_span_context().span_id)
|
62
62
|
trace_id = str(span.get_span_context().trace_id)
|
63
63
|
|
64
|
+
# Attach session ID if available
|
65
|
+
session_id = os.environ.get("LANGTRACE_SESSION_ID")
|
66
|
+
if session_id:
|
67
|
+
span.set_attribute("session.id", session_id)
|
68
|
+
|
64
69
|
if (
|
65
70
|
"span_id" in func.__code__.co_varnames
|
66
71
|
and "trace_id" in func.__code__.co_varnames
|
@@ -82,6 +87,12 @@ def with_langtrace_root_span(
|
|
82
87
|
) as span:
|
83
88
|
span_id = span.get_span_context().span_id
|
84
89
|
trace_id = span.get_span_context().trace_id
|
90
|
+
|
91
|
+
# Attach session ID if available
|
92
|
+
session_id = os.environ.get("LANGTRACE_SESSION_ID")
|
93
|
+
if session_id:
|
94
|
+
span.set_attribute("session.id", session_id)
|
95
|
+
|
85
96
|
if (
|
86
97
|
"span_id" in func.__code__.co_varnames
|
87
98
|
and "trace_id" in func.__code__.co_varnames
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "3.3.15"
|