@arizeai/openinference-instrumentation-beeai 1.1.2 → 1.2.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/dist/esm/helpers/getSerializedObjectSafe.js +2 -2
- package/dist/esm/helpers/getSerializedObjectSafe.js.map +1 -1
- package/dist/esm/middleware.d.ts.map +1 -1
- package/dist/esm/middleware.js +25 -3
- package/dist/esm/middleware.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esnext/helpers/getSerializedObjectSafe.js +9 -9
- package/dist/esnext/helpers/getSerializedObjectSafe.js.map +1 -1
- package/dist/esnext/middleware.d.ts.map +1 -1
- package/dist/esnext/middleware.js +25 -3
- package/dist/esnext/middleware.js.map +1 -1
- package/dist/esnext/tsconfig.esnext.tsbuildinfo +1 -1
- package/dist/examples/run-react-agent.d.ts +2 -0
- package/dist/examples/run-react-agent.d.ts.map +1 -0
- package/dist/examples/{run-agent.js → run-react-agent.js} +1 -1
- package/dist/examples/run-react-agent.js.map +1 -0
- package/dist/examples/run-toolcalling-agent.d.ts +2 -0
- package/dist/examples/run-toolcalling-agent.d.ts.map +1 -0
- package/dist/examples/run-toolcalling-agent.js +36 -0
- package/dist/examples/run-toolcalling-agent.js.map +1 -0
- package/dist/src/helpers/getSerializedObjectSafe.js +9 -9
- package/dist/src/helpers/getSerializedObjectSafe.js.map +1 -1
- package/dist/src/middleware.d.ts.map +1 -1
- package/dist/src/middleware.js +25 -3
- package/dist/src/middleware.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/helpers/getSerializedObjectSafe.ts +2 -2
- package/src/middleware.ts +35 -4
- package/dist/examples/run-agent.d.ts +0 -2
- package/dist/examples/run-agent.d.ts.map +0 -1
- package/dist/examples/run-agent.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/openinference-instrumentation-beeai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "gallas.milan@gmail.com",
|
|
6
6
|
"description": "OpenInference Instrumentation for BeeAI framework",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@opentelemetry/api": "^1.9.0",
|
|
33
33
|
"@opentelemetry/instrumentation": "^0.57.1",
|
|
34
34
|
"remeda": "^2.20.2",
|
|
35
|
-
"@arizeai/openinference-
|
|
36
|
-
"@arizeai/openinference-
|
|
35
|
+
"@arizeai/openinference-semantic-conventions": "1.0.1",
|
|
36
|
+
"@arizeai/openinference-core": "1.0.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"beeai-framework": "^0.1.9"
|
|
@@ -114,7 +114,7 @@ export function getSerializedObjectSafe(
|
|
|
114
114
|
return {
|
|
115
115
|
[SemanticConventions.OPENINFERENCE_SPAN_KIND]:
|
|
116
116
|
OpenInferenceSpanKind.AGENT,
|
|
117
|
-
iteration: meta
|
|
117
|
+
iteration: meta?.iteration,
|
|
118
118
|
...(tools?.length > 0 && {
|
|
119
119
|
[SemanticConventions.LLM_TOOLS]: tools.map((tool) => ({
|
|
120
120
|
[SemanticConventions.TOOL_NAME]: tool.name,
|
|
@@ -185,7 +185,7 @@ export function getSerializedObjectSafe(
|
|
|
185
185
|
return {
|
|
186
186
|
[SemanticConventions.OPENINFERENCE_SPAN_KIND]:
|
|
187
187
|
OpenInferenceSpanKind.TOOL,
|
|
188
|
-
thought: data
|
|
188
|
+
thought: data?.iteration?.thought,
|
|
189
189
|
...(data?.input
|
|
190
190
|
? {
|
|
191
191
|
[SemanticConventions.TOOL_PARAMETERS]: JSON.stringify(data.input),
|
package/src/middleware.ts
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
successLLMEventName,
|
|
37
37
|
} from "./config";
|
|
38
38
|
import { createFullPath } from "beeai-framework/emitter/utils";
|
|
39
|
-
import
|
|
39
|
+
import { ReActAgent } from "beeai-framework/agents/react/agent";
|
|
40
40
|
import { BaseAgent } from "beeai-framework/agents/base";
|
|
41
41
|
import { diag } from "@opentelemetry/api";
|
|
42
42
|
import { FrameworkSpan, GeneratedResponse } from "./types";
|
|
@@ -45,6 +45,8 @@ import {
|
|
|
45
45
|
OpenInferenceSpanKind,
|
|
46
46
|
SemanticConventions,
|
|
47
47
|
} from "@arizeai/openinference-semantic-conventions";
|
|
48
|
+
import { ToolCallingAgent } from "beeai-framework/agents/toolCalling/agent";
|
|
49
|
+
import type { ToolCallingAgentCallbacks } from "beeai-framework/agents/toolCalling/types";
|
|
48
50
|
|
|
49
51
|
export const activeTracesMap = new Map<string, string>();
|
|
50
52
|
|
|
@@ -307,11 +309,11 @@ export function createTelemetryMiddleware(
|
|
|
307
309
|
}
|
|
308
310
|
});
|
|
309
311
|
|
|
310
|
-
// The generated response and message history are collected from the `success`
|
|
312
|
+
// The generated response and message history are collected from the `success` event generated by ReActAgent
|
|
311
313
|
emitter.match(
|
|
312
314
|
(event) =>
|
|
313
315
|
event.name === successLLMEventName &&
|
|
314
|
-
event.creator instanceof
|
|
316
|
+
event.creator instanceof ReActAgent,
|
|
315
317
|
(data: InferCallbackValue<ReActAgentCallbacks["success"]>) => {
|
|
316
318
|
try {
|
|
317
319
|
const { data: dataObject, memory } = data;
|
|
@@ -326,7 +328,36 @@ export function createTelemetryMiddleware(
|
|
|
326
328
|
}));
|
|
327
329
|
} catch (e) {
|
|
328
330
|
diag.warn(
|
|
329
|
-
"Instrumentation error. Unable to map messages to history",
|
|
331
|
+
"Instrumentation error. Unable to map messages to history for ReActAgent",
|
|
332
|
+
e,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
// The generated response and message history are collected from the `success` event generated by ToolCallingAgentCallbacks
|
|
339
|
+
emitter.match(
|
|
340
|
+
(event) =>
|
|
341
|
+
event.name === successLLMEventName &&
|
|
342
|
+
event.creator instanceof ToolCallingAgent,
|
|
343
|
+
(data: InferCallbackValue<ToolCallingAgentCallbacks["success"]>) => {
|
|
344
|
+
try {
|
|
345
|
+
const { state } = data;
|
|
346
|
+
|
|
347
|
+
if (state.result) {
|
|
348
|
+
generatedMessage = {
|
|
349
|
+
role: state.result.role,
|
|
350
|
+
text: state.result.text,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
history = state.memory.messages.map((msg) => ({
|
|
355
|
+
text: msg.text,
|
|
356
|
+
role: msg.role,
|
|
357
|
+
}));
|
|
358
|
+
} catch (e) {
|
|
359
|
+
diag.warn(
|
|
360
|
+
"Instrumentation error. Unable to map messages to history for ToolCallingAgent",
|
|
330
361
|
e,
|
|
331
362
|
);
|
|
332
363
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-agent.d.ts","sourceRoot":"","sources":["../../examples/run-agent.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-agent.js","sourceRoot":"","sources":["../../examples/run-agent.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA2B;AAC3B,8DAAgE;AAChE,uEAA+E;AAC/E,oEAAiE;AACjE,oFAAqF;AACrF,uEAAwE;AAExE,MAAM,GAAG,GAAG,IAAI,sBAAe,CAAC,UAAU,CAAC,CAAC,CAAC,+DAA+D;AAC5G,MAAM,KAAK,GAAG,IAAI,kBAAU,CAAC;IAC3B,GAAG,EAAE,8CAA8C;IACnD,MAAM,EAAE,IAAI,yBAAW,EAAE,EAAE,4CAA4C;IACvE,KAAK,EAAE,CAAC,IAAI,uCAAoB,EAAE,EAAE,IAAI,yBAAa,EAAE,CAAC,EAAE,2CAA2C;CACtG,CAAC,CAAC;AAEH,SAAe,IAAI;;QACjB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC;YAC/B,MAAM,EAAE,0CAA0C;SACnD,CAAC,CAAC;QACH,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CAAA;AAED,sCAAsC;AACtC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|