shield360 1.0.0
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.
- package/LICENSE +201 -0
- package/README.md +310 -0
- package/dist/__tests__/manual-trace.test.d.ts +1 -0
- package/dist/__tests__/manual-trace.test.js +118 -0
- package/dist/__tests__/manual-trace.test.js.map +1 -0
- package/dist/__tests__/register.test.d.ts +0 -0
- package/dist/__tests__/register.test.js +90 -0
- package/dist/__tests__/register.test.js.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -0
- package/dist/constant.d.ts +6 -0
- package/dist/constant.js +14 -0
- package/dist/constant.js.map +1 -0
- package/dist/evals/__tests__/offline.test.d.ts +1 -0
- package/dist/evals/__tests__/offline.test.js +427 -0
- package/dist/evals/__tests__/offline.test.js.map +1 -0
- package/dist/evals/index.d.ts +2 -0
- package/dist/evals/index.js +15 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/offline.d.ts +6 -0
- package/dist/evals/offline.js +350 -0
- package/dist/evals/offline.js.map +1 -0
- package/dist/evals/types.d.ts +74 -0
- package/dist/evals/types.js +23 -0
- package/dist/evals/types.js.map +1 -0
- package/dist/features/__tests__/rule-engine.test.d.ts +1 -0
- package/dist/features/__tests__/rule-engine.test.js +146 -0
- package/dist/features/__tests__/rule-engine.test.js.map +1 -0
- package/dist/features/base.d.ts +8 -0
- package/dist/features/base.js +15 -0
- package/dist/features/base.js.map +1 -0
- package/dist/features/prompt-hub.d.ts +4 -0
- package/dist/features/prompt-hub.js +66 -0
- package/dist/features/prompt-hub.js.map +1 -0
- package/dist/features/rule-engine.d.ts +6 -0
- package/dist/features/rule-engine.js +60 -0
- package/dist/features/rule-engine.js.map +1 -0
- package/dist/features/vault.d.ts +4 -0
- package/dist/features/vault.js +63 -0
- package/dist/features/vault.js.map +1 -0
- package/dist/guard/__tests__/findings.test.d.ts +1 -0
- package/dist/guard/__tests__/findings.test.js +79 -0
- package/dist/guard/__tests__/findings.test.js.map +1 -0
- package/dist/guard/__tests__/integration.test.d.ts +1 -0
- package/dist/guard/__tests__/integration.test.js +215 -0
- package/dist/guard/__tests__/integration.test.js.map +1 -0
- package/dist/guard/__tests__/pii.test.d.ts +1 -0
- package/dist/guard/__tests__/pii.test.js +131 -0
- package/dist/guard/__tests__/pii.test.js.map +1 -0
- package/dist/guard/__tests__/pipeline.test.d.ts +1 -0
- package/dist/guard/__tests__/pipeline.test.js +162 -0
- package/dist/guard/__tests__/pipeline.test.js.map +1 -0
- package/dist/guard/__tests__/prompt-injection.test.d.ts +1 -0
- package/dist/guard/__tests__/prompt-injection.test.js +92 -0
- package/dist/guard/__tests__/prompt-injection.test.js.map +1 -0
- package/dist/guard/__tests__/report.test.d.ts +1 -0
- package/dist/guard/__tests__/report.test.js +50 -0
- package/dist/guard/__tests__/report.test.js.map +1 -0
- package/dist/guard/base.d.ts +79 -0
- package/dist/guard/base.js +136 -0
- package/dist/guard/base.js.map +1 -0
- package/dist/guard/custom.d.ts +19 -0
- package/dist/guard/custom.js +46 -0
- package/dist/guard/custom.js.map +1 -0
- package/dist/guard/findings.d.ts +31 -0
- package/dist/guard/findings.js +156 -0
- package/dist/guard/findings.js.map +1 -0
- package/dist/guard/index.d.ts +24 -0
- package/dist/guard/index.js +42 -0
- package/dist/guard/index.js.map +1 -0
- package/dist/guard/integration.d.ts +44 -0
- package/dist/guard/integration.js +363 -0
- package/dist/guard/integration.js.map +1 -0
- package/dist/guard/moderation.d.ts +18 -0
- package/dist/guard/moderation.js +61 -0
- package/dist/guard/moderation.js.map +1 -0
- package/dist/guard/pii.d.ts +17 -0
- package/dist/guard/pii.js +114 -0
- package/dist/guard/pii.js.map +1 -0
- package/dist/guard/pipeline.d.ts +26 -0
- package/dist/guard/pipeline.js +139 -0
- package/dist/guard/pipeline.js.map +1 -0
- package/dist/guard/prompt-injection.d.ts +21 -0
- package/dist/guard/prompt-injection.js +70 -0
- package/dist/guard/prompt-injection.js.map +1 -0
- package/dist/guard/report.d.ts +34 -0
- package/dist/guard/report.js +182 -0
- package/dist/guard/report.js.map +1 -0
- package/dist/guard/schema.d.ts +20 -0
- package/dist/guard/schema.js +99 -0
- package/dist/guard/schema.js.map +1 -0
- package/dist/guard/sensitive-topic.d.ts +23 -0
- package/dist/guard/sensitive-topic.js +89 -0
- package/dist/guard/sensitive-topic.js.map +1 -0
- package/dist/guard/topic-restriction.d.ts +22 -0
- package/dist/guard/topic-restriction.js +54 -0
- package/dist/guard/topic-restriction.js.map +1 -0
- package/dist/helpers.d.ts +246 -0
- package/dist/helpers.js +903 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.d.ts +13 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js +176 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.d.ts +10 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js +203 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.js +160 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.js +171 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js +422 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.d.ts +15 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.js +155 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.js.map +1 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.d.ts +18 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js +209 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js +256 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js +282 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js +238 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.d.ts +4 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js +229 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.js +247 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.js.map +1 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.d.ts +11 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js +391 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +687 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.d.ts +14 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.js +347 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.js.map +1 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js +529 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.js +19 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.js.map +1 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js +282 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.js +285 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.d.ts +13 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js +208 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.d.ts +17 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js +206 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js +345 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.js +179 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.d.ts +21 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.js +455 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.d.ts +17 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js +182 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.d.ts +8 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js +346 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.d.ts +4 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js +289 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.d.ts +67 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.js +255 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.js.map +1 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.d.ts +11 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js +214 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.d.ts +8 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js +446 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.d.ts +6 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js +409 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js +519 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/ai21/index.d.ts +11 -0
- package/dist/instrumentation/ai21/index.js +67 -0
- package/dist/instrumentation/ai21/index.js.map +1 -0
- package/dist/instrumentation/ai21/wrapper.d.ts +54 -0
- package/dist/instrumentation/ai21/wrapper.js +511 -0
- package/dist/instrumentation/ai21/wrapper.js.map +1 -0
- package/dist/instrumentation/anthropic/index.d.ts +11 -0
- package/dist/instrumentation/anthropic/index.js +45 -0
- package/dist/instrumentation/anthropic/index.js.map +1 -0
- package/dist/instrumentation/anthropic/wrapper.d.ts +34 -0
- package/dist/instrumentation/anthropic/wrapper.js +426 -0
- package/dist/instrumentation/anthropic/wrapper.js.map +1 -0
- package/dist/instrumentation/assemblyai/index.d.ts +12 -0
- package/dist/instrumentation/assemblyai/index.js +91 -0
- package/dist/instrumentation/assemblyai/index.js.map +1 -0
- package/dist/instrumentation/assemblyai/wrapper.d.ts +35 -0
- package/dist/instrumentation/assemblyai/wrapper.js +238 -0
- package/dist/instrumentation/assemblyai/wrapper.js.map +1 -0
- package/dist/instrumentation/astra/index.d.ts +11 -0
- package/dist/instrumentation/astra/index.js +87 -0
- package/dist/instrumentation/astra/index.js.map +1 -0
- package/dist/instrumentation/astra/wrapper.d.ts +39 -0
- package/dist/instrumentation/astra/wrapper.js +349 -0
- package/dist/instrumentation/astra/wrapper.js.map +1 -0
- package/dist/instrumentation/azure-ai-inference/index.d.ts +11 -0
- package/dist/instrumentation/azure-ai-inference/index.js +76 -0
- package/dist/instrumentation/azure-ai-inference/index.js.map +1 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +55 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js +580 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -0
- package/dist/instrumentation/base-wrapper.d.ts +16 -0
- package/dist/instrumentation/base-wrapper.js +139 -0
- package/dist/instrumentation/base-wrapper.js.map +1 -0
- package/dist/instrumentation/bedrock/index.d.ts +11 -0
- package/dist/instrumentation/bedrock/index.js +52 -0
- package/dist/instrumentation/bedrock/index.js.map +1 -0
- package/dist/instrumentation/bedrock/wrapper.d.ts +41 -0
- package/dist/instrumentation/bedrock/wrapper.js +494 -0
- package/dist/instrumentation/bedrock/wrapper.js.map +1 -0
- package/dist/instrumentation/browser-use/index.d.ts +11 -0
- package/dist/instrumentation/browser-use/index.js +98 -0
- package/dist/instrumentation/browser-use/index.js.map +1 -0
- package/dist/instrumentation/browser-use/wrapper.d.ts +12 -0
- package/dist/instrumentation/browser-use/wrapper.js +706 -0
- package/dist/instrumentation/browser-use/wrapper.js.map +1 -0
- package/dist/instrumentation/chroma/index.d.ts +11 -0
- package/dist/instrumentation/chroma/index.js +70 -0
- package/dist/instrumentation/chroma/index.js.map +1 -0
- package/dist/instrumentation/chroma/wrapper.d.ts +10 -0
- package/dist/instrumentation/chroma/wrapper.js +127 -0
- package/dist/instrumentation/chroma/wrapper.js.map +1 -0
- package/dist/instrumentation/claude-agent-sdk/index.d.ts +23 -0
- package/dist/instrumentation/claude-agent-sdk/index.js +83 -0
- package/dist/instrumentation/claude-agent-sdk/index.js.map +1 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.d.ts +13 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js +1123 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -0
- package/dist/instrumentation/cohere/index.d.ts +11 -0
- package/dist/instrumentation/cohere/index.js +53 -0
- package/dist/instrumentation/cohere/index.js.map +1 -0
- package/dist/instrumentation/cohere/wrapper.d.ts +50 -0
- package/dist/instrumentation/cohere/wrapper.js +452 -0
- package/dist/instrumentation/cohere/wrapper.js.map +1 -0
- package/dist/instrumentation/cursor-sdk/index.d.ts +21 -0
- package/dist/instrumentation/cursor-sdk/index.js +58 -0
- package/dist/instrumentation/cursor-sdk/index.js.map +1 -0
- package/dist/instrumentation/cursor-sdk/wrapper.d.ts +17 -0
- package/dist/instrumentation/cursor-sdk/wrapper.js +789 -0
- package/dist/instrumentation/cursor-sdk/wrapper.js.map +1 -0
- package/dist/instrumentation/elevenlabs/index.d.ts +12 -0
- package/dist/instrumentation/elevenlabs/index.js +92 -0
- package/dist/instrumentation/elevenlabs/index.js.map +1 -0
- package/dist/instrumentation/elevenlabs/wrapper.d.ts +34 -0
- package/dist/instrumentation/elevenlabs/wrapper.js +280 -0
- package/dist/instrumentation/elevenlabs/wrapper.js.map +1 -0
- package/dist/instrumentation/firecrawl/index.d.ts +13 -0
- package/dist/instrumentation/firecrawl/index.js +115 -0
- package/dist/instrumentation/firecrawl/index.js.map +1 -0
- package/dist/instrumentation/firecrawl/wrapper.d.ts +22 -0
- package/dist/instrumentation/firecrawl/wrapper.js +378 -0
- package/dist/instrumentation/firecrawl/wrapper.js.map +1 -0
- package/dist/instrumentation/google-adk/index.d.ts +57 -0
- package/dist/instrumentation/google-adk/index.js +371 -0
- package/dist/instrumentation/google-adk/index.js.map +1 -0
- package/dist/instrumentation/google-adk/utils.d.ts +45 -0
- package/dist/instrumentation/google-adk/utils.js +663 -0
- package/dist/instrumentation/google-adk/utils.js.map +1 -0
- package/dist/instrumentation/google-adk/wrapper.d.ts +11 -0
- package/dist/instrumentation/google-adk/wrapper.js +391 -0
- package/dist/instrumentation/google-adk/wrapper.js.map +1 -0
- package/dist/instrumentation/google-ai/index.d.ts +11 -0
- package/dist/instrumentation/google-ai/index.js +48 -0
- package/dist/instrumentation/google-ai/index.js.map +1 -0
- package/dist/instrumentation/google-ai/wrapper.d.ts +52 -0
- package/dist/instrumentation/google-ai/wrapper.js +466 -0
- package/dist/instrumentation/google-ai/wrapper.js.map +1 -0
- package/dist/instrumentation/gpu/index.d.ts +38 -0
- package/dist/instrumentation/gpu/index.js +233 -0
- package/dist/instrumentation/gpu/index.js.map +1 -0
- package/dist/instrumentation/gradient/index.d.ts +12 -0
- package/dist/instrumentation/gradient/index.js +74 -0
- package/dist/instrumentation/gradient/index.js.map +1 -0
- package/dist/instrumentation/gradient/utils.d.ts +14 -0
- package/dist/instrumentation/gradient/utils.js +119 -0
- package/dist/instrumentation/gradient/utils.js.map +1 -0
- package/dist/instrumentation/gradient/wrapper.d.ts +76 -0
- package/dist/instrumentation/gradient/wrapper.js +584 -0
- package/dist/instrumentation/gradient/wrapper.js.map +1 -0
- package/dist/instrumentation/groq/index.d.ts +11 -0
- package/dist/instrumentation/groq/index.js +43 -0
- package/dist/instrumentation/groq/index.js.map +1 -0
- package/dist/instrumentation/groq/wrapper.d.ts +35 -0
- package/dist/instrumentation/groq/wrapper.js +442 -0
- package/dist/instrumentation/groq/wrapper.js.map +1 -0
- package/dist/instrumentation/huggingface/index.d.ts +13 -0
- package/dist/instrumentation/huggingface/index.js +110 -0
- package/dist/instrumentation/huggingface/index.js.map +1 -0
- package/dist/instrumentation/huggingface/wrapper.d.ts +54 -0
- package/dist/instrumentation/huggingface/wrapper.js +514 -0
- package/dist/instrumentation/huggingface/wrapper.js.map +1 -0
- package/dist/instrumentation/index.d.ts +7 -0
- package/dist/instrumentation/index.js +176 -0
- package/dist/instrumentation/index.js.map +1 -0
- package/dist/instrumentation/langchain/index.d.ts +16 -0
- package/dist/instrumentation/langchain/index.js +91 -0
- package/dist/instrumentation/langchain/index.js.map +1 -0
- package/dist/instrumentation/langchain/wrapper.d.ts +41 -0
- package/dist/instrumentation/langchain/wrapper.js +1235 -0
- package/dist/instrumentation/langchain/wrapper.js.map +1 -0
- package/dist/instrumentation/langgraph/index.d.ts +12 -0
- package/dist/instrumentation/langgraph/index.js +99 -0
- package/dist/instrumentation/langgraph/index.js.map +1 -0
- package/dist/instrumentation/langgraph/wrapper.d.ts +20 -0
- package/dist/instrumentation/langgraph/wrapper.js +620 -0
- package/dist/instrumentation/langgraph/wrapper.js.map +1 -0
- package/dist/instrumentation/letta/index.d.ts +10 -0
- package/dist/instrumentation/letta/index.js +122 -0
- package/dist/instrumentation/letta/index.js.map +1 -0
- package/dist/instrumentation/letta/utils.d.ts +24 -0
- package/dist/instrumentation/letta/utils.js +343 -0
- package/dist/instrumentation/letta/utils.js.map +1 -0
- package/dist/instrumentation/letta/wrapper.d.ts +37 -0
- package/dist/instrumentation/letta/wrapper.js +180 -0
- package/dist/instrumentation/letta/wrapper.js.map +1 -0
- package/dist/instrumentation/llamaindex/index.d.ts +36 -0
- package/dist/instrumentation/llamaindex/index.js +221 -0
- package/dist/instrumentation/llamaindex/index.js.map +1 -0
- package/dist/instrumentation/llamaindex/wrapper.d.ts +36 -0
- package/dist/instrumentation/llamaindex/wrapper.js +811 -0
- package/dist/instrumentation/llamaindex/wrapper.js.map +1 -0
- package/dist/instrumentation/mcp/index.d.ts +20 -0
- package/dist/instrumentation/mcp/index.js +282 -0
- package/dist/instrumentation/mcp/index.js.map +1 -0
- package/dist/instrumentation/mcp/wrapper.d.ts +72 -0
- package/dist/instrumentation/mcp/wrapper.js +571 -0
- package/dist/instrumentation/mcp/wrapper.js.map +1 -0
- package/dist/instrumentation/mem0/index.d.ts +17 -0
- package/dist/instrumentation/mem0/index.js +113 -0
- package/dist/instrumentation/mem0/index.js.map +1 -0
- package/dist/instrumentation/mem0/wrapper.d.ts +37 -0
- package/dist/instrumentation/mem0/wrapper.js +298 -0
- package/dist/instrumentation/mem0/wrapper.js.map +1 -0
- package/dist/instrumentation/milvus/index.d.ts +11 -0
- package/dist/instrumentation/milvus/index.js +67 -0
- package/dist/instrumentation/milvus/index.js.map +1 -0
- package/dist/instrumentation/milvus/wrapper.d.ts +15 -0
- package/dist/instrumentation/milvus/wrapper.js +219 -0
- package/dist/instrumentation/milvus/wrapper.js.map +1 -0
- package/dist/instrumentation/mistral/index.d.ts +11 -0
- package/dist/instrumentation/mistral/index.js +66 -0
- package/dist/instrumentation/mistral/index.js.map +1 -0
- package/dist/instrumentation/mistral/wrapper.d.ts +49 -0
- package/dist/instrumentation/mistral/wrapper.js +482 -0
- package/dist/instrumentation/mistral/wrapper.js.map +1 -0
- package/dist/instrumentation/ollama/index.d.ts +11 -0
- package/dist/instrumentation/ollama/index.js +72 -0
- package/dist/instrumentation/ollama/index.js.map +1 -0
- package/dist/instrumentation/ollama/wrapper.d.ts +73 -0
- package/dist/instrumentation/ollama/wrapper.js +629 -0
- package/dist/instrumentation/ollama/wrapper.js.map +1 -0
- package/dist/instrumentation/openai/index.d.ts +11 -0
- package/dist/instrumentation/openai/index.js +79 -0
- package/dist/instrumentation/openai/index.js.map +1 -0
- package/dist/instrumentation/openai/wrapper.d.ts +80 -0
- package/dist/instrumentation/openai/wrapper.js +1121 -0
- package/dist/instrumentation/openai/wrapper.js.map +1 -0
- package/dist/instrumentation/openai-agents/index.d.ts +20 -0
- package/dist/instrumentation/openai-agents/index.js +174 -0
- package/dist/instrumentation/openai-agents/index.js.map +1 -0
- package/dist/instrumentation/openai-agents/processor.d.ts +35 -0
- package/dist/instrumentation/openai-agents/processor.js +249 -0
- package/dist/instrumentation/openai-agents/processor.js.map +1 -0
- package/dist/instrumentation/openai-agents/utils.d.ts +20 -0
- package/dist/instrumentation/openai-agents/utils.js +624 -0
- package/dist/instrumentation/openai-agents/utils.js.map +1 -0
- package/dist/instrumentation/pg/index.d.ts +20 -0
- package/dist/instrumentation/pg/index.js +74 -0
- package/dist/instrumentation/pg/index.js.map +1 -0
- package/dist/instrumentation/pg/wrapper.d.ts +66 -0
- package/dist/instrumentation/pg/wrapper.js +441 -0
- package/dist/instrumentation/pg/wrapper.js.map +1 -0
- package/dist/instrumentation/pinecone/index.d.ts +11 -0
- package/dist/instrumentation/pinecone/index.js +79 -0
- package/dist/instrumentation/pinecone/index.js.map +1 -0
- package/dist/instrumentation/pinecone/wrapper.d.ts +14 -0
- package/dist/instrumentation/pinecone/wrapper.js +198 -0
- package/dist/instrumentation/pinecone/wrapper.js.map +1 -0
- package/dist/instrumentation/qdrant/index.d.ts +11 -0
- package/dist/instrumentation/qdrant/index.js +67 -0
- package/dist/instrumentation/qdrant/index.js.map +1 -0
- package/dist/instrumentation/qdrant/wrapper.d.ts +14 -0
- package/dist/instrumentation/qdrant/wrapper.js +213 -0
- package/dist/instrumentation/qdrant/wrapper.js.map +1 -0
- package/dist/instrumentation/replicate/index.d.ts +11 -0
- package/dist/instrumentation/replicate/index.js +57 -0
- package/dist/instrumentation/replicate/index.js.map +1 -0
- package/dist/instrumentation/replicate/wrapper.d.ts +28 -0
- package/dist/instrumentation/replicate/wrapper.js +242 -0
- package/dist/instrumentation/replicate/wrapper.js.map +1 -0
- package/dist/instrumentation/strands/index.d.ts +21 -0
- package/dist/instrumentation/strands/index.js +83 -0
- package/dist/instrumentation/strands/index.js.map +1 -0
- package/dist/instrumentation/strands/processor.d.ts +51 -0
- package/dist/instrumentation/strands/processor.js +625 -0
- package/dist/instrumentation/strands/processor.js.map +1 -0
- package/dist/instrumentation/strands/utils.d.ts +24 -0
- package/dist/instrumentation/strands/utils.js +373 -0
- package/dist/instrumentation/strands/utils.js.map +1 -0
- package/dist/instrumentation/together/index.d.ts +11 -0
- package/dist/instrumentation/together/index.js +43 -0
- package/dist/instrumentation/together/index.js.map +1 -0
- package/dist/instrumentation/together/wrapper.d.ts +48 -0
- package/dist/instrumentation/together/wrapper.js +409 -0
- package/dist/instrumentation/together/wrapper.js.map +1 -0
- package/dist/instrumentation/transformers/index.d.ts +35 -0
- package/dist/instrumentation/transformers/index.js +119 -0
- package/dist/instrumentation/transformers/index.js.map +1 -0
- package/dist/instrumentation/transformers/wrapper.d.ts +49 -0
- package/dist/instrumentation/transformers/wrapper.js +472 -0
- package/dist/instrumentation/transformers/wrapper.js.map +1 -0
- package/dist/instrumentation/vercel-ai/index.d.ts +10 -0
- package/dist/instrumentation/vercel-ai/index.js +59 -0
- package/dist/instrumentation/vercel-ai/index.js.map +1 -0
- package/dist/instrumentation/vercel-ai/wrapper.d.ts +50 -0
- package/dist/instrumentation/vercel-ai/wrapper.js +539 -0
- package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -0
- package/dist/instrumentation/vertexai/index.d.ts +11 -0
- package/dist/instrumentation/vertexai/index.js +70 -0
- package/dist/instrumentation/vertexai/index.js.map +1 -0
- package/dist/instrumentation/vertexai/wrapper.d.ts +67 -0
- package/dist/instrumentation/vertexai/wrapper.js +530 -0
- package/dist/instrumentation/vertexai/wrapper.js.map +1 -0
- package/dist/instrumentation/vllm/index.d.ts +13 -0
- package/dist/instrumentation/vllm/index.js +67 -0
- package/dist/instrumentation/vllm/index.js.map +1 -0
- package/dist/instrumentation/vllm/wrapper.d.ts +60 -0
- package/dist/instrumentation/vllm/wrapper.js +482 -0
- package/dist/instrumentation/vllm/wrapper.js.map +1 -0
- package/dist/llm/anthropic.d.ts +5 -0
- package/dist/llm/anthropic.js +39 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +93 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/openai.d.ts +6 -0
- package/dist/llm/openai.js +52 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/providers.d.ts +7 -0
- package/dist/llm/providers.js +10 -0
- package/dist/llm/providers.js.map +1 -0
- package/dist/manual-trace.d.ts +40 -0
- package/dist/manual-trace.js +103 -0
- package/dist/manual-trace.js.map +1 -0
- package/dist/otel/__tests__/metrics.test.d.ts +1 -0
- package/dist/otel/__tests__/metrics.test.js +40 -0
- package/dist/otel/__tests__/metrics.test.js.map +1 -0
- package/dist/otel/events.d.ts +11 -0
- package/dist/otel/events.js +74 -0
- package/dist/otel/events.js.map +1 -0
- package/dist/otel/metrics.d.ts +35 -0
- package/dist/otel/metrics.js +219 -0
- package/dist/otel/metrics.js.map +1 -0
- package/dist/otel/tracing.d.ts +12 -0
- package/dist/otel/tracing.js +93 -0
- package/dist/otel/tracing.js.map +1 -0
- package/dist/otel/utils.d.ts +11 -0
- package/dist/otel/utils.js +34 -0
- package/dist/otel/utils.js.map +1 -0
- package/dist/pricing.json +951 -0
- package/dist/prompt-hub.d.ts +4 -0
- package/dist/prompt-hub.js +66 -0
- package/dist/prompt-hub.js.map +1 -0
- package/dist/register.d.ts +4 -0
- package/dist/register.js +52 -0
- package/dist/register.js.map +1 -0
- package/dist/score/__tests__/score.test.d.ts +1 -0
- package/dist/score/__tests__/score.test.js +143 -0
- package/dist/score/__tests__/score.test.js.map +1 -0
- package/dist/score/index.d.ts +2 -0
- package/dist/score/index.js +6 -0
- package/dist/score/index.js.map +1 -0
- package/dist/score/score.d.ts +15 -0
- package/dist/score/score.js +135 -0
- package/dist/score/score.js.map +1 -0
- package/dist/semantic-convention.d.ts +555 -0
- package/dist/semantic-convention.js +630 -0
- package/dist/semantic-convention.js.map +1 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +136 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const api_1 = require("@opentelemetry/api");
|
|
7
|
+
const wrapper_1 = __importDefault(require("../mistral/wrapper"));
|
|
8
|
+
const config_1 = __importDefault(require("../../config"));
|
|
9
|
+
const helpers_1 = __importDefault(require("../../helpers"));
|
|
10
|
+
const base_wrapper_1 = __importDefault(require("../base-wrapper"));
|
|
11
|
+
const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
|
|
12
|
+
jest.mock('../../../src/config');
|
|
13
|
+
jest.mock('../../../src/helpers');
|
|
14
|
+
jest.mock('../../../src/instrumentation/base-wrapper');
|
|
15
|
+
const mockTracer = api_1.trace.getTracer('test-tracer');
|
|
16
|
+
describe('MistralWrapper', () => {
|
|
17
|
+
let span;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
span = mockTracer.startSpan('test-span');
|
|
20
|
+
span.setAttribute = jest.fn();
|
|
21
|
+
span.addEvent = jest.fn();
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
span.end();
|
|
26
|
+
});
|
|
27
|
+
describe('_chatCompletion', () => {
|
|
28
|
+
it('should call recordMetrics after span ends', async () => {
|
|
29
|
+
const mockArgs = [{ messages: [{ role: 'user', content: 'test message' }] }];
|
|
30
|
+
const mockResponse = {
|
|
31
|
+
id: '123',
|
|
32
|
+
model: 'mistral-small-latest',
|
|
33
|
+
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
|
34
|
+
choices: [
|
|
35
|
+
{
|
|
36
|
+
message: { content: 'response text', role: 'assistant' },
|
|
37
|
+
finish_reason: 'stop',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
const mockGenAIEndpoint = 'mistral.chat.completions';
|
|
42
|
+
jest
|
|
43
|
+
.spyOn(wrapper_1.default, '_chatCompletionCommonSetter')
|
|
44
|
+
.mockImplementationOnce(async ({ genAIEndpoint, span }) => {
|
|
45
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, 1);
|
|
46
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
|
|
47
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
|
|
48
|
+
return {
|
|
49
|
+
genAIEndpoint,
|
|
50
|
+
model: 'mistral-small-latest',
|
|
51
|
+
user: 'test-user',
|
|
52
|
+
cost: 0.5,
|
|
53
|
+
aiSystem: semantic_convention_1.default.GEN_AI_SYSTEM_MISTRAL,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
await wrapper_1.default._chatCompletion({
|
|
57
|
+
args: mockArgs,
|
|
58
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
59
|
+
response: mockResponse,
|
|
60
|
+
span,
|
|
61
|
+
});
|
|
62
|
+
expect(base_wrapper_1.default.recordMetrics).toHaveBeenCalledWith(span, {
|
|
63
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
64
|
+
model: 'mistral-small-latest',
|
|
65
|
+
user: 'test-user',
|
|
66
|
+
cost: 0.5,
|
|
67
|
+
aiSystem: semantic_convention_1.default.GEN_AI_SYSTEM_MISTRAL,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('_chatCompletionCommonSetter', () => {
|
|
72
|
+
it('should set span attributes and return metric parameters', async () => {
|
|
73
|
+
const mockArgs = [
|
|
74
|
+
{
|
|
75
|
+
model: 'mistral-small-latest',
|
|
76
|
+
messages: [{ role: 'user', content: 'test message' }],
|
|
77
|
+
max_tokens: 100,
|
|
78
|
+
temperature: 0.7,
|
|
79
|
+
top_p: 1,
|
|
80
|
+
user: 'test-user',
|
|
81
|
+
presence_penalty: 2,
|
|
82
|
+
frequency_penalty: 3,
|
|
83
|
+
seed: 3,
|
|
84
|
+
stream: false,
|
|
85
|
+
stop: ['STOP'],
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const mockResult = {
|
|
89
|
+
id: '123',
|
|
90
|
+
model: 'mistral-small-latest',
|
|
91
|
+
usage: {
|
|
92
|
+
prompt_tokens: 10,
|
|
93
|
+
completion_tokens: 20,
|
|
94
|
+
total_tokens: 30,
|
|
95
|
+
},
|
|
96
|
+
choices: [
|
|
97
|
+
{
|
|
98
|
+
message: { content: 'response text', role: 'assistant' },
|
|
99
|
+
finish_reason: 'stop',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
const mockGenAIEndpoint = 'mistral.chat.completions';
|
|
104
|
+
jest.restoreAllMocks();
|
|
105
|
+
config_1.default.pricingInfo = {};
|
|
106
|
+
config_1.default.disableEvents = true;
|
|
107
|
+
jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
|
|
108
|
+
const metricParams = await wrapper_1.default._chatCompletionCommonSetter({
|
|
109
|
+
args: mockArgs,
|
|
110
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
111
|
+
result: mockResult,
|
|
112
|
+
span,
|
|
113
|
+
});
|
|
114
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, 1);
|
|
115
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
|
|
116
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
|
|
117
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_PRESENCE_PENALTY, 2);
|
|
118
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY, 3);
|
|
119
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_SEED, 3);
|
|
120
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
|
|
121
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES, ['STOP']);
|
|
122
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, 'mistral-small-latest');
|
|
123
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, 10);
|
|
124
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
|
|
125
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
|
|
126
|
+
expect(metricParams).toEqual({
|
|
127
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
128
|
+
model: 'mistral-small-latest',
|
|
129
|
+
user: 'test-user',
|
|
130
|
+
cost: 0.5,
|
|
131
|
+
aiSystem: semantic_convention_1.default.GEN_AI_SYSTEM_MISTRAL,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
it('should NOT set sentinel values for optional request params', async () => {
|
|
135
|
+
const mockArgs = [
|
|
136
|
+
{
|
|
137
|
+
model: 'mistral-small-latest',
|
|
138
|
+
messages: [{ role: 'user', content: 'test' }],
|
|
139
|
+
stream: false,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
const mockResult = {
|
|
143
|
+
id: '456',
|
|
144
|
+
model: 'mistral-small-latest',
|
|
145
|
+
usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
|
|
146
|
+
choices: [
|
|
147
|
+
{
|
|
148
|
+
message: { content: 'test response', role: 'assistant' },
|
|
149
|
+
finish_reason: 'stop',
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
jest.restoreAllMocks();
|
|
154
|
+
config_1.default.pricingInfo = {};
|
|
155
|
+
config_1.default.disableEvents = true;
|
|
156
|
+
jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
|
|
157
|
+
await wrapper_1.default._chatCompletionCommonSetter({
|
|
158
|
+
args: mockArgs,
|
|
159
|
+
genAIEndpoint: 'mistral.chat.completions',
|
|
160
|
+
result: mockResult,
|
|
161
|
+
span,
|
|
162
|
+
});
|
|
163
|
+
const setAttrCalls = span.setAttribute.mock.calls;
|
|
164
|
+
const attrKeys = setAttrCalls.map((c) => c[0]);
|
|
165
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS);
|
|
166
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_SEED);
|
|
167
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_PRESENCE_PENALTY);
|
|
168
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY);
|
|
169
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES);
|
|
170
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_CHOICE_COUNT);
|
|
171
|
+
});
|
|
172
|
+
it('should handle tool calls properly', async () => {
|
|
173
|
+
const mockArgs = [
|
|
174
|
+
{
|
|
175
|
+
messages: [{ role: 'user', content: 'test message' }],
|
|
176
|
+
tools: [{ type: 'function', function: { name: 'get_weather' } }],
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
const mockResult = {
|
|
180
|
+
id: '123',
|
|
181
|
+
model: 'mistral-small-latest',
|
|
182
|
+
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
|
183
|
+
choices: [
|
|
184
|
+
{
|
|
185
|
+
message: {
|
|
186
|
+
content: null,
|
|
187
|
+
role: 'assistant',
|
|
188
|
+
tool_calls: [
|
|
189
|
+
{
|
|
190
|
+
id: 'call_123',
|
|
191
|
+
type: 'function',
|
|
192
|
+
function: { name: 'get_weather', arguments: '{"location":"SF"}' },
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
finish_reason: 'tool_calls',
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
config_1.default.pricingInfo = {};
|
|
201
|
+
config_1.default.disableEvents = true;
|
|
202
|
+
jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
|
|
203
|
+
await wrapper_1.default._chatCompletionCommonSetter({
|
|
204
|
+
args: mockArgs,
|
|
205
|
+
genAIEndpoint: 'mistral.chat.completions',
|
|
206
|
+
result: mockResult,
|
|
207
|
+
span,
|
|
208
|
+
});
|
|
209
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_NAME, 'get_weather');
|
|
210
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, 'call_123');
|
|
211
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_ARGS, '{"location":"SF"}');
|
|
212
|
+
});
|
|
213
|
+
it('should emit inference event when events not disabled', async () => {
|
|
214
|
+
const mockArgs = [
|
|
215
|
+
{
|
|
216
|
+
model: 'mistral-small-latest',
|
|
217
|
+
messages: [{ role: 'user', content: 'test message' }],
|
|
218
|
+
stream: false,
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
const mockResult = {
|
|
222
|
+
id: '789',
|
|
223
|
+
model: 'mistral-small-latest',
|
|
224
|
+
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
|
225
|
+
choices: [
|
|
226
|
+
{
|
|
227
|
+
message: { content: 'response text', role: 'assistant' },
|
|
228
|
+
finish_reason: 'stop',
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
};
|
|
232
|
+
jest.restoreAllMocks();
|
|
233
|
+
config_1.default.pricingInfo = {};
|
|
234
|
+
config_1.default.captureMessageContent = false;
|
|
235
|
+
config_1.default.disableEvents = false;
|
|
236
|
+
jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
|
|
237
|
+
jest.spyOn(helpers_1.default, 'emitInferenceEvent').mockImplementation(() => { });
|
|
238
|
+
await wrapper_1.default._chatCompletionCommonSetter({
|
|
239
|
+
args: mockArgs,
|
|
240
|
+
genAIEndpoint: 'mistral.chat.completions',
|
|
241
|
+
result: mockResult,
|
|
242
|
+
span,
|
|
243
|
+
});
|
|
244
|
+
expect(helpers_1.default.emitInferenceEvent).toHaveBeenCalledWith(span, expect.objectContaining({
|
|
245
|
+
[semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
|
|
246
|
+
[semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: 'mistral-small-latest',
|
|
247
|
+
[semantic_convention_1.default.GEN_AI_RESPONSE_MODEL]: 'mistral-small-latest',
|
|
248
|
+
[semantic_convention_1.default.SERVER_ADDRESS]: 'api.mistral.ai',
|
|
249
|
+
[semantic_convention_1.default.SERVER_PORT]: 443,
|
|
250
|
+
[semantic_convention_1.default.GEN_AI_RESPONSE_ID]: '789',
|
|
251
|
+
[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]: 10,
|
|
252
|
+
[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]: 20,
|
|
253
|
+
}));
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
describe('Cross-Language Trace Comparison', () => {
|
|
257
|
+
it('should use mistral_ai as provider name (matching Python SDK)', () => {
|
|
258
|
+
expect(wrapper_1.default.aiSystem).toBe('mistral_ai');
|
|
259
|
+
expect(wrapper_1.default.aiSystem).toBe(semantic_convention_1.default.GEN_AI_SYSTEM_MISTRAL);
|
|
260
|
+
});
|
|
261
|
+
it('should set same attributes as Python SDK for chat completion', async () => {
|
|
262
|
+
const mockArgs = [
|
|
263
|
+
{
|
|
264
|
+
messages: [{ role: 'user', content: 'What is Mistral AI?' }],
|
|
265
|
+
model: 'mistral-small-latest',
|
|
266
|
+
max_tokens: 50,
|
|
267
|
+
temperature: 0.7,
|
|
268
|
+
stream: false,
|
|
269
|
+
},
|
|
270
|
+
];
|
|
271
|
+
const mockResponse = {
|
|
272
|
+
id: 'mistral-test-id',
|
|
273
|
+
created: Date.now(),
|
|
274
|
+
model: 'mistral-small-latest',
|
|
275
|
+
choices: [
|
|
276
|
+
{
|
|
277
|
+
index: 0,
|
|
278
|
+
finish_reason: 'stop',
|
|
279
|
+
message: { role: 'assistant', content: 'Mistral AI is...' },
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
usage: {
|
|
283
|
+
prompt_tokens: 8,
|
|
284
|
+
completion_tokens: 15,
|
|
285
|
+
total_tokens: 23,
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
jest.restoreAllMocks();
|
|
289
|
+
config_1.default.pricingInfo = {};
|
|
290
|
+
config_1.default.captureMessageContent = true;
|
|
291
|
+
config_1.default.disableEvents = true;
|
|
292
|
+
jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.001);
|
|
293
|
+
jest.spyOn(helpers_1.default, 'buildInputMessages').mockReturnValue('[]');
|
|
294
|
+
jest.spyOn(helpers_1.default, 'buildOutputMessages').mockReturnValue('[]');
|
|
295
|
+
await wrapper_1.default._chatCompletion({
|
|
296
|
+
args: mockArgs,
|
|
297
|
+
genAIEndpoint: 'mistral.chat.completions',
|
|
298
|
+
response: mockResponse,
|
|
299
|
+
span,
|
|
300
|
+
});
|
|
301
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, 8);
|
|
302
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, 15);
|
|
303
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, 'mistral-small-latest');
|
|
304
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
|
|
305
|
+
const setAttrCalls = span.setAttribute.mock.calls;
|
|
306
|
+
const attrKeys = setAttrCalls.map((c) => c[0]);
|
|
307
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS);
|
|
308
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_CLIENT_TOKEN_USAGE);
|
|
309
|
+
});
|
|
310
|
+
it('should set embedding attributes matching Python SDK', async () => {
|
|
311
|
+
const mockArgs = [
|
|
312
|
+
{
|
|
313
|
+
model: 'mistral-embed',
|
|
314
|
+
input: 'Test embedding text',
|
|
315
|
+
},
|
|
316
|
+
];
|
|
317
|
+
const mockResponse = {
|
|
318
|
+
model: 'mistral-embed',
|
|
319
|
+
data: [{ embedding: [0.1, 0.2, 0.3] }],
|
|
320
|
+
usage: {
|
|
321
|
+
prompt_tokens: 3,
|
|
322
|
+
total_tokens: 3,
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
jest.restoreAllMocks();
|
|
326
|
+
config_1.default.pricingInfo = {};
|
|
327
|
+
config_1.default.captureMessageContent = true;
|
|
328
|
+
jest.spyOn(helpers_1.default, 'getEmbedModelCost').mockReturnValue(0.0001);
|
|
329
|
+
const mockTracer = {
|
|
330
|
+
startSpan: jest.fn().mockReturnValue(span),
|
|
331
|
+
};
|
|
332
|
+
const patchMethod = wrapper_1.default._patchEmbedding(mockTracer);
|
|
333
|
+
const wrappedMethod = patchMethod(async () => mockResponse);
|
|
334
|
+
await wrappedMethod.call({}, ...mockArgs);
|
|
335
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, 3);
|
|
336
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
|
|
337
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_ENCODING_FORMATS, ['float']);
|
|
338
|
+
const setAttrCalls = span.setAttribute.mock.calls;
|
|
339
|
+
const attrKeys = setAttrCalls.map((c) => c[0]);
|
|
340
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_SERVER_TTFT);
|
|
341
|
+
expect(attrKeys).not.toContain(semantic_convention_1.default.GEN_AI_SERVER_TBT);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
//# sourceMappingURL=mistral-trace-comparison.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mistral-trace-comparison.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/mistral-trace-comparison.test.ts"],"names":[],"mappings":";;;;;AAAA,4CAAiD;AACjD,iEAAgD;AAChD,0DAA2C;AAC3C,4DAA4C;AAC5C,mEAA0C;AAC1C,oFAA2D;AAE3D,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACjC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAClC,IAAI,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAEvD,MAAM,UAAU,GAAG,WAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAElD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,IAAU,CAAC;IAEf,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC/B,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;YACzD,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC;YAC7E,MAAM,YAAY,GAAG;gBACnB,EAAE,EAAE,KAAK;gBACT,K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,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC;YAE5D,MAAM,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAC;YAE1C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,6BAAkB,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;YAChG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,6BAAkB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YACnG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,6BAAkB,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;YAE9G,MAAM,YAAY,GAAI,IAAI,CAAC,YAA0B,CAAC,IAAI,CAAC,KAAK,CAAC;YACjE,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,6BAAkB,CAAC,kBAAkB,CAAC,CAAC;YACtE,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,6BAAkB,CAAC,iBAAiB,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const api_1 = require("@opentelemetry/api");
|
|
7
|
+
const wrapper_1 = __importDefault(require("../openai/wrapper"));
|
|
8
|
+
const config_1 = __importDefault(require("../../config"));
|
|
9
|
+
const helpers_1 = __importDefault(require("../../helpers"));
|
|
10
|
+
const base_wrapper_1 = __importDefault(require("../base-wrapper"));
|
|
11
|
+
const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
|
|
12
|
+
jest.mock('../../../src/config');
|
|
13
|
+
jest.mock('../../../src/helpers');
|
|
14
|
+
jest.mock('../../../src/instrumentation/base-wrapper');
|
|
15
|
+
const mockTracer = api_1.trace.getTracer('test-tracer');
|
|
16
|
+
describe('OpenAIWrapper', () => {
|
|
17
|
+
let span;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
span = mockTracer.startSpan('test-span');
|
|
20
|
+
span.setAttribute = jest.fn();
|
|
21
|
+
span.addEvent = jest.fn();
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
span.end();
|
|
26
|
+
});
|
|
27
|
+
describe('_chatCompletion', () => {
|
|
28
|
+
it('should call recordMetrics after span ends', async () => {
|
|
29
|
+
const mockArgs = [{ messages: [{ role: 'user', content: 'test message' }] }];
|
|
30
|
+
const mockResponse = {
|
|
31
|
+
id: '123',
|
|
32
|
+
model: 'gpt-3.5-turbo',
|
|
33
|
+
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
|
34
|
+
choices: [
|
|
35
|
+
{
|
|
36
|
+
message: { content: 'response text', role: 'assistant' },
|
|
37
|
+
finish_reason: 'stop',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
const mockGenAIEndpoint = 'openai.resources.chat.completions';
|
|
42
|
+
jest
|
|
43
|
+
.spyOn(wrapper_1.default, '_chatCompletionCommonSetter')
|
|
44
|
+
.mockImplementationOnce(async ({ genAIEndpoint, span }) => {
|
|
45
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, 1);
|
|
46
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
|
|
47
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
|
|
48
|
+
return {
|
|
49
|
+
genAIEndpoint,
|
|
50
|
+
model: 'gpt-3.5-turbo',
|
|
51
|
+
user: 'test-user',
|
|
52
|
+
cost: 0.5,
|
|
53
|
+
aiSystem: 'openai',
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
await wrapper_1.default._chatCompletion({
|
|
57
|
+
args: mockArgs,
|
|
58
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
59
|
+
response: mockResponse,
|
|
60
|
+
span,
|
|
61
|
+
});
|
|
62
|
+
expect(base_wrapper_1.default.recordMetrics).toHaveBeenCalledWith(span, {
|
|
63
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
64
|
+
model: 'gpt-3.5-turbo',
|
|
65
|
+
user: 'test-user',
|
|
66
|
+
cost: 0.5,
|
|
67
|
+
aiSystem: 'openai',
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('_chatCompletionCommonSetter', () => {
|
|
72
|
+
it('should set span attributes and return metric parameters', async () => {
|
|
73
|
+
const mockArgs = [
|
|
74
|
+
{
|
|
75
|
+
model: 'gpt-3.5-turbo',
|
|
76
|
+
messages: [{ role: 'user', content: 'test message' }],
|
|
77
|
+
max_tokens: 100,
|
|
78
|
+
temperature: 0.7,
|
|
79
|
+
top_p: 1,
|
|
80
|
+
user: 'test-user',
|
|
81
|
+
presence_penalty: 2,
|
|
82
|
+
frequency_penalty: 3,
|
|
83
|
+
seed: 3,
|
|
84
|
+
stream: false,
|
|
85
|
+
stop: ['STOP'],
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const mockResult = {
|
|
89
|
+
id: '123',
|
|
90
|
+
model: 'gpt-3.5-turbo',
|
|
91
|
+
usage: {
|
|
92
|
+
prompt_tokens: 10,
|
|
93
|
+
completion_tokens: 20,
|
|
94
|
+
total_tokens: 30,
|
|
95
|
+
completion_tokens_details: { reasoning_tokens: 5 },
|
|
96
|
+
},
|
|
97
|
+
choices: [
|
|
98
|
+
{
|
|
99
|
+
message: { content: 'response text', role: 'assistant' },
|
|
100
|
+
finish_reason: 'stop',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
system_fingerprint: 'fp_test',
|
|
104
|
+
service_tier: 'default',
|
|
105
|
+
};
|
|
106
|
+
const mockGenAIEndpoint = 'openai.resources.chat.completions';
|
|
107
|
+
jest.restoreAllMocks();
|
|
108
|
+
config_1.default.pricingInfo = {};
|
|
109
|
+
jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
|
|
110
|
+
const metricParams = await wrapper_1.default._chatCompletionCommonSetter({
|
|
111
|
+
args: mockArgs,
|
|
112
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
113
|
+
result: mockResult,
|
|
114
|
+
span,
|
|
115
|
+
});
|
|
116
|
+
// Basic request parameters
|
|
117
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, 1);
|
|
118
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
|
|
119
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
|
|
120
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_PRESENCE_PENALTY, 2);
|
|
121
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY, 3);
|
|
122
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_SEED, 3);
|
|
123
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
|
|
124
|
+
// New attributes
|
|
125
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES, ['STOP']);
|
|
126
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, 'gpt-3.5-turbo');
|
|
127
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.OPENAI_RESPONSE_SYSTEM_FINGERPRINT, 'fp_test');
|
|
128
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.OPENAI_RESPONSE_SERVICE_TIER, 'default');
|
|
129
|
+
expect(metricParams).toEqual({
|
|
130
|
+
genAIEndpoint: mockGenAIEndpoint,
|
|
131
|
+
model: 'gpt-3.5-turbo',
|
|
132
|
+
user: 'test-user',
|
|
133
|
+
cost: 0.5,
|
|
134
|
+
aiSystem: 'openai',
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
it('should handle tool calls properly', async () => {
|
|
138
|
+
const mockArgs = [
|
|
139
|
+
{
|
|
140
|
+
messages: [{ role: 'user', content: 'test message' }],
|
|
141
|
+
tools: [{ type: 'function', function: { name: 'get_weather' } }],
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
const mockResult = {
|
|
145
|
+
id: '123',
|
|
146
|
+
model: 'gpt-3.5-turbo',
|
|
147
|
+
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
|
148
|
+
choices: [
|
|
149
|
+
{
|
|
150
|
+
message: {
|
|
151
|
+
content: null,
|
|
152
|
+
role: 'assistant',
|
|
153
|
+
tool_calls: [
|
|
154
|
+
{
|
|
155
|
+
id: 'call_123',
|
|
156
|
+
type: 'function',
|
|
157
|
+
function: { name: 'get_weather', arguments: '{"location":"SF"}' },
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
finish_reason: 'tool_calls',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
config_1.default.pricingInfo = {};
|
|
166
|
+
jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
|
|
167
|
+
await wrapper_1.default._chatCompletionCommonSetter({
|
|
168
|
+
args: mockArgs,
|
|
169
|
+
genAIEndpoint: 'openai.resources.chat.completions',
|
|
170
|
+
result: mockResult,
|
|
171
|
+
span,
|
|
172
|
+
});
|
|
173
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_NAME, 'get_weather');
|
|
174
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, 'call_123');
|
|
175
|
+
expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_ARGS, '{"location":"SF"}');
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=openai-wrapper.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-wrapper.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/openai-wrapper.test.ts"],"names":[],"mappings":";;;;;AAAA,4CAAiD;AACjD,gEAA8C;AAC9C,0DAA2C;AAC3C,4DAA4C;AAC5C,mEAA0C;AAC1C,oFAA2D;AAE3D,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACjC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAClC,IAAI,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAEvD,MAAM,UAAU,GAAG,WAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAElD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,IAAU,CAAC;IAEf,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,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traces consistent with the Python SDK
|
|
5
|
+
* psycopg instrumentation for PostgreSQL queries.
|
|
6
|
+
*
|
|
7
|
+
* Python SDK reference: sdk/python/src/shield360/instrumentation/psycopg/utils.py
|
|
8
|
+
*
|
|
9
|
+
* Key alignment:
|
|
10
|
+
* - db.system.name = 'postgresql'
|
|
11
|
+
* - db.operation.name parsed from the SQL verb (SELECT/INSERT/UPDATE/DELETE/...)
|
|
12
|
+
* - db.collection.name = target table
|
|
13
|
+
* - db.namespace = database name
|
|
14
|
+
* - server.address, server.port (default localhost:5432)
|
|
15
|
+
* - db.query.text (when captureMessageContent is enabled)
|
|
16
|
+
* - db.query.parameter.<index> (only when captureDbParameters is enabled)
|
|
17
|
+
* - db.search.similarity_metric for pgvector operators (<=>, <->, <#>)
|
|
18
|
+
* - db.query.summary
|
|
19
|
+
* - db.response.returned_rows from result.rowCount
|
|
20
|
+
*/
|
|
21
|
+
export {};
|