🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat: add additional input/output parsing for pydantic via OTel (#6138)
Steffen Schmitza6c1678da86b
diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.tsindex 857bc81b78..77ec6f4956 100644--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts@@ -730,6 +730,36 @@ describe("OTel Resource Span Mapping", () => {entityAttributeValue: "gpt-4o-mini",},],+ [+ "#6084: should map input to input for pydantic",+ {+ entity: "observation",+ otelAttributeKey: "input",+ otelAttributeValue: {+ stringValue: JSON.stringify({+ task: "Play some chess",+ stream: false,+ }),+ },+ entityAttributeKey: "input",+ entityAttributeValue: JSON.stringify({+ task: "Play some chess",+ stream: false,+ }),+ },+ ],+ [+ "#6084: should map model_config to modelParameters",+ {+ entity: "observation",+ otelAttributeKey: "model_config",+ otelAttributeValue: {+ stringValue: '{"max_tokens": 4096}',+ },+ entityAttributeKey: "modelParameters.max_tokens",+ entityAttributeValue: 4096,+ },+ ],["#5412: should map input.value to input for smolagents",{diff --git a/web/src/features/otel/server/index.ts b/web/src/features/otel/server/index.tsindex d4e39963a4..d1063da68a 100644--- a/web/src/features/otel/server/index.ts+++ b/web/src/features/otel/server/index.ts@@ -203,6 +203,13 @@ const extractInputAndOutput = (return { input, output };}+ // Pydantic uses input and output+ input = attributes["input"];+ output = attributes["output"];+ if (input || output) {+ return { input, output };+ }+// TraceLoop uses attributes propertyconst inputAttributes = Object.keys(attributes).filter((key) =>key.startsWith("gen_ai.prompt"),@@ -301,6 +308,14 @@ const extractModelParameters = (}}+ if (attributes["model_config"]) {+ try {+ return JSON.parse(attributes["model_config"] as string);+ } catch (e) {+ // fallthrough+ }+ }+const modelParameters = Object.keys(attributes).filter((key) =>key.startsWith("gen_ai.request."),);