Skip to content

Commit

Permalink
Revert "core[patch]: Add check for bind tools in structured prompt (#…
Browse files Browse the repository at this point in the history
…5882)" (#5909)

This reverts commit b7e4264.
  • Loading branch information
bracesproul authored Jun 26, 2024
1 parent b7e4264 commit 0f1d90b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
18 changes: 2 additions & 16 deletions langchain-core/src/prompts/structured.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { BaseLanguageModel } from "../language_models/base.js";
import { BaseChatModel } from "../language_models/chat_models.js";
import { ChatPromptValueInterface } from "../prompt_values.js";
import {
RunnableLike,
Expand All @@ -24,18 +22,7 @@ function isWithStructuredOutput(
typeof x === "object" &&
x != null &&
"withStructuredOutput" in x &&
x.withStructuredOutput !== BaseLanguageModel.prototype.withStructuredOutput
);
}

function isBindTools(x: unknown): x is {
bindTools: (...arg: unknown[]) => Runnable;
} {
return (
typeof x === "object" &&
x != null &&
"bindTools" in x &&
x.bindTools !== BaseChatModel.prototype.bindTools
typeof x.withStructuredOutput === "function"
);
}

Expand Down Expand Up @@ -97,8 +84,7 @@ export class StructuredPrompt<

if (
isRunnableBinding(coerceable) &&
isWithStructuredOutput(coerceable.bound) &&
isBindTools(coerceable.bound)
isWithStructuredOutput(coerceable.bound)
) {
return super.pipe(
coerceable.bound
Expand Down
8 changes: 0 additions & 8 deletions langchain-core/src/prompts/tests/structured.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ import {
StructuredOutputMethodParams,
StructuredOutputMethodOptions,
BaseLanguageModelInput,
ToolDefinition,
} from "../../language_models/base.js";
import { BaseMessage } from "../../messages/index.js";
import { Runnable, RunnableLambda } from "../../runnables/base.js";
import { RunnableConfig } from "../../runnables/config.js";
import { FakeListChatModel } from "../../utils/testing/index.js";
import { StructuredPrompt } from "../structured.js";
import { load } from "../../load/index.js";
import { StructuredToolInterface } from "../../tools.js";

class FakeStructuredChatModel extends FakeListChatModel {
override bindTools(
_tools: (StructuredToolInterface | ToolDefinition | Record<string, any>)[]
): Runnable {
return this.bind({});
}

withStructuredOutput<
RunOutput extends Record<string, any> = Record<string, any>
>(
Expand Down

0 comments on commit 0f1d90b

Please sign in to comment.