langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.73k stars 2.19k forks source link

Cannot pass document by retriever and throws "text.replace is not a function" error #6912

Closed lynicis closed 1 week ago

lynicis commented 1 month ago

Checked other resources

Example Code

const serializeDocuments = (documents: Array<Document>) =>
        documents.map((document) => JSON.stringify(document)).toString();

const chain = RunnableSequence.from([
    RunnableLambda.from((input: { foo: string; bar: string }) => input),
    {
        context: retriever.pipe(serializeDocuments),
        foo: new RunnablePassthrough(),
        bar: new RunnablePassthrough(),
    },
    prompt,
    this.llm,
]);

const output = await chain.invoke({ foo, bar });

Error Message and Stack Trace (if applicable)

TypeError: text.replace is not a function at OpenAIEmbeddings.embedQuery at PineconeStore.similaritySearch at VectorStoreRetriever.getRelevantDocuments

Description

I send the document pageContent and metadata with some inputs to the prompt but it throws error: text.replace is not a function

I've tried different ways to send the document and other fields but they don't work either, I've also looked for other issues similar to my case but they don't work for me.

System Info

yarn info v1.22.22 { name: 'langchain', 'dist-tags': { next: '0.3.2-rc.0', latest: '0.3.2', 'tag-for-publishing-older-releases': '0.2.20' }, versions: [ '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.0.10', '0.0.11', '0.0.12', '0.0.13', '0.0.14', '0.0.15', '0.0.16', '0.0.17', '0.0.18', '0.0.19', '0.0.20', '0.0.21', '0.0.22', '0.0.23', '0.0.24', '0.0.25', '0.0.26', '0.0.27', '0.0.28', '0.0.29', '0.0.30', '0.0.31', '0.0.32', '0.0.33', '0.0.34', '0.0.35', '0.0.36', '0.0.37', '0.0.38', '0.0.39', '0.0.40', '0.0.41', '0.0.42', '0.0.43', '0.0.44', '0.0.45', '0.0.46', '0.0.47', '0.0.48', '0.0.49-0', '0.0.49-1', '0.0.49', '0.0.50', '0.0.51', '0.0.52-0', '0.0.52', '0.0.53', '0.0.54', '0.0.55', '0.0.56', '0.0.57', '0.0.58', '0.0.59', '0.0.60', '0.0.61', '0.0.62', '0.0.63', '0.0.64', '0.0.65', '0.0.66', '0.0.67', '0.0.68', '0.0.69', '0.0.70', '0.0.71', '0.0.72', '0.0.73', '0.0.74', '0.0.75', '0.0.76', '0.0.77', '0.0.78', '0.0.79', '0.0.80', '0.0.81', '0.0.82', '0.0.83', '0.0.84', '0.0.85', '0.0.86', '0.0.87', '0.0.88', '0.0.89', '0.0.90', '0.0.91', '0.0.92', '0.0.93', '0.0.94', '0.0.95', '0.0.96', '0.0.97', '0.0.98', '0.0.99', '0.0.100', '0.0.101', '0.0.102', '0.0.103', '0.0.104', '0.0.105', '0.0.106', '0.0.107', '0.0.108', '0.0.109', '0.0.110', '0.0.111', '0.0.112', '0.0.113', '0.0.114', '0.0.115', '0.0.116', '0.0.117', '0.0.118', '0.0.119', '0.0.120', '0.0.121', '0.0.122', '0.0.123', '0.0.124', '0.0.125', '0.0.126', '0.0.127', '0.0.128', '0.0.129', '0.0.130', '0.0.131', '0.0.132', '0.0.133', '0.0.134', '0.0.135', '0.0.136', '0.0.137', '0.0.138', '0.0.139', '0.0.140', '0.0.141', '0.0.142', '0.0.143', '0.0.144', '0.0.145', '0.0.146', '0.0.147', '0.0.148', '0.0.149', '0.0.150', '0.0.151', '0.0.152', '0.0.153', '0.0.154', '0.0.155', '0.0.156', '0.0.157', '0.0.158', '0.0.159', '0.0.160', '0.0.161', '0.0.162', '0.0.163', '0.0.164', '0.0.165', '0.0.166', '0.0.167', '0.0.168', '0.0.169', '0.0.170', '0.0.171', '0.0.172', '0.0.173', '0.0.174', '0.0.175', '0.0.176', '0.0.177', '0.0.178', '0.0.179', '0.0.180', '0.0.181', '0.0.182-rc.0', '0.0.182-rc.1', '0.0.182', '0.0.183', '0.0.184', '0.0.185', '0.0.186', '0.0.187', '0.0.188', '0.0.189', '0.0.190', '0.0.191', '0.0.192', '0.0.193', '0.0.194', '0.0.195', '0.0.196', '0.0.197-rc.0', '0.0.197-rc.1', '0.0.197', '0.0.198', '0.0.199', '0.0.200', '0.0.201', '0.0.202', '0.0.203', '0.0.204-rc.0', '0.0.204-rc.1', '0.0.204-rc.2', '0.0.204', '0.0.205', '0.0.206', '0.0.207', '0.0.208', '0.0.209-rc.0', '0.0.209', '0.0.210', '0.0.211', '0.0.212', '0.0.213', '0.0.214', '0.1.0-rc.0', '0.1.0-rc.1', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9-rc.0', '0.1.9', '0.1.10', '0.1.11', '0.1.12', '0.1.13', '0.1.14', '0.1.15', '0.1.16-rc.0', '0.1.16', '0.1.17', '0.1.18', '0.1.19-rc.0', '0.1.19-rc.1', '0.1.19-rc.2', '0.1.19', '0.1.20', '0.1.21', '0.1.22', '0.1.23', '0.1.24', '0.1.25', '0.1.26', '0.1.27', '0.1.28', '0.1.29-rc.0', '0.1.29', '0.1.30', '0.1.31', '0.1.32', '0.1.33', '0.1.34', '0.1.35', '0.1.36', '0.1.37', '0.2.0-rc.0', '0.2.0-rc.1', '0.2.0', '0.2.1', '0.2.2', '0.2.3-rc.0', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.2.10', '0.2.11', '0.2.12', '0.2.13', '0.2.14', '0.2.15', '0.2.16', '0.2.17', '0.2.18', '0.2.19', '0.2.20', '0.3.0-rc.0', '0.3.0', '0.3.1', '0.3.2-rc.0', '0.3.2' ], time: { created: '2023-02-14T18:06:57.074Z', modified: '2024-09-15T06:29:13.702Z', '1.0.0': '2023-01-20T03:45:29.634Z', '1.0.9': '2023-01-22T02:02:57.467Z', '0.0.1': '2023-01-26T21:22:58.657Z', '0.0.4': '2023-02-14T18:06:57.434Z', '0.0.5': '2023-02-17T05:51:37.227Z', '0.0.6': '2023-02-17T08:53:32.946Z', '0.0.7': '2023-02-18T00:31:00.386Z', '0.0.8': '2023-02-20T04:56:45.683Z', '0.0.9': '2023-02-21T07:17:14.208Z', '0.0.10': '2023-02-22T18:48:35.631Z', '0.0.11': '2023-02-23T16:12:41.455Z', '0.0.12': '2023-02-26T18:49:26.071Z', '0.0.13': '2023-02-27T16:03:50.432Z', '0.0.14': '2023-02-27T16:59:17.082Z', '0.0.15': '2023-02-27T17:59:53.741Z', '0.0.16': '2023-02-28T16:41:21.705Z', '0.0.17': '2023-03-01T15:28:09.338Z', '0.0.18': '2023-03-01T20:00:24.554Z', '0.0.19': '2023-03-01T20:58:49.811Z', '0.0.20': '2023-03-02T17:11:30.882Z', '0.0.21': '2023-03-03T19:23:04.354Z', '0.0.22': '2023-03-04T16:00:04.873Z', '0.0.23': '2023-03-06T16:42:44.996Z', '0.0.24': '2023-03-07T18:10:28.933Z', '0.0.25': '2023-03-08T17:42:24.706Z', '0.0.26': '2023-03-09T19:36:23.799Z', '0.0.27': '2023-03-10T16:24:31.279Z', '0.0.28': '2023-03-11T19:41:29.182Z', '0.0.29': '2023-03-12T07:41:25.588Z', '0.0.30': '2023-03-13T19:27:19.085Z', '0.0.31': '2023-03-13T22:48:33.902Z', '0.0.32': '2023-03-14T08:48:30.479Z', '0.0.33': '2023-03-14T18:36:54.970Z', '0.0.34': '2023-03-15T18:20:43.233Z', '0.0.35': '2023-03-15T18:59:13.048Z', '0.0.36': '2023-03-17T18:55:33.715Z', '0.0.37': '2023-03-20T20:10:36.444Z', '0.0.38': '2023-03-21T18:31:14.819Z', '0.0.39': '2023-03-22T15:47:46.529Z', '0.0.40': '2023-03-24T15:13:53.947Z', '0.0.41': '2023-03-24T19:33:29.565Z', '0.0.42': '2023-03-27T18:47:07.410Z', '0.0.43': '2023-03-28T18:43:21.068Z', '0.0.44': '2023-03-29T18:45:08.636Z', '0.0.45': '2023-03-31T15:55:26.705Z', '0.0.46': '2023-04-03T15:46:07.061Z', '0.0.47': '2023-04-03T15:55:06.384Z', '0.0.48': '2023-04-04T17:25:41.531Z', '0.0.49-0': '2023-04-05T12:56:44.659Z', '0.0.49-1': '2023-04-05T13:07:31.197Z', '0.0.49': '2023-04-06T10:31:23.786Z', '0.0.50': '2023-04-07T21:46:20.961Z', '0.0.51': '2023-04-08T17:07:19.121Z', '0.0.52-0': '2023-04-09T17:48:55.378Z', '0.0.52': '2023-04-10T18:57:02.678Z', '0.0.53': '2023-04-11T15:51:36.258Z', '0.0.54': '2023-04-12T16:59:09.975Z', '0.0.55': '2023-04-13T16:22:58.352Z', '0.0.56': '2023-04-14T17:47:49.152Z', '0.0.57': '2023-04-17T17:01:13.362Z', '0.0.58': '2023-04-18T18:51:48.339Z', '0.0.59': '2023-04-18T20:23:09.912Z', '0.0.60': '2023-04-21T18:45:14.498Z', '0.0.61': '2023-04-21T20:58:46.669Z', '0.0.62': '2023-04-22T20:27:37.499Z', '0.0.63': '2023-04-23T15:27:57.932Z', '0.0.64': '2023-04-25T15:58:01.314Z', '0.0.65': '2023-04-28T11:29:13.611Z', '0.0.66': '2023-04-28T12:48:12.798Z', '0.0.67': '2023-05-01T14:55:22.206Z', '0.0.68': '2023-05-02T19:51:47.329Z', '0.0.69': '2023-05-04T17:35:32.223Z', '0.0.70': '2023-05-05T16:40:01.904Z', '0.0.71': '2023-05-06T15:19:04.361Z', '0.0.72': '2023-05-08T07:03:31.569Z', '0.0.73': '2023-05-09T18:50:58.586Z', '0.0.74': '2023-05-10T15:50:49.597Z', '0.0.75': '2023-05-11T18:54:42.166Z', '0.0.76': '2023-05-17T19:35:53.355Z', '0.0.77': '2023-05-18T15:25:50.965Z', '0.0.78': '2023-05-19T15:18:20.002Z', '0.0.79': '2023-05-23T16:30:38.510Z', '0.0.80': '2023-05-23T18:18:28.751Z', '0.0.81': '2023-05-23T18:57:35.910Z', '0.0.82': '2023-05-25T00:15:56.768Z', '0.0.83': '2023-05-25T16:48:27.312Z', '0.0.84': '2023-05-26T20:43:14.443Z', '0.0.85': '2023-05-30T19:31:33.866Z', '0.0.86': '2023-05-30T23:26:55.520Z', '0.0.87': '2023-05-31T15:23:33.608Z', '0.0.88': '2023-06-01T02:10:23.366Z', '0.0.89': '2023-06-02T16:10:24.873Z', '0.0.90': '2023-06-03T01:29:12.535Z', '0.0.91': '2023-06-04T23:00:33.336Z', '0.0.92': '2023-06-07T20:40:58.171Z', '0.0.93': '2023-06-13T17:32:25.870Z', '0.0.94': '2023-06-13T21:41:36.359Z', '0.0.95': '2023-06-14T14:25:53.017Z', '0.0.96': '2023-06-19T18:24:31.016Z', '0.0.97': '2023-06-26T20:08:09.043Z', '0.0.98': '2023-06-28T05:15:53.569Z', '0.0.99': '2023-06-29T10:00:34.210Z', '0.0.100': '2023-06-29T16:19:24.235Z', '0.0.101': '2023-06-30T19:51:23.760Z', '0.0.102': '2023-07-01T19:12:19.594Z', '0.0.103': '2023-07-05T23:21:04.630Z', '0.0.104': '2023-07-07T01:35:39.991Z', '0.0.105': '2023-07-09T00:55:47.724Z', '0.0.106': '2023-07-10T17:32:39.936Z', '0.0.107': '2023-07-12T06:09:52.155Z', '0.0.108': '2023-07-13T02:24:55.332Z', '0.0.109': '2023-07-14T01:37:31.791Z', '0.0.110': '2023-07-15T17:39:11.281Z', '0.0.111': '2023-07-18T04:22:39.858Z', '0.0.112': '2023-07-18T18:22:02.588Z', '0.0.113': '2023-07-19T23:56:22.261Z', '0.0.114': '2023-07-21T03:00:26.247Z', '0.0.115': '2023-07-24T01:01:00.307Z', '0.0.116': '2023-07-24T05:19:14.838Z', '0.0.117': '2023-07-25T00:26:59.388Z', '0.0.118': '2023-07-26T16:09:04.672Z', '0.0.119': '2023-07-28T22:08:02.687Z', '0.0.120': '2023-07-30T17:08:46.417Z', '0.0.121': '2023-08-01T21:15:07.740Z', '0.0.122': '2023-08-03T03:25:11.530Z', '0.0.123': '2023-08-05T06:09:18.474Z', '0.0.124': '2023-08-07T05:38:39.271Z', '0.0.125': '2023-08-09T03:48:44.885Z', '0.0.126': '2023-08-11T01:19:19.011Z', '0.0.127': '2023-08-12T01:03:28.743Z', '0.0.128': '2023-08-15T06:55:07.574Z', '0.0.129': '2023-08-16T02:39:45.923Z', '0.0.130': '2023-08-18T01:17:54.954Z', '0.0.131': '2023-08-19T00:48:09.017Z', '0.0.132': '2023-08-21T23:24:17.628Z', '0.0.133': '2023-08-24T02:13:40.841Z', '0.0.134': '2023-08-25T04:45:19.565Z', '0.0.135': '2023-08-26T00:44:11.083Z', '0.0.136': '2023-08-29T01:36:44.900Z', '0.0.137': '2023-08-30T01:34:15.475Z', '0.0.138': '2023-08-31T02:22:36.630Z', '0.0.139': '2023-09-01T07:20:17.993Z', '0.0.140': '2023-09-02T00:37:02.261Z', '0.0.141': '2023-09-03T07:34:21.546Z', '0.0.142': '2023-09-04T20:15:53.914Z', '0.0.143': '2023-09-05T14:41:59.202Z', '0.0.144': '2023-09-06T01:21:44.338Z', '0.0.145': '2023-09-07T01:35:35.892Z', '0.0.146': '2023-09-08T15:27:22.355Z', '0.0.147': '2023-09-12T06:22:04.926Z', '0.0.148': '2023-09-13T03:03:39.760Z', '0.0.149': '2023-09-14T01:40:17.567Z', '0.0.150': '2023-09-15T06:28:14.560Z', '0.0.151': '2023-09-19T03:53:15.800Z', '0.0.152': '2023-09-20T00:08:57.506Z', '0.0.153': '2023-09-21T03:10:39.410Z', '0.0.154': '2023-09-26T01:47:45.016Z', '0.0.155': '2023-09-28T01:35:14.504Z', '0.0.156': '2023-09-29T05:55:44.312Z', '0.0.157': '2023-10-02T01:10:49.355Z', '0.0.158': '2023-10-03T16:33:07.960Z', '0.0.159': '2023-10-04T05:07:58.638Z', '0.0.160': '2023-10-04T22:07:49.157Z', '0.0.161': '2023-10-06T02:07:05.756Z', '0.0.162': '2023-10-07T01:37:20.312Z', '0.0.163': '2023-10-08T01:32:36.536Z', '0.0.164': '2023-10-10T01:43:32.276Z', '0.0.165': '2023-10-10T20:57:49.443Z', '0.0.166': '2023-10-12T01:40:20.109Z', '0.0.167': '2023-10-14T00:32:54.607Z', '0.0.168': '2023-10-18T02:53:34.953Z', '0.0.169': '2023-10-19T06:32:45.493Z', '0.0.170': '2023-10-20T22:38:06.659Z', '0.0.171': '2023-10-24T00:17:00.928Z', '0.0.172': '2023-10-24T20:19:09.813Z', '0.0.173': '2023-10-26T00:58:15.045Z', '0.0.174': '2023-10-26T23:11:53.499Z', '0.0.175': '2023-10-28T17:04:03.349Z', '0.0.176': '2023-10-31T00:57:13.953Z', '0.0.177': '2023-11-01T00:20:00.276Z', '0.0.178': '2023-11-01T22:33:03.571Z', '0.0.179': '2023-11-03T05:49:56.666Z', '0.0.180': '2023-11-03T22:15:10.842Z', '0.0.181': '2023-11-06T09:59:26.380Z', '0.0.182-rc.0': '2023-11-06T22:23:48.947Z', '0.0.182-rc.1': '2023-11-07T03:41:06.816Z', '0.0.182': '2023-11-08T04:04:31.241Z', '0.0.183': '2023-11-08T05:25:05.808Z', '0.0.184': '2023-11-08T23:56:28.690Z', '0.0.185': '2023-11-10T02:35:22.582Z', '0.0.186': '2023-11-11T02:24:26.776Z', '0.0.187': '2023-11-14T04:35:18.096Z', '0.0.188': '2023-11-15T05:34:58.759Z', '0.0.189': '2023-11-15T06:30:57.181Z', '0.0.190': '2023-11-16T15:23:59.223Z', '0.0.191': '2023-11-16T16:31:07.507Z', '0.0.192': '2023-11-17T02:06:54.439Z', '0.0.193': '2023-11-19T11:06:54.623Z', '0.0.194': '2023-11-20T02:15:31.205Z', '0.0.195': '2023-11-20T20:25:34.666Z', '0.0.196': '2023-11-22T02:19:47.812Z', '0.0.197-rc.0': '2023-11-22T22:16:48.971Z', '0.0.197-rc.1': '2023-11-23T05:27:13.906Z', '0.0.197': '2023-11-27T17:42:53.476Z', '0.0.198': '2023-11-28T02:22:55.183Z', '0.0.199': '2023-12-01T01:28:26.144Z', '0.0.200': '2023-12-02T04:43:25.313Z', '0.0.201': '2023-12-05T04:22:22.540Z', '0.0.202': '2023-12-06T01:34:55.388Z', '0.0.203': '2023-12-07T06:15:39.619Z', '0.0.204-rc.0': '2023-12-08T02:34:03.010Z', '0.0.204-rc.1': '2023-12-09T03:54:40.336Z', '0.0.204-rc.2': '2023-12-11T20:15:35.207Z', '0.0.204': '2023-12-11T22:28:49.455Z', '0.0.205': '2023-12-12T18:27:07.427Z', '0.0.206': '2023-12-13T04:51:42.993Z', '0.0.207': '2023-12-14T03:34:38.535Z', '0.0.208': '2023-12-15T10:05:40.181Z', '0.0.209-rc.0': '2023-12-17T03:47:20.439Z', '0.0.209': '2023-12-17T06:10:40.303Z', '0.0.210': '2023-12-20T02:53:42.769Z', '0.0.211': '2023-12-21T07:29:16.193Z', '0.0.212': '2023-12-23T01:22:18.040Z', '0.0.213': '2023-12-29T15:33:05.323Z', '0.0.214': '2024-01-03T03:24:13.994Z', '0.1.0-rc.0': '2024-01-05T22:33:51.804Z', '0.1.0-rc.1': '2024-01-06T03:41:30.131Z', '0.1.0': '2024-01-06T03:58:20.185Z', '0.1.1': '2024-01-08T00:25:32.620Z', '0.1.2': '2024-01-09T22:35:21.328Z', '0.1.3': '2024-01-15T17:18:03.822Z', '0.1.4': '2024-01-18T05:58:46.640Z', '0.1.5': '2024-01-21T17:57:55.335Z', '0.1.6': '2024-01-24T07:58:31.013Z', '0.1.7': '2024-01-25T07:27:13.252Z', '0.1.8': '2024-01-27T01:11:52.718Z', '0.1.9-rc.0': '2024-01-27T06:14:56.103Z', '0.1.9': '2024-01-27T06:25:12.844Z', '0.1.10': '2024-01-30T09:54:07.013Z', '0.1.11': '2024-01-31T03:31:39.843Z', '0.1.12': '2024-02-01T23:57:54.094Z', '0.1.13': '2024-02-05T03:24:29.383Z', '0.1.14': '2024-02-07T01:03:54.355Z', '0.1.15': '2024-02-07T19:22:37.134Z', '0.1.16-rc.0': '2024-02-07T23:34:28.951Z', '0.1.16': '2024-02-07T23:45:35.740Z', '0.1.17': '2024-02-08T23:22:04.844Z', '0.1.18': '2024-02-13T23:15:14.011Z', '0.1.19-rc.0': '2024-02-14T23:59:15.835Z', '0.1.19-rc.1': '2024-02-16T00:20:22.801Z', '0.1.19': '2024-02-16T04:48:07.787Z', '0.1.19-rc.2': '2024-02-16T18:47:07.688Z', '0.1.20': '2024-02-16T22:03:07.378Z', '0.1.21': '2024-02-21T22:48:04.422Z', '0.1.22': '2024-02-26T20:27:53.383Z', '0.1.23': '2024-02-27T04:07:47.477Z', '0.1.24': '2024-02-29T00:52:15.516Z', '0.1.25': '2024-03-01T18:49:55.617Z', '0.1.26': '2024-03-10T01:36:01.782Z', '0.1.27': '2024-03-13T01:01:08.908Z', '0.1.28': '2024-03-15T00:06:05.523Z', '0.1.29-rc.0': '2024-03-15T03:31:14.345Z', '0.1.29': '2024-03-25T04:19:39.067Z', '0.1.30': '2024-03-26T06:27:42.909Z', '0.1.31': '2024-04-04T08:23:54.517Z', '0.1.32': '2024-04-09T01:22:19.683Z', '0.1.33': '2024-04-11T09:30:55.275Z', '0.1.34': '2024-04-18T03:01:59.519Z', '0.1.35': '2024-04-22T23:30:56.916Z', '0.1.36': '2024-04-24T21:36:22.008Z', '0.2.0-rc.0': '2024-04-26T23:56:59.053Z', '0.2.0-rc.1': '2024-05-02T22:00:18.752Z', '0.1.37': '2024-05-10T21:40:01.263Z', '0.2.0': '2024-05-17T21:03:13.753Z', '0.2.1': '2024-05-22T17:32:07.344Z', '0.2.2': '2024-05-23T23:12:00.768Z', '0.2.3-rc.0': '2024-05-28T21:17:33.560Z', '0.2.3': '2024-05-29T01:15:36.521Z', '0.2.4': '2024-05-31T04:14:35.289Z', '0.2.5': '2024-06-04T22:19:23.685Z', '0.2.6': '2024-06-21T23:52:24.414Z', '0.2.7': '2024-06-25T19:24:56.599Z', '0.2.8': '2024-06-28T01:05:43.266Z', '0.2.9': '2024-07-10T01:19:00.661Z', '0.2.10': '2024-07-16T04:39:54.756Z', '0.2.11': '2024-07-24T23:01:59.481Z', '0.2.12': '2024-07-30T16:59:27.878Z', '0.2.13': '2024-08-06T23:34:44.938Z', '0.2.14': '2024-08-09T19:52:51.258Z', '0.2.15': '2024-08-10T15:14:36.266Z', '0.2.16': '2024-08-13T11:41:17.160Z', '0.2.17': '2024-08-23T01:13:12.015Z', '0.2.18': '2024-09-04T22:45:35.518Z', '0.3.0-rc.0': '2024-09-07T00:10:44.310Z', '0.2.19': '2024-09-11T23:34:20.084Z', '0.3.0': '2024-09-13T21:43:36.208Z', '0.3.1': '2024-09-15T05:37:11.723Z', '0.3.2-rc.0': '2024-09-15T05:53:56.512Z', '0.3.2': '2024-09-15T06:16:32.327Z', '0.2.20': '2024-09-15T06:29:13.500Z' }, bugs: { url: 'https://github.com/langchain-ai/langchainjs/issues' }, author: { name: 'LangChain' }, license: 'MIT', homepage: 'https://github.com/langchain-ai/langchainjs/tree/main/langchain/', keywords: [ 'llm', 'ai', 'gpt3', 'chain', 'prompt', 'prompt engineering', 'chatgpt', 'machine learning', 'ml', 'openai', 'embeddings', 'vectorstores' ], repository: { url: 'git+ssh://git@github.com/langchain-ai/langchainjs.git', type: 'git' }, description: 'Typescript bindings for langchain', maintainers: [ { name: 'nfcampos', email: 'nuno@boringbits.io' }, { name: 'jacoblee93', email: 'jacoblee93@gmail.com' }, { name: 'andrewnguonly', email: 'andrewnguonly@gmail.com' }, { name: 'davidduong', email: 'david@duong.cz' }, { name: 'hwchase17', email: 'hw.chase.17@gmail.com' }, { name: 'basproul', email: 'braceasproul@gmail.com' } ], version: '0.3.2', dist: { shasum: 'aec3e679d3d6c36f469448380affa475c92fbd86', tarball: 'https://registry.npmjs.org/langchain/-/langchain-0.3.2.tgz', fileCount: 1339, integrity: 'sha512-kd2kz1cS/PIVrLEDFlrZsAasQfPLbY1UqCZbRKa3/QcpB33/n6xPDvXSMfBuKhvNj0bjW6MXDR9HZTduXjJBgg==', signatures: [ { sig: 'MEUCIHLidb//Cq/8rhG52q76O8Ne2CWgSkBMY7fVX8J1evQtAiEAilcggr9RYOKstN2XFeUwbtNWEgcbfkwj59XdsSGZg7g=', keyid: 'SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA' } ], unpackedSize: 2865397 }, main: './index.js', type: 'module', types: './index.d.ts', engines: { node: '>=18' }, exports: { './hub': { types: { import: './hub.d.ts', default: './hub.d.ts', require: './hub.d.cts' }, import: './hub.js', require: './hub.cjs' }, './load': { types: { import: './load.d.ts', default: './load.d.ts', require: './load.d.cts' }, import: './load.js', require: './load.cjs' }, './smith': { types: { import: './smith.d.ts', default: './smith.d.ts', require: './smith.d.cts' }, import: './smith.js', require: './smith.cjs' }, './tools': { types: { import: './tools.d.ts', default: './tools.d.ts', require: './tools.d.cts' }, import: './tools.js', require: './tools.cjs' }, './agents': { types: { import: './agents.d.ts', default: './agents.d.ts', require: './agents.d.cts' }, import: './agents.js', require: './agents.cjs' }, './chains': { types: { import: './chains.d.ts', default: './chains.d.ts', require: './chains.d.cts' }, import: './chains.js', require: './chains.cjs' }, './memory': { types: { import: './memory.d.ts', default: './memory.d.ts', require: './memory.d.cts' }, import: './memory.js', require: './memory.cjs' }, './sql_db': { types: { import: './sql_db.d.ts', default: './sql_db.d.ts', require: './sql_db.d.cts' }, import: './sql_db.js', require: './sql_db.cjs' }, './indexes': { types: { import: './indexes.d.ts', default: './indexes.d.ts', require: './indexes.d.cts' }, import: './indexes.js', require: './indexes.cjs' }, './document': { types: { import: './document.d.ts', default: './document.d.ts', require: './document.d.cts' }, import: './document.js', require: './document.cjs' }, './callbacks': { types: { import: './callbacks.d.ts', default: './callbacks.d.ts', require: './callbacks.d.cts' }, import: './callbacks.js', require: './callbacks.cjs' }, './tools/sql': { types: { import: './tools/sql.d.ts', default: './tools/sql.d.ts', require: './tools/sql.d.cts' }, import: './tools/sql.js', require: './tools/sql.cjs' }, './util/math': { types: { import: './util/math.d.ts', default: './util/math.d.ts', require: './util/math.d.cts' }, import: './util/math.js', require: './util/math.cjs' }, './util/time': { types: { import: './util/time.d.ts', default: './util/time.d.ts', require: './util/time.d.cts' }, import: './util/time.js', require: './util/time.cjs' }, './evaluation': { types: { import: './evaluation.d.ts', default: './evaluation.d.ts', require: './evaluation.d.cts' }, import: './evaluation.js', require: './evaluation.cjs' }, './agents/load': { types: { import: './agents/load.d.ts', default: './agents/load.d.ts', require: './agents/load.d.cts' }, import: './agents/load.js', require: './agents/load.cjs' }, './chains/load': { types: { import: './chains/load.d.ts', default: './chains/load.d.ts', require: './chains/load.d.cts' }, import: './chains/load.js', require: './chains/load.cjs' }, './tools/chain': { types: { import: './tools/chain.d.ts', default: './tools/chain.d.ts', require: './tools/chain.d.cts' }, import: './tools/chain.js', require: './tools/chain.cjs' }, './package.json': './package.json', './tools/render': { types: { import: './tools/render.d.ts', default: './tools/render.d.ts', require: './tools/render.d.cts' }, import: './tools/render.js', require: './tools/render.cjs' }, './chains/sql_db': { types: { import: './chains/sql_db.d.ts', default: './chains/sql_db.d.ts', require: './chains/sql_db.d.cts' }, import: './chains/sql_db.js', require: './chains/sql_db.cjs' }, './text_splitter': { types: { import: './text_splitter.d.ts', default: './text_splitter.d.ts', require: './text_splitter.d.cts' }, import: './text_splitter.js', require: './text_splitter.cjs' }, './util/document': { types: { import: './util/document.d.ts', default: './util/document.d.ts', require: './util/document.d.cts' }, import: './util/document.js', require: './util/document.cjs' }, './output_parsers': { types: { import: './output_parsers.d.ts', default: './output_parsers.d.ts', require: './output_parsers.d.cts' }, import: './output_parsers.js', require: './output_parsers.cjs' }, './agents/toolkits': { types: { import: './agents/toolkits.d.ts', default: './agents/toolkits.d.ts', require: './agents/toolkits.d.cts' }, import: './agents/toolkits.js', require: './agents/toolkits.cjs' }, './embeddings/fake': { types: { import: './embeddings/fake.d.ts', default: './embeddings/fake.d.ts', require: './embeddings/fake.d.cts' }, import: './embeddings/fake.js', require: './embeddings/fake.cjs' }, './retrievers/hyde': { types: { import: './retrievers/hyde.d.ts', default: './retrievers/hyde.d.ts', require: './retrievers/hyde.d.cts' }, import: './retrievers/hyde.js', require: './retrievers/hyde.cjs' }, './stores/doc/base': { types: { import: './stores/doc/base.d.ts', default: './stores/doc/base.d.ts', require: './stores/doc/base.d.cts' }, import: './stores/doc/base.js', require: './stores/doc/base.cjs' }, './tools/retriever': { types: { import: './tools/retriever.d.ts', default: './tools/retriever.d.ts', require: './tools/retriever.d.cts' }, import: './tools/retriever.js', require: './tools/retriever.cjs' }, './chains/retrieval': { types: { import: './chains/retrieval.d.ts', default: './chains/retrieval.d.ts', require: './chains/retrieval.d.cts' }, import: './chains/retrieval.js', require: './chains/retrieval.cjs' }, './runnables/remote': { types: { import: './runnables/remote.d.ts', default: './runnables/remote.d.ts', require: './runnables/remote.d.cts' }, import: './runnables/remote.js', require: './runnables/remote.cjs' }, './stores/file/node': { types: { import: './stores/file/node.d.ts', default: './stores/file/node.d.ts', require: './stores/file/node.d.cts' }, import: './stores/file/node.js', require: './stores/file/node.cjs' }, './tools/webbrowser': { types: { import: './tools/webbrowser.d.ts', default: './tools/webbrowser.d.ts', require: './tools/webbrowser.d.cts' }, import: './tools/webbrowser.js', require: './tools/webbrowser.cjs' }, './cache/file_system': { types: { import: './cache/file_system.d.ts', default: './cache/file_system.d.ts', require: './cache/file_system.d.cts' }, import: './cache/file_system.js', require: './cache/file_system.cjs' }, './load/serializable': { types: { import: './load/serializable.d.ts', default: './load/serializable.d.ts', require: './load/serializable.d.cts' }, import: './load/serializable.js', require: './load/serializable.cjs' }, './storage/in_memory': { types: { import: './storage/in_memory.d.ts', default: './storage/in_memory.d.ts', require: './storage/in_memory.d.cts' }, import: './storage/in_memory.js', require: './storage/in_memory.cjs' }, './memory/chat_memory': { types: { import: './memory/chat_memory.d.ts', default: './memory/chat_memory.d.ts', require: './memory/chat_memory.d.cts' }, import: './memory/chat_memory.js', require: './memory/chat_memory.cjs' }, './agents/toolkits/sql': { types: { import: './agents/toolkits/sql.d.ts', default: './agents/toolkits/sql.d.ts', require: './agents/toolkits/sql.d.cts' }, import: './agents/toolkits/sql.js', require: './agents/toolkits/sql.cjs' }, './retrievers/ensemble': { types: { import: './retrievers/ensemble.d.ts', default: './retrievers/ensemble.d.ts', require: './retrievers/ensemble.d.cts' }, import: './retrievers/ensemble.js', require: './retrievers/ensemble.cjs' }, './storage/file_system': { types: { import: './storage/file_system.d.ts', default: './storage/file_system.d.ts', require: './storage/file_system.d.cts' }, import: './storage/file_system.js', require: './storage/file_system.cjs' }, './vectorstores/memory': { types: { import: './vectorstores/memory.d.ts', default: './vectorstores/memory.d.ts', require: './vectorstores/memory.d.cts' }, import: './vectorstores/memory.js', require: './vectorstores/memory.cjs' }, './experimental/autogpt': { types: { import: './experimental/autogpt.d.ts', default: './experimental/autogpt.d.ts', require: './experimental/autogpt.d.cts' }, import: './experimental/autogpt.js', require: './experimental/autogpt.cjs' }, './experimental/babyagi': { types: { import: './experimental/babyagi.d.ts', default: './experimental/babyagi.d.ts', require: './experimental/babyagi.d.cts' }, import: './experimental/babyagi.js', require: './experimental/babyagi.cjs' }, './experimental/masking': { types: { import: './experimental/masking.d.ts', default: './experimental/masking.d.ts', require: './experimental/masking.d.cts' }, import: './experimental/masking.js', require: './experimental/masking.cjs' }, './stores/doc/in_memory': { types: { import: './stores/doc/in_memory.d.ts', default: './stores/doc/in_memory.d.ts', require: './stores/doc/in_memory.d.cts' }, import: './stores/doc/in_memory.js', require: './stores/doc/in_memory.cjs' }, './chat_models/universal': { types: { import: './chat_models/universal.d.ts', default: './chat_models/universal.d.ts', require: './chat_models/universal.d.cts' }, import: './chat_models/universal.js', require: './chat_models/universal.cjs' }, './document_loaders/base': { types: { import: './document_loaders/base.d.ts', default: './document_loaders/base.d.ts', require: './document_loaders/base.d.cts' }, import: './document_loaders/base.js', require: './document_loaders/base.cjs' }, './retrievers/self_query': { types: { import: './retrievers/self_query.d.ts', default: './retrievers/self_query.d.ts', require: './retrievers/self_query.d.cts' }, import: './retrievers/self_query.js', require: './retrievers/self_query.cjs' }, './stores/file/in_memory': { types: { import: './stores/file/in_memory.d.ts', default: './stores/file/in_memory.d.ts', require: './stores/file/in_memory.d.cts' }, import: './stores/file/in_memory.js', require: './stores/file/in_memory.cjs' }, './chains/graph_qa/cypher': { types: { import: './chains/graph_qa/cypher.d.ts', default: './chains/graph_qa/cypher.d.ts', require: './chains/graph_qa/cypher.d.cts' }, import: './chains/graph_qa/cypher.js', require: './chains/graph_qa/cypher.cjs' }, './retrievers/multi_query': { types: { import: './retrievers/multi_query.d.ts', default: './retrievers/multi_query.d.ts', require: './retrievers/multi_query.d.cts' }, import: './retrievers/multi_query.js', require: './retrievers/multi_query.cjs' }, './schema/prompt_template': { types: { import: './schema/prompt_template.d.ts', default: './schema/prompt_template.d.ts', require: './schema/prompt_template.d.cts' }, import: './schema/prompt_template.js', require: './schema/prompt_template.cjs' }, './storage/encoder_backed': { types: { import: './storage/encoder_backed.d.ts', default: './storage/encoder_backed.d.ts', require: './storage/encoder_backed.d.cts' }, import: './storage/encoder_backed.js', require: './storage/encoder_backed.cjs' }, './chains/openai_functions': { types: { import: './chains/openai_functions.d.ts', default: './chains/openai_functions.d.ts', require: './chains/openai_functions.d.cts' }, import: './chains/openai_functions.js', require: './chains/openai_functions.cjs' }, './embeddings/cache_backed': { types: { import: './embeddings/cache_backed.d.ts', default: './embeddings/cache_backed.d.ts', require: './embeddings/cache_backed.d.cts' }, import: './embeddings/cache_backed.js', require: './embeddings/cache_backed.cjs' }, './retrievers/multi_vector': { types: { import: './retrievers/multi_vector.d.ts', default: './retrievers/multi_vector.d.ts', require: './retrievers/multi_vector.d.cts' }, import: './retrievers/multi_vector.js', require: './retrievers/multi_vector.cjs' }, './agents/format_scratchpad': { types: { import: './agents/format_scratchpad.d.ts', default: './agents/format_scratchpad.d.ts', require: './agents/format_scratchpad.d.cts' }, import: './agents/format_scratchpad.js', require: './agents/format_scratchpad.cjs' }, './agents/xml/output_parser': { types: { import: './agents/xml/output_parser.d.ts', default: './agents/xml/output_parser.d.ts', require: './agents/xml/output_parser.d.cts' }, import: './agents/xml/output_parser.js', require: './agents/xml/output_parser.cjs' }, './chains/combine_documents': { types: { import: './chains/combine_documents.d.ts', default: './chains/combine_documents.d.ts', require: './chains/combine_documents.d.cts' }, import: './chains/combine_documents.js', require: './chains/combine_documents.cjs' }, './chains/query_constructor': { types: { import: './chains/query_constructor.d.ts', default: './chains/query_constructor.d.ts', require: './chains/query_constructor.d.cts' }, import: './chains/query_constructor.js', require: './chains/query_constructor.cjs' }, './document_loaders/fs/json': { types: { import: './document_loaders/fs/json.d.ts', default: './document_loaders/fs/json.d.ts', require: './document_loaders/fs/json.d.cts' }, import: './document_loaders/fs/json.js', require: './document_loaders/fs/json.cjs' }, './document_loaders/fs/text': { types: { import: './document_loaders/fs/text.d.ts', default: './document_loaders/fs/text.d.ts', require: './document_loaders/fs/text.d.cts' }, import: './document_loaders/fs/text.js', require: './document_loaders/fs/text.cjs' }, './retrievers/time_weighted': { types: { import: './retrievers/time_weighted.d.ts', default: './retrievers/time_weighted.d.ts', require: './retrievers/time_weighted.d.cts' }, import: './retrievers/time_weighted.js', require: './retrievers/time_weighted.cjs' }, './schema/query_constructor': { types: { import: './schema/query_constructor.d.ts', default: './schema/query_constructor.d.ts', require: './schema/query_constructor.d.cts' }, import: './schema/query_constructor.js', require: './schema/query_constructor.cjs' }, './stores/message/in_memory': { types: { import: './stores/message/in_memory.d.ts', default: './stores/message/in_memory.d.ts', require: './stores/message/in_memory.d.cts' }, import: './stores/message/in_memory.js', require: './stores/message/in_memory.cjs' }, './experimental/openai_files': { types: { import: './experimental/openai_files.d.ts', default: './experimental/openai_files.d.ts', require: './experimental/openai_files.d.cts' }, import: './experimental/openai_files.js', require: './experimental/openai_files.cjs' }, './output_parsers/expression': { types: { import: './output_parsers/expression.d.ts', default: './output_parsers/expression.d.ts', require: './output_parsers/expression.d.cts' }, import: './output_parsers/expression.js', require: './output_parsers/expression.cjs' }, './agents/react/output_parser': { types: { import: './agents/react/output_parser.d.ts', default: './agents/react/output_parser.d.ts', require: './agents/react/output_parser.d.cts' }, import: './agents/react/output_parser.js', require: './agents/react/output_parser.cjs' }, './document_loaders/fs/buffer': { types: { import: './document_loaders/fs/buffer.d.ts', default: './document_loaders/fs/buffer.d.ts', require: './document_loaders/fs/buffer.d.cts' }, import: './document_loaders/fs/buffer.js', require: './document_loaders/fs/buffer.cjs' }, './retrievers/parent_document': { types: { import: './retrievers/parent_document.d.ts', default: './retrievers/parent_document.d.ts', require: './retrievers/parent_document.d.cts' }, import: './retrievers/parent_document.js', require: './retrievers/parent_document.cjs' }, './retrievers/score_threshold': { types: { import: './retrievers/score_threshold.d.ts', default: './retrievers/score_threshold.d.ts', require: './retrievers/score_threshold.d.cts' }, import: './retrievers/score_threshold.js', require: './retrievers/score_threshold.cjs' }, './agents/openai/output_parser': { types: { import: './agents/openai/output_parser.d.ts', default: './agents/openai/output_parser.d.ts', require: './agents/openai/output_parser.d.cts' }, import: './agents/openai/output_parser.js', require: './agents/openai/output_parser.cjs' }, './chains/query_constructor/ir': { types: { import: './chains/query_constructor/ir.d.ts', default: './chains/query_constructor/ir.d.ts', require: './chains/query_constructor/ir.d.cts' }, import: './chains/query_constructor/ir.js', require: './chains/query_constructor/ir.cjs' }, './agents/format_scratchpad/log': { types: { import: './agents/format_scratchpad/log.d.ts', default: './agents/format_scratchpad/log.d.ts', require: './agents/format_scratchpad/log.d.cts' }, import: './agents/format_scratchpad/log.js', require: './agents/format_scratchpad/log.cjs' }, './agents/format_scratchpad/xml': { types: { import: './agents/format_scratchpad/xml.d.ts', default: './agents/format_scratchpad/xml.d.ts', require: './agents/format_scratchpad/xml.d.cts' }, import: './agents/format_scratchpad/xml.js', require: './agents/format_scratchpad/xml.cjs' }, './document_loaders/fs/directory': { types: { import: './document_loaders/fs/directory.d.ts', default: './document_loaders/fs/directory.d.ts', require: './document_loaders/fs/directory.d.cts' }, import: './document_loaders/fs/directory.js', require: './document_loaders/fs/directory.cjs' }, './experimental/openai_assistant': { types: { import: './experimental/openai_assistant.d.ts', default: './experimental/openai_assistant.d.ts', require: './experimental/openai_assistant.d.cts' }, import: './experimental/openai_assistant.js', require: './experimental/openai_assistant.cjs' }, './experimental/plan_and_execute': { types: { import: './experimental/plan_and_execute.d.ts', default: './experimental/plan_and_execute.d.ts', require: './experimental/plan_and_execute.d.cts' }, import: './experimental/plan_and_execute.js', require: './experimental/plan_and_execute.cjs' }, './chains/history_aware_retriever': { types: { import: './chains/history_aware_retriever.d.ts', default: './chains/history_aware_retriever.d.ts', require: './chains/history_aware_retriever.d.cts' }, import: './chains/history_aware_retriever.js', require: './chains/history_aware_retriever.cjs' }, './document_loaders/fs/multi_file': { types: { import: './document_loaders/fs/multi_file.d.ts', default: './document_loaders/fs/multi_file.d.ts', require: './document_loaders/fs/multi_file.d.cts' }, import: './document_loaders/fs/multi_file.js', require: './document_loaders/fs/multi_file.cjs' }, './experimental/generative_agents': { types: { import: './experimental/generative_agents.d.ts', default: './experimental/generative_agents.d.ts', require: './experimental/generative_agents.d.cts' }, import: './experimental/generative_agents.js', require: './experimental/generative_agents.cjs' }, './chains/combine_documents/reduce': { types: { import: './chains/combine_documents/reduce.d.ts', default: './chains/combine_documents/reduce.d.ts', require: './chains/combine_documents/reduce.d.cts' }, import: './chains/combine_documents/reduce.js', require: './chains/combine_documents/reduce.cjs' }, './experimental/prompts/handlebars': { types: { import: './experimental/prompts/handlebars.d.ts', default: './experimental/prompts/handlebars.d.ts', require: './experimental/prompts/handlebars.d.cts' }, import: './experimental/prompts/handlebars.js', require: './experimental/prompts/handlebars.cjs' }, './retrievers/document_compressors': { types: { import: './retrievers/document_compressors.d.ts', default: './retrievers/document_compressors.d.ts', require: './retrievers/document_compressors.d.cts' }, import: './retrievers/document_compressors.js', require: './retrievers/document_compressors.cjs' }, './retrievers/matryoshka_retriever': { types: { import: './retrievers/matryoshka_retriever.d.ts', default: './retrievers/matryoshka_retriever.d.ts', require: './retrievers/matryoshka_retriever.d.cts' }, import: './retrievers/matryoshka_retriever.js', require: './retrievers/matryoshka_retriever.cjs' }, './retrievers/self_query/functional': { types: { import: './retrievers/self_query/functional.d.ts', default: './retrievers/self_query/functional.d.ts', require: './retrievers/self_query/functional.d.cts' }, import: './retrievers/self_query/functional.js', require: './retrievers/self_query/functional.cjs' }, './retrievers/contextual_compression': { types: { import: './retrievers/contextual_compression.d.ts', default: './retrievers/contextual_compression.d.ts', require: './retrievers/contextual_compression.d.cts' }, import: './retrievers/contextual_compression.js', require: './retrievers/contextual_compression.cjs' }, './experimental/prompts/custom_format': { types: { import: './experimental/prompts/custom_format.d.ts', default: './experimental/prompts/custom_format.d.ts', require: './experimental/prompts/custom_format.d.cts' }, import: './experimental/prompts/custom_format.js', require: './experimental/prompts/custom_format.cjs' }, './agents/format_scratchpad/openai_tools': { types: { import: './agents/format_scratchpad/openai_tools.d.ts', default: './agents/format_scratchpad/openai_tools.d.ts', require: './agents/format_scratchpad/openai_tools.d.cts' }, import: './agents/format_scratchpad/openai_tools.js', require: './agents/format_scratchpad/openai_tools.cjs' }, './document_transformers/openai_functions': { types: { import: './document_transformers/openai_functions.d.ts', default: './document_transformers/openai_functions.d.ts', require: './document_transformers/openai_functions.d.cts' }, import: './document_transformers/openai_functions.js', require: './document_transformers/openai_functions.cjs' }, './agents/format_scratchpad/log_to_message': { types: { import: './agents/format_scratchpad/log_to_message.d.ts', default: './agents/format_scratchpad/log_to_message.d.ts', require: './agents/format_scratchpad/log_to_message.d.cts' }, import: './agents/format_scratchpad/log_to_message.js', require: './agents/format_scratchpad/log_to_message.cjs' }, './experimental/chains/violation_of_expectations': { types: { import: './experimental/chains/violation_of_expectations.d.ts', default: './experimental/chains/violation_of_expectations.d.ts', require: './experimental/chains/violation_of_expectations.d.cts' }, import: './experimental/chains/violation_of_expectations.js', require: './experimental/chains/violation_of_expectations.cjs' }, './retrievers/document_compressors/chain_extract': { types: { import: './retrievers/document_compressors/chain_extract.d.ts', default: './retrievers/document_compressors/chain_extract.d.ts', require: './retrievers/document_compressors/chain_extract.d.cts' }, import: './retrievers/document_compressors/chain_extract.js', require: './retrievers/document_compressors/chain_extract.cjs' }, './retrievers/document_compressors/embeddings_filter': { types: { import: './retrievers/document_compressors/embeddings_filter.d.ts', default: './retrievers/document_compressors/embeddings_filter.d.ts', require: './retrievers/document_compressors/embeddings_filter.d.cts' }, import: './retrievers/document_compressors/embeddings_filter.js', require: './retrievers/document_compressors/embeddings_filter.cjs' } }, gitHead: '67574efc941f455d6f08693cd78f827a6bce7525', scripts: { lint: 'yarn lint:eslint && yarn lint:dpdm', test: 'NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\.int\.test.ts --testTimeout 30000 --maxWorkers=50%', build: 'yarn turbo:command build:internal --filter=langchain', clean: 'rm -rf .turbo dist/', format: 'prettier --config .prettierrc --write "src"', prepack: 'yarn build', release: 'release-it --only-version --config .release-it.json', 'lint:fix': 'yarn lint:eslint --fix && yarn lint:dpdm', 'lint:dpdm': 'dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/*/.ts', precommit: 'lint-staged', 'test:watch': 'NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\.int\.test.ts', 'lint:eslint': 'NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/', 'test:single': 'NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000', 'format:check': 'prettier --config .prettierrc --check "src"', 'build:internal': 'yarn lc_build --create-entrypoints --pre --tree-shaking --gen-maps', 'test:integration': 'NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\.int\.test.ts --testTimeout 100000 --maxWorkers=50%' }, directories: {}, dependencies: { zod: '^3.22.4', uuid: '^10.0.0', yaml: '^2.2.1', 'js-yaml': '^4.1.0', 'p-retry': '4', langsmith: '^0.1.56-rc.1', 'js-tiktoken': '^1.0.12', jsonpointer: '^5.0.1', 'openapi-types': '^12.1.3', '@langchain/openai': '>=0.1.0 <0.4.0', 'zod-to-json-schema': '^3.22.3', '@langchain/textsplitters': '>=0.0.0 <0.2.0' }, publishConfig: { access: 'public' }, devDependencies: { dpdm: '^3.12.0', jest: '^29.5.0', axios: '^0.26.0', peggy: '^3.0.2', dotenv: '^16.0.3', eslint: '^8.33.0', openai: '^4.41.1', rimraf: '^5.0.1', rollup: '^3.19.1', cheerio: '1.0.0-rc.12', 'ts-jest': '^29.1.0', typeorm: '^0.3.20', prettier: '^2.8.3', '@swc/core': '^1.3.90', '@swc/jest': '^0.2.29', '@types/ws': '^8', wikipedia: '^2.1.2', handlebars: '^4.7.8', 'release-it': '^17.6.0', typescript: '~5.1.6', '@types/uuid': '^9', '@types/jsdom': '^21.1.1', '@jest/globals': '^29.5.0', '@langchain/aws': '', '@types/js-yaml': '^4', '@faker-js/faker': '^7.6.0', '@langchain/core': 'workspace:', '@langchain/groq': '', '@langchain/cohere': '', '@langchain/ollama': '', '@types/handlebars': '^4.1.0', '@langchain/scripts': '>=0.1.0 <0.2.0', 'eslint-plugin-jest': '^27.6.0', '@types/html-to-text': '^9', '@langchain/anthropic': '', '@langchain/mistralai': '', 'eslint-plugin-import': '^2.27.5', '@tsconfig/recommended': '^1.0.2', 'jest-environment-node': '^29.6.4', 'eslint-config-prettier': '^8.6.0', 'eslint-plugin-prettier': '^4.2.1', '@langchain/google-genai': '', '@typescript-eslint/parser': '^5.58.0', 'eslint-config-airbnb-base': '^15.0.0', '@langchain/google-vertexai': '', 'eslint-plugin-no-instanceof': '^1.0.1', '@typescript-eslint/eslint-plugin': '^5.58.0' }, peerDependencies: { axios: '', peggy: '^3.0.2', cheerio: '', typeorm: '', handlebars: '^4.7.8', '@langchain/aws': '', '@langchain/core': '>=0.2.21 <0.4.0', '@langchain/groq': '', '@langchain/cohere': '', '@langchain/ollama': '', '@langchain/anthropic': '', '@langchain/mistralai': '', '@langchain/google-genai': '', '@langchain/google-vertexai': '' }, peerDependenciesMeta: { axios: { optional: true }, peggy: { optional: true }, cheerio: { optional: true }, typeorm: { optional: true }, handlebars: { optional: true }, '@langchain/aws': { optional: true }, '@langchain/groq': { optional: true }, '@langchain/cohere': { optional: true }, '@langchain/ollama': { optional: true }, '@langchain/anthropic': { optional: true }, '@langchain/mistralai': { optional: true }, '@langchain/google-genai': { optional: true }, '@langchain/google-vertexai': { optional: true } } } platform: Mac node: v20.17.0 pnpm: 9.11.0

