@langchain/core 0.3.49-rc.0 → 0.3.50

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.
@@ -33,6 +33,12 @@ class StructuredPrompt extends chat_js_1.ChatPromptTemplate {
33
33
  writable: true,
34
34
  value: void 0
35
35
  });
36
+ Object.defineProperty(this, "method", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
36
42
  Object.defineProperty(this, "lc_namespace", {
37
43
  enumerable: true,
38
44
  configurable: true,
@@ -40,6 +46,7 @@ class StructuredPrompt extends chat_js_1.ChatPromptTemplate {
40
46
  value: ["langchain_core", "prompts", "structured"]
41
47
  });
42
48
  this.schema = input.schema;
49
+ this.method = input.method;
43
50
  }
44
51
  pipe(coerceable) {
45
52
  if (isWithStructuredOutput(coerceable)) {
@@ -47,18 +54,23 @@ class StructuredPrompt extends chat_js_1.ChatPromptTemplate {
47
54
  }
48
55
  if (isRunnableBinding(coerceable) &&
49
56
  isWithStructuredOutput(coerceable.bound)) {
50
- return super.pipe(coerceable.bound
51
- .withStructuredOutput(this.schema)
52
- .bind(coerceable.kwargs ?? {})
53
- .withConfig(coerceable.config));
57
+ return super.pipe(this.method
58
+ ? coerceable.bound
59
+ .withStructuredOutput(this.schema, { method: this.method })
60
+ .bind(coerceable.kwargs ?? {})
61
+ .withConfig(coerceable.config)
62
+ : coerceable.bound
63
+ .withStructuredOutput(this.schema)
64
+ .bind(coerceable.kwargs ?? {})
65
+ .withConfig(coerceable.config));
54
66
  }
55
67
  throw new Error(`Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.`);
56
68
  }
57
69
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
- static fromMessagesAndSchema(promptMessages, schema
70
+ static fromMessagesAndSchema(promptMessages, schema, method
59
71
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
72
  ) {
61
- return StructuredPrompt.fromMessages(promptMessages, { schema });
73
+ return StructuredPrompt.fromMessages(promptMessages, { schema, method });
62
74
  }
63
75
  }
64
76
  exports.StructuredPrompt = StructuredPrompt;
@@ -8,12 +8,14 @@ import { BaseMessagePromptTemplateLike, ChatPromptTemplate, ChatPromptTemplateIn
8
8
  */
9
9
  export interface StructuredPromptInput<RunInput extends InputValues = any, PartialVariableName extends string = any> extends ChatPromptTemplateInput<RunInput, PartialVariableName> {
10
10
  schema: Record<string, any>;
11
+ method?: "jsonMode" | "jsonSchema" | "functionMode";
11
12
  }
12
13
  export declare class StructuredPrompt<RunInput extends InputValues = any, PartialVariableName extends string = any> extends ChatPromptTemplate<RunInput, PartialVariableName> implements StructuredPromptInput<RunInput, PartialVariableName> {
13
14
  schema: Record<string, any>;
15
+ method?: "jsonMode" | "jsonSchema" | "functionMode";
14
16
  lc_namespace: string[];
15
17
  get lc_aliases(): Record<string, string>;
16
18
  constructor(input: StructuredPromptInput<RunInput, PartialVariableName>);
17
19
  pipe<NewRunOutput>(coerceable: RunnableLike<ChatPromptValueInterface, NewRunOutput>): Runnable<RunInput, Exclude<NewRunOutput, Error>, RunnableConfig>;
18
- static fromMessagesAndSchema<RunInput extends InputValues = any>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], schema: StructuredPromptInput["schema"]): ChatPromptTemplate<RunInput, any>;
20
+ static fromMessagesAndSchema<RunInput extends InputValues = any>(promptMessages: (ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike)[], schema: StructuredPromptInput["schema"], method?: "jsonMode" | "jsonSchema" | "functionMode"): ChatPromptTemplate<RunInput, any>;
19
21
  }
@@ -30,6 +30,12 @@ export class StructuredPrompt extends ChatPromptTemplate {
30
30
  writable: true,
31
31
  value: void 0
32
32
  });
33
+ Object.defineProperty(this, "method", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: void 0
38
+ });
33
39
  Object.defineProperty(this, "lc_namespace", {
34
40
  enumerable: true,
35
41
  configurable: true,
@@ -37,6 +43,7 @@ export class StructuredPrompt extends ChatPromptTemplate {
37
43
  value: ["langchain_core", "prompts", "structured"]
38
44
  });
39
45
  this.schema = input.schema;
46
+ this.method = input.method;
40
47
  }
41
48
  pipe(coerceable) {
42
49
  if (isWithStructuredOutput(coerceable)) {
@@ -44,17 +51,22 @@ export class StructuredPrompt extends ChatPromptTemplate {
44
51
  }
45
52
  if (isRunnableBinding(coerceable) &&
46
53
  isWithStructuredOutput(coerceable.bound)) {
47
- return super.pipe(coerceable.bound
48
- .withStructuredOutput(this.schema)
49
- .bind(coerceable.kwargs ?? {})
50
- .withConfig(coerceable.config));
54
+ return super.pipe(this.method
55
+ ? coerceable.bound
56
+ .withStructuredOutput(this.schema, { method: this.method })
57
+ .bind(coerceable.kwargs ?? {})
58
+ .withConfig(coerceable.config)
59
+ : coerceable.bound
60
+ .withStructuredOutput(this.schema)
61
+ .bind(coerceable.kwargs ?? {})
62
+ .withConfig(coerceable.config));
51
63
  }
52
64
  throw new Error(`Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.`);
53
65
  }
54
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- static fromMessagesAndSchema(promptMessages, schema
67
+ static fromMessagesAndSchema(promptMessages, schema, method
56
68
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
69
  ) {
58
- return StructuredPrompt.fromMessages(promptMessages, { schema });
70
+ return StructuredPrompt.fromMessages(promptMessages, { schema, method });
59
71
  }
60
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.3.49-rc.0",
3
+ "version": "0.3.50",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {