Skip to content

Commit 636e809

Browse files
feat(langchain): add toolEmulator middleware (#9339)
1 parent 39dbe63 commit 636e809

File tree

4 files changed

+572
-0
lines changed

4 files changed

+572
-0
lines changed

libs/langchain/src/agents/middleware/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@ export {
4646
toolRetryMiddleware,
4747
type ToolRetryMiddlewareConfig,
4848
} from "./toolRetry.js";
49+
export {
50+
toolEmulatorMiddleware,
51+
type ToolEmulatorOptions,
52+
} from "./toolEmulator.js";
4953
export { type AgentMiddleware } from "./types.js";
5054
export { countTokensApproximately } from "./utils.js";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { AIMessage } from "@langchain/core/messages";
2+
3+
export const ChatOpenAI = class MockChatOpenAI {
4+
lc_kwargs: Record<string, unknown>;
5+
6+
constructor(params?: Record<string, unknown>) {
7+
this.lc_kwargs = params || {};
8+
}
9+
10+
async invoke() {
11+
return new AIMessage({
12+
content: "Emulated response for openai",
13+
});
14+
}
15+
16+
getName() {
17+
return "ChatOpenAI";
18+
}
19+
20+
get _modelType() {
21+
return "base_chat_model";
22+
}
23+
24+
get lc_runnable() {
25+
return true;
26+
}
27+
};

0 commit comments

Comments
 (0)