dosubot[bot] commented 1 month ago

Hey @lynicis! I'm here to help you with any bugs, questions, or to guide you on becoming a contributor. Let's tackle this issue together!

I found a similar issue that might help you resolve the "text.replace is not a function" error. The error often occurs when a non-string value is processed where a string is expected, particularly in the OpenAIEmbeddings.embedQuery method.

Solution:

  1. Ensure Correct Input Types: The embedQuery method expects a string input. Make sure that the input being passed is a string and not undefined or any other type.

  2. Filter Undefined Content: If your documents might have undefined pageContent, filter them out before processing:

    const newDocs = documents
       .filter((doc) => doc.pageContent)
       .map((doc) => ({
           ...doc,
           metadata: {
               ...doc.metadata,
               s3Key: key,
           },
       }));
  3. Check Retriever Implementation: Ensure that the retriever is correctly implemented and returns the expected types. It should be a subclass of BaseRetrieverInterface or implement RunnableInterface.

  4. Invoke Chain Correctly: When using RunnableSequence, ensure that the input is structured correctly. Here's an example of how to set up the chain:

    const ragChain = RunnableSequence.from([
         RunnableLambda.from((input) => input.question),
         {
           context: retriever.pipe(formatDocumentsAsString),
           question: new RunnablePassthrough(),
         },
         prompt,
         llm,
         new StringOutputParser(),
       ]);
    
    const response = ragChain.invoke({ question });

