@langchain/core
Advanced tools
@@ -11,5 +11,7 @@ import { ChatPromptValueInterface } from "../prompt_values.js"; | ||
schema: Record<string, any>; | ||
method?: "jsonMode" | "jsonSchema" | "functionMode"; | ||
} | ||
export declare class StructuredPrompt<RunInput extends InputValues = any, PartialVariableName extends string = any> extends ChatPromptTemplate<RunInput, PartialVariableName> implements StructuredPromptInput<RunInput, PartialVariableName> { | ||
schema: Record<string, any>; | ||
method?: "jsonMode" | "jsonSchema" | "functionMode"; | ||
lc_namespace: string[]; | ||
@@ -19,3 +21,3 @@ get lc_aliases(): Record<string, string>; | ||
pipe<NewRunOutput>(coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig>; | ||
static fromMessagesAndSchema<RunInput extends InputValues = any>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], schema: StructuredPromptInput["schema"]): ChatPromptTemplate<RunInput, any>; | ||
static fromMessagesAndSchema<RunInput extends InputValues = any>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], schema: StructuredPromptInput["schema"], method?: "jsonMode" | "jsonSchema" | "functionMode"): ChatPromptTemplate<RunInput, any>; | ||
} |
@@ -33,2 +33,8 @@ import { ChatPromptTemplate, } from "./chat.js"; | ||
}); | ||
Object.defineProperty(this, "method", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "lc_namespace", { | ||
@@ -41,2 +47,3 @@ enumerable: true, | ||
this.schema = input.schema; | ||
this.method = input.method; | ||
} | ||
@@ -49,6 +56,11 @@ pipe(coerceable) { | ||
isWithStructuredOutput(coerceable.bound)) { | ||
return super.pipe(coerceable.bound | ||
.withStructuredOutput(this.schema) | ||
.bind(coerceable.kwargs ?? {}) | ||
.withConfig(coerceable.config)); | ||
return super.pipe(this.method | ||
? coerceable.bound | ||
.withStructuredOutput(this.schema, { method: this.method }) | ||
.bind(coerceable.kwargs ?? {}) | ||
.withConfig(coerceable.config) | ||
: coerceable.bound | ||
.withStructuredOutput(this.schema) | ||
.bind(coerceable.kwargs ?? {}) | ||
.withConfig(coerceable.config)); | ||
} | ||
@@ -58,7 +70,7 @@ throw new Error(`Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.`); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
static fromMessagesAndSchema(promptMessages, schema | ||
static fromMessagesAndSchema(promptMessages, schema, method | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
) { | ||
return StructuredPrompt.fromMessages(promptMessages, { schema }); | ||
return StructuredPrompt.fromMessages(promptMessages, { schema, method }); | ||
} | ||
} |
{ | ||
"name": "@langchain/core", | ||
"version": "0.3.49", | ||
"version": "0.3.50", | ||
"description": "Core LangChain.js abstractions and schemas", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
2291337
0.05%57360
0.05%