9f54578ef79f49cff8672b7baa1c86d19a84569203edbd8dcf113bc52f4b9a48.json 6.5 KB

1
  1. {"ast":null,"code":"import { ChatPromptTemplate } from \"./chat.js\";\nfunction isWithStructuredOutput(x\n// eslint-disable-next-line @typescript-eslint/ban-types\n) {\n return typeof x === \"object\" && x != null && \"withStructuredOutput\" in x && typeof x.withStructuredOutput === \"function\";\n}\nfunction isRunnableBinding(x) {\n return typeof x === \"object\" && x != null && \"lc_id\" in x && Array.isArray(x.lc_id) && x.lc_id.join(\"/\") === \"langchain_core/runnables/RunnableBinding\";\n}\nexport class StructuredPrompt extends ChatPromptTemplate {\n get lc_aliases() {\n return {\n ...super.lc_aliases,\n schema: \"schema_\"\n };\n }\n constructor(input) {\n super(input);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.defineProperty(this, \"schema\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"prompts\", \"structured\"]\n });\n this.schema = input.schema;\n }\n pipe(coerceable) {\n if (isWithStructuredOutput(coerceable)) {\n return super.pipe(coerceable.withStructuredOutput(this.schema));\n }\n if (isRunnableBinding(coerceable) && isWithStructuredOutput(coerceable.bound)) {\n var _coerceable$kwargs;\n return super.pipe(coerceable.bound.withStructuredOutput(this.schema).bind((_coerceable$kwargs = coerceable.kwargs) !== null && _coerceable$kwargs !== void 0 ? _coerceable$kwargs : {}).withConfig(coerceable.config));\n }\n throw new Error(`Structured prompts need to be piped to a language model that supports the \"withStructuredOutput()\" method.`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static fromMessagesAndSchema(promptMessages, schema\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) {\n return StructuredPrompt.fromMessages(promptMessages, {\n schema\n });\n }\n}","map":{"version":3,"names":["ChatPromptTemplate","isWithStructuredOutput","x","withStructuredOutput","isRunnableBinding","Array","isArray","lc_id","join","StructuredPrompt","lc_aliases","schema","constructor","input","Object","defineProperty","enumerable","configurable","writable","value","pipe","coerceable","bound","_coerceable$kwargs","bind","kwargs","withConfig","config","Error","fromMessagesAndSchema","promptMessages","fromMessages"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@langchain/core/dist/prompts/structured.js"],"sourcesContent":["import { ChatPromptTemplate, } from \"./chat.js\";\nfunction isWithStructuredOutput(x\n// eslint-disable-next-line @typescript-eslint/ban-types\n) {\n return (typeof x === \"object\" &&\n x != null &&\n \"withStructuredOutput\" in x &&\n typeof x.withStructuredOutput === \"function\");\n}\nfunction isRunnableBinding(x) {\n return (typeof x === \"object\" &&\n x != null &&\n \"lc_id\" in x &&\n Array.isArray(x.lc_id) &&\n x.lc_id.join(\"/\") === \"langchain_core/runnables/RunnableBinding\");\n}\nexport class StructuredPrompt extends ChatPromptTemplate {\n get lc_aliases() {\n return {\n ...super.lc_aliases,\n schema: \"schema_\",\n };\n }\n constructor(input) {\n super(input);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.defineProperty(this, \"schema\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"lc_namespace\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: [\"langchain_core\", \"prompts\", \"structured\"]\n });\n this.schema = input.schema;\n }\n pipe(coerceable) {\n if (isWithStructuredOutput(coerceable)) {\n return super.pipe(coerceable.withStructuredOutput(this.schema));\n }\n if (isRunnableBinding(coerceable) &&\n isWithStructuredOutput(coerceable.bound)) {\n return super.pipe(coerceable.bound\n .withStructuredOutput(this.schema)\n .bind(coerceable.kwargs ?? {})\n .withConfig(coerceable.config));\n }\n throw new Error(`Structured prompts need to be piped to a language model that supports the \"withStructuredOutput()\" method.`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static fromMessagesAndSchema(promptMessages, schema\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) {\n return StructuredPrompt.fromMessages(promptMessages, {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