These steps should help you address the error by ensuring that the inputs are correctly formatted and processed [1][2].

To continue talking to Dosu, mention @dosu.

jacoblee93 commented 1 month ago

Hey @lynicis, I believe this was fixed here:

https://github.com/langchain-ai/langchainjs/pull/6920

Please reopen if upgrading to the latest @langchain/pinecone doesn't resolve this.

lynicis commented 1 month ago

Hey @lynicis, I believe this was fixed here:

6920

Please reopen if upgrading to the latest @langchain/pinecone doesn't resolve this.

Still same on "@langchain/pinecone": "^0.1.1"

lynicis commented 2 weeks ago

OpenAI Embeddings is broken and no one cares

jacoblee93 commented 2 weeks ago

Can you give a minimal reproducible example? Something I can paste into a file and run end to end

lynicis commented 2 weeks ago

Can you give a minimal reproducible example? Something I can paste into a file and run end to end

After invoke prompt, it just throws replace is not a function

import { MemoryVectorStore } from "langchain/vectorstores/memory";
import { createStuffDocumentsChain } from "langchain/chains/combine_documents";
import { OpenAIEmbeddings, OpenAI, ChatOpenAI } from "@langchain/openai";
import { createRetrievalChain } from "langchain/chains/retrieval";
import { PDFLoader } from "langchain/document_loaders/fs/pdf";
import { pull } from "langchain/hub";

