Skip to content

Commit

Permalink
fix(instrumentation): assert raw prompt (#248)
Browse files Browse the repository at this point in the history
Signed-off-by: Milan Gallas <Milan.Gallas@ibm.com>
  • Loading branch information
GALLLASMILAN authored Dec 12, 2024
1 parent 0e69d11 commit 24546c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/instrumentation/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, any> & {
messagesToPrompt: BAMChatLLMInputConfig["messagesToPrompt"];
} {
return isFunction(getProp(instance, ["messagesToPrompt"])) && instance instanceof BaseLLM;
return Boolean(
instance instanceof BaseLLM &&
"messagesToPrompt" in instance &&
isFunction(instance.messagesToPrompt),
);
}

0 comments on commit 24546c9

Please sign in to comment.