From 24546c9a897d9147ebe9fafec5eb1c3d5898e49f Mon Sep 17 00:00:00 2001 From: Milan Gallas <44726162+GALLLASMILAN@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:21:26 +0100 Subject: [PATCH] fix(instrumentation): assert raw prompt (#248) Signed-off-by: Milan Gallas --- src/instrumentation/helpers/utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/instrumentation/helpers/utils.ts b/src/instrumentation/helpers/utils.ts index d5a43293..7b571d25 100644 --- a/src/instrumentation/helpers/utils.ts +++ b/src/instrumentation/helpers/utils.ts @@ -15,12 +15,15 @@ */ import { BAMChatLLMInputConfig } from "@/adapters/bam/chat.js"; -import { getProp } from "@/internals/helpers/object.js"; import { BaseLLM } from "@/llms/base.js"; import { isFunction } from "remeda"; export function assertLLMWithMessagesToPromptFn(instance: object): instance is BaseLLM & { messagesToPrompt: BAMChatLLMInputConfig["messagesToPrompt"]; } { - return isFunction(getProp(instance, ["messagesToPrompt"])) && instance instanceof BaseLLM; + return Boolean( + instance instanceof BaseLLM && + "messagesToPrompt" in instance && + isFunction(instance.messagesToPrompt), + ); }