const doc = await new PDFLoader("foo.pdf").load();

const textEmbedding = await new OpenAIEmbeddings({
  modelName: "text-embedding-3-large",
  openAIApiKey: "foobar",
});

await MemoryVectorStore.fromDocuments(doc, textEmbedding);
const retriever = vectorStore.asRetriever();

const llm = new ChatOpenAI({
  model: "gpt-4o-mini",
  apiKey: "foobar",
});

const fooBarPrompt = pull("foo-bar-prompt");

const documentChain = await createStuffDocumentsChain({
  llm,
  prompt: fooBarPrompt,
});

const ragChain = await createRetrievalChain({
  retriever,
  combineDocsChain: documentChain,
});

const game = await ragChain.invoke({
    foo: "bar",
});
jacoblee93 commented 2 weeks ago

Can you print const fooBarPrompt = pull("foo-bar-prompt");? Pretty sure that also needs to be await'ed

lynicis commented 1 week ago

Can you print const fooBarPrompt = pull("foo-bar-prompt");? Pretty sure that also needs to be await'ed

sorry it was typo but same

jacoblee93 commented 1 week ago

I can't see the prompt though

lynicis commented 1 week ago

I can't see the prompt though

import { createStuffDocumentsChain } from "langchain/chains/combine_documents";
import { StringOutputParser } from "@langchain/core/output_parsers";
import { MemoryVectorStore } from "langchain/vectorstores/memory";
import { OpenAIEmbeddings, ChatOpenAI } from "@langchain/openai";
import { createRetrievalChain } from "langchain/chains/retrieval";
import { PDFLoader } from "langchain/document_loaders/fs/pdf";
import { pull } from "langchain/hub";

