Langchain + convex action
While langchain's
and the error is
any insights?
pdf-loader
works with use node
directive, my following code won't work in both js and node env.
import { v } from "convex/values"
import { ChatOpenAI } from "langchain/chat_models/openai"
import { HumanChatMessage } from "langchain/dist/schema"
import { action } from "./_generated/server"
export const extract = action({
args: {
report: v.id("reports"),
},
handler: async ({ runMutation, runQuery }, { report }) => {
const docs = "..."
const chat = new ChatOpenAI({ temperature: 0 })
const response = await chat.call([
new HumanChatMessage(`Translate the doc: ${docs}`),
])
runMutation("reports:patch", { id: report, insights: [response.text] })
},
})
import { v } from "convex/values"
import { ChatOpenAI } from "langchain/chat_models/openai"
import { HumanChatMessage } from "langchain/dist/schema"
import { action } from "./_generated/server"
export const extract = action({
args: {
report: v.id("reports"),
},
handler: async ({ runMutation, runQuery }, { report }) => {
const docs = "..."
const chat = new ChatOpenAI({ temperature: 0 })
const response = await chat.call([
new HumanChatMessage(`Translate the doc: ${docs}`),
])
runMutation("reports:patch", { id: report, insights: [response.text] })
},
})
✖ Error: Unable to bundle Convex modules
esbuild failed: Error: Build failed with 1 error:
convex/insights.ts:3:33: ERROR: Could not resolve "langchain/dist/schema"
✘ [ERROR] Could not resolve "langchain/dist/schema"
convex/insights.ts:3:33:
3 │ ... from "langchain/dist/schema"
╵ ~~~~~~~~~~~~~~~~~~~~~~~
The path "./dist/schema" is not exported
by package "langchain":
node_modules/langchain/package.json:598:13:
598 │ "exports": {
╵ ^
You can mark the path
"langchain/dist/schema" as external to
exclude it from the bundle, which will
remove this error.
✖ Error: Unable to bundle Convex modules
esbuild failed: Error: Build failed with 1 error:
convex/insights.ts:3:33: ERROR: Could not resolve "langchain/dist/schema"
✖ Error: Unable to bundle Convex modules
esbuild failed: Error: Build failed with 1 error:
convex/insights.ts:3:33: ERROR: Could not resolve "langchain/dist/schema"
✘ [ERROR] Could not resolve "langchain/dist/schema"
convex/insights.ts:3:33:
3 │ ... from "langchain/dist/schema"
╵ ~~~~~~~~~~~~~~~~~~~~~~~
The path "./dist/schema" is not exported
by package "langchain":
node_modules/langchain/package.json:598:13:
598 │ "exports": {
╵ ^
You can mark the path
"langchain/dist/schema" as external to
exclude it from the bundle, which will
remove this error.
✖ Error: Unable to bundle Convex modules
esbuild failed: Error: Build failed with 1 error:
convex/insights.ts:3:33: ERROR: Could not resolve "langchain/dist/schema"
1 Reply
mentioned in other thread, I think
langchain/dist/schema
the wrong import path?