Skip to content

Commit

Permalink
langchain[patch]: Fix ImagePromptTemplate deserialization, export Rem…
Browse files Browse the repository at this point in the history
…oteRunnable directly from @langchain/core (#4308)

* Fix ImagePromptTemplate deserialization

* Bump core version
  • Loading branch information
jacoblee93 authored Feb 7, 2024
1 parent 4607e88 commit 8c676db
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 467 deletions.
7 changes: 7 additions & 0 deletions langchain/langchain.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,13 @@ export const config = {
alias: ["prompts", "chat"],
path: "@langchain/core/prompts",
},
{
modules: [
"ImagePromptTemplate",
],
alias: ["prompts", "image"],
path: "@langchain/core/prompts",
},
{
modules: ["PipelinePromptTemplate"],
alias: ["prompts", "pipeline"],
Expand Down
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@
"dependencies": {
"@anthropic-ai/sdk": "^0.9.1",
"@langchain/community": "~0.0.20",
"@langchain/core": "~0.1.16",
"@langchain/core": "~0.1.24",
"@langchain/openai": "~0.0.12",
"binary-extensions": "^2.2.0",
"expr-eval": "^2.0.2",
Expand Down
5 changes: 5 additions & 0 deletions langchain/src/load/import_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {
HumanMessagePromptTemplate,
MessagesPlaceholder,
SystemMessagePromptTemplate,
ImagePromptTemplate,
PipelinePromptTemplate
} from "@langchain/core/prompts";
import {
Expand Down Expand Up @@ -188,6 +189,10 @@ const prompts__chat = {
SystemMessagePromptTemplate
};
export { prompts__chat };
const prompts__image = {
ImagePromptTemplate
};
export { prompts__image };
const prompts__pipeline = {
PipelinePromptTemplate
};
Expand Down
1 change: 1 addition & 0 deletions langchain/src/load/tests/data/important_imports.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"langchain/prompts/chat/ChatPromptTemplate": "langchain_core/prompts/chat/ChatPromptTemplate",
"langchain/prompts/chat/HumanMessagePromptTemplate": "langchain_core/prompts/chat/HumanMessagePromptTemplate",
"langchain/prompts/chat/SystemMessagePromptTemplate": "langchain_core/prompts/chat/SystemMessagePromptTemplate",
"langchain/prompts/image/ImagePromptTemplate": "langchain_core/prompts/image/ImagePromptTemplate",
"langchain/schema/agent/AgentActionMessageLog": "langchain_core/agents/AgentActionMessageLog",
"langchain/schema/agent/OpenAIToolAgentAction": "langchain/agents/output_parsers/openai_tools/OpenAIToolAgentAction",
"langchain/prompts/chat/BaseMessagePromptTemplate": "langchain_core/prompts/chat/BaseMessagePromptTemplate",
Expand Down
12 changes: 12 additions & 0 deletions langchain/src/retrievers/tests/vectorstores.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ test("Test Memory Retriever with Callback", async () => {
const queryStr = "testing testing";
let startRun = 0;
let endRun = 0;
let startPromiseResolve: (v?: unknown) => void;
const startPromise = new Promise((resolve) => {
startPromiseResolve = resolve;
});
let endPromiseResolve: (v?: unknown) => void;
const endPromise = new Promise((resolve) => {
endPromiseResolve = resolve;
});

const retriever = vectorStore.asRetriever({
k: 1,
Expand All @@ -29,10 +37,12 @@ test("Test Memory Retriever with Callback", async () => {
handleRetrieverStart: async (_, query) => {
expect(query).toBe(queryStr);
startRun += 1;
startPromiseResolve();
},
handleRetrieverEnd: async (documents) => {
expect(documents[0].pageContent).toBe(pageContent);
endRun += 1;
endPromiseResolve();
},
},
],
Expand All @@ -41,6 +51,8 @@ test("Test Memory Retriever with Callback", async () => {
const results = await retriever.getRelevantDocuments(queryStr);

expect(results).toEqual([new Document({ metadata: { a: 1 }, pageContent })]);
await startPromise;
await endPromise;
expect(startRun).toBe(1);
expect(endRun).toBe(1);
});
Loading

0 comments on commit 8c676db

Please sign in to comment.