const pdf = await new PDFLoader("test.pdf").load();

const openAIEmbeddings = await new OpenAIEmbeddings({
    modelName: "text-embedding-3-large",
    openAIApiKey: "...",
});

const vectorStore = new MemoryVectorStore(openAIEmbeddings);
await vectorStore.addDocuments(pdf);

const retriever = vectorStore.asRetriever();

const llm = new ChatOpenAI({
    model: "gpt-4o-mini",
    apiKey: "...",
})

const prompt = await pull("rlm/rag-prompt");

const documentChain = await createStuffDocumentsChain({
    llm,
    prompt,
});
const ragChain = await createRetrievalChain({
    retriever,
    combineDocsChain: documentChain,
    outputParser: new StringOutputParser()
});

const result = await ragChain.invoke("what is the context about?");

console.log(result);
lynicis commented 1 week ago

is there any update?

jacoblee93 commented 1 week ago

Doesn't seem like you're using TypeScript? We generally recommend it.

Invoking looks that chain looks like this:

const result = await ragChain.invoke({ input: "what is the context about?" });

You also cannot pass arbitrary prompts.

So end to end:

import { createStuffDocumentsChain } from "langchain/chains/combine_documents";
import { MemoryVectorStore } from "langchain/vectorstores/memory";
import { OpenAIEmbeddings, ChatOpenAI } from "@langchain/openai";
import { createRetrievalChain } from "langchain/chains/retrieval";
import { PDFLoader } from "@langchain/community/document_loaders/fs/pdf";
import { pull } from "langchain/hub";
import { ChatPromptTemplate } from "@langchain/core/prompts";

const pdf = await new PDFLoader(
  "test.pdf"
).load();

const openAIEmbeddings = await new OpenAIEmbeddings({
  model: "text-embedding-3-large",
});

const vectorStore = new MemoryVectorStore(openAIEmbeddings);
await vectorStore.addDocuments(pdf);

const retriever = vectorStore.asRetriever();

const llm = new ChatOpenAI({
  model: "gpt-4o-mini",
});

const SYSTEM_TEMPLATE = `Answer the user's questions based on the below context. 
If the context doesn't contain any relevant information to the question, don't make something up and just say "I don't know":

<context>
{context}
</context>
`;

const prompt = ChatPromptTemplate.fromMessages([
  ["system", SYSTEM_TEMPLATE],
  ["placeholder", "{messages}"],
]);

const documentChain = await createStuffDocumentsChain({
  llm,
  prompt,
});
const ragChain = await createRetrievalChain({
  retriever,
  combineDocsChain: documentChain,
});

const result = await ragChain.invoke({ input: "what is the context about?" });

console.log(result);