From af722feb1865a72f910a3de9fb15042688fc2131 Mon Sep 17 00:00:00 2001 From: GALLLASMILAN Date: Fri, 22 Nov 2024 13:09:23 +0100 Subject: [PATCH] fix: review 2 Signed-off-by: GALLLASMILAN --- docs/_sidebar.md | 2 ++ docs/integrations.md | 4 +-- docs/native-telemetry.md | 2 +- examples/integrations/langgraph.ts | 4 +-- .../create-telemetry-metrics-middleware.ts | 2 +- src/instrumentation/opentelemetry.spec.ts | 19 +++++++----- src/instrumentation/sdk.ts | 2 +- yarn.lock | 30 +++++++++---------- 8 files changed, 36 insertions(+), 29 deletions(-) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index db1540a9..df2852b7 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -24,3 +24,5 @@ - Others - [Integrations](integrations.md) + - [Instrumentation](instrumentation.md) + - [Native Telemetry](native-telemetry.md) diff --git a/docs/integrations.md b/docs/integrations.md index 6a9598e7..df491a18 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -54,8 +54,8 @@ const workflow = new Workflow({ }, { signal: ctx.signal, recursionLimit: 5 }, ); - const answer = response.messages.at(-1).content; - return { next: Workflow.END, update: { answer } }; + const answer = response.messages.at(-1)?.content; + return { next: Workflow.END, update: { answer: answer?.toString() } }; }); const memory = new UnconstrainedMemory(); diff --git a/docs/native-telemetry.md b/docs/native-telemetry.md index c4584ecd..95077ecd 100644 --- a/docs/native-telemetry.md +++ b/docs/native-telemetry.md @@ -21,6 +21,6 @@ We value your privacy and ensure that **no sensitive data** is collected through We understand that not all users want to send telemetry data. You can easily disable this feature by setting an environment variable: -```bash +``` BEE_FRAMEWORK_INSTRUMENTATION_METRICS_ENABLED=false ``` diff --git a/examples/integrations/langgraph.ts b/examples/integrations/langgraph.ts index 0991f5d7..8e27b05b 100644 --- a/examples/integrations/langgraph.ts +++ b/examples/integrations/langgraph.ts @@ -45,8 +45,8 @@ const workflow = new Workflow({ }, { signal: ctx.signal, recursionLimit: 5 }, ); - const answer = response.messages.at(-1).content; - return { next: Workflow.END, update: { answer } }; + const answer = response.messages.at(-1)?.content; + return { next: Workflow.END, update: { answer: answer?.toString() } }; }); const memory = new UnconstrainedMemory(); diff --git a/src/instrumentation/create-telemetry-metrics-middleware.ts b/src/instrumentation/create-telemetry-metrics-middleware.ts index 1a56c2f3..e5913937 100644 --- a/src/instrumentation/create-telemetry-metrics-middleware.ts +++ b/src/instrumentation/create-telemetry-metrics-middleware.ts @@ -1,5 +1,5 @@ /** - * Copyright 2024 IBM Corp. + * Copyright 2025 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/instrumentation/opentelemetry.spec.ts b/src/instrumentation/opentelemetry.spec.ts index cadcdbfe..033c252d 100644 --- a/src/instrumentation/opentelemetry.spec.ts +++ b/src/instrumentation/opentelemetry.spec.ts @@ -1,5 +1,5 @@ /** - * Copyright 2024 IBM Corp. + * Copyright 2025 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,19 +25,26 @@ import { DuckDuckGoSearchTool } from "@/tools/search/duckDuckGoSearch.js"; import { WebCrawlerTool } from "@/tools/web/webCrawler.js"; import { ArXivTool } from "@/tools/arxiv.js"; import { CalculatorTool } from "@/tools/calculator.js"; -import { LLMTool } from "@/tools/llm.js"; import { OllamaLLM } from "@/adapters/ollama/llm.js"; import { WatsonXLLM } from "@/adapters/watsonx/llm.js"; import { LLM } from "@/llms/llm.js"; import { Emitter } from "@/emitter/emitter.js"; -import { GenerateCallbacks, LLMMeta, BaseLLMTokenizeOutput, AsyncStream } from "@/llms/base.js"; +import { + BaseLLMEvents, + LLMMeta, + BaseLLMTokenizeOutput, + AsyncStream, + EmbeddingOutput, +} from "@/llms/base.js"; import { OllamaChatLLM } from "@/adapters/ollama/chat.js"; import { TokenMemory } from "@/memory/tokenMemory.js"; -import { GraniteBeeAgent } from "@/agents/granite/agent.js"; import { SlidingCache } from "@/cache/slidingCache.js"; export class CustomLLM extends LLM { - public readonly emitter = Emitter.root.child({ + embed(): Promise { + throw new Error("Method not implemented."); + } + public readonly emitter = Emitter.root.child({ namespace: ["bam", "llm"], creator: this, }); @@ -71,7 +78,6 @@ describe("opentelemetry", () => { new WebCrawlerTool(), new ArXivTool(), new CalculatorTool(), - new LLMTool({ llm: new OllamaLLM({ modelId: "llama3.1" }) }), // llm new OllamaLLM({ modelId: "llama3.1" }), new WatsonXLLM({ modelId: "llama3.1", apiKey: "xx" }), @@ -79,7 +85,6 @@ describe("opentelemetry", () => { new OllamaChatLLM({ modelId: "llama3.1" }), // agent new BeeAgent({ llm, memory, tools: [] }), - new GraniteBeeAgent({ llm, memory, tools: [] }), ])("Should return true for '%s'", (value) => { expect(isMeasurementedInstance(value)).toBeTruthy(); }); diff --git a/src/instrumentation/sdk.ts b/src/instrumentation/sdk.ts index 07f47098..68f471a7 100644 --- a/src/instrumentation/sdk.ts +++ b/src/instrumentation/sdk.ts @@ -1,5 +1,5 @@ /** - * Copyright 2024 IBM Corp. + * Copyright 2025 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/yarn.lock b/yarn.lock index 537e80da..cfbe9108 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4074,29 +4074,29 @@ __metadata: linkType: hard "@types/node@npm:*, @types/node@npm:>=13.7.0": - version: 22.10.7 - resolution: "@types/node@npm:22.10.7" + version: 22.10.9 + resolution: "@types/node@npm:22.10.9" dependencies: undici-types: "npm:~6.20.0" - checksum: 10c0/c941b4689dfc4044b64a5f601306cbcb0c7210be853ba378a5dd44137898c45accedd796ee002ad9407024cac7ecaf5049304951cb1d80ce3d7cebbbae56f20e + checksum: 10c0/ed2d7b2cf20ce520e04711eab48e9cd7d6a835d2859fbdc5d9a8c5e00a97c1f872a409f789783c473062b29beaf1cddf4b1c7ad03ae3fe433b072b7cf9fff741 languageName: node linkType: hard "@types/node@npm:^18.11.18": - version: 18.19.71 - resolution: "@types/node@npm:18.19.71" + version: 18.19.74 + resolution: "@types/node@npm:18.19.74" dependencies: undici-types: "npm:~5.26.4" - checksum: 10c0/9f9b4a1c4e2db2994ef36f165322b3bb807466e3f92751ed52a40af0212917bc6ecd12dc6775eb829176b71b26570bea9c6a0a2d9e3ae6b496721c71934244db + checksum: 10c0/365d9cc2af934965aa6a8471e24ae80add815c15dc094e42a320c57c1ea5416032f0b7ef6f23e32174c34811fbb8d89ea8eaa1396548610fbb8ba317b6e93fbf languageName: node linkType: hard "@types/node@npm:^20.13.0, @types/node@npm:^20.17.9": - version: 20.17.14 - resolution: "@types/node@npm:20.17.14" + version: 20.17.16 + resolution: "@types/node@npm:20.17.16" dependencies: undici-types: "npm:~6.19.2" - checksum: 10c0/2af0722989c677416dec4d9bc37e262a9724e090e5ce021a976e4ab12d4fa26aecbb00dddc8114d0fbf4a6552f12ace0ec98156247a20bf4d57809b7ce90ea5a + checksum: 10c0/50c589dd6a377238bc51b6fb5b8fc60ff6d688df0bde621d4a9fc59f480eb956cdf6d46052e1cb9536f150bc62e9194ddc733aa78b65e812155b4d3a32717de2 languageName: node linkType: hard @@ -6472,9 +6472,9 @@ __metadata: linkType: hard "electron-to-chromium@npm:^1.5.73": - version: 1.5.84 - resolution: "electron-to-chromium@npm:1.5.84" - checksum: 10c0/8362d556360eba420ea3475a7878c8fa8507a42c4ebfbf44108f6acc4edbe30a1cde79e95613bdc9ae6e7d73bf1776347cf7f615c1a220f63e34a0fa029568e0 + version: 1.5.86 + resolution: "electron-to-chromium@npm:1.5.86" + checksum: 10c0/f0af8465d9390d21cb3ffec5ed6ce011b5026615f59ebc7a70bb0da806a27918888b2ec446432a5080da0e0bea4f3c6a3a4dcff24c9eb8e884813b0ccceedc59 languageName: node linkType: hard @@ -11189,12 +11189,12 @@ __metadata: linkType: hard "p-queue-compat@npm:^1.0.227": - version: 1.0.228 - resolution: "p-queue-compat@npm:1.0.228" + version: 1.0.229 + resolution: "p-queue-compat@npm:1.0.229" dependencies: eventemitter3: "npm:5.x" p-timeout-compat: "npm:^1.0.3" - checksum: 10c0/8f7f128e70c3dfe0a5646c49b9302a6cf0234cdb9340a75758271ff81ee0402b2919fa79fb5be18e776e517994d89bb6a968c3d2ac3781fdf819a4a57a6ebbd5 + checksum: 10c0/f9882127cf9a16a33e7b31142aeb73d6c6f1a11c6c7230eb2328bf8dc679dbb35f2b153cbfc49e19090d7c6226f6c2391ee0a93e3d8bd9ef1e88be63f7579f09 languageName: node linkType: hard