From 7ac3b00ed50d62634e2f5b52a16041c15cd2fc44 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Fri, 13 Dec 2024 19:38:32 -0800 Subject: [PATCH] Fix lint --- .../src/stores/message/neo4j.ts | 18 +++++++++++------- .../src/stores/tests/neo4j.int.test.ts | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libs/langchain-community/src/stores/message/neo4j.ts b/libs/langchain-community/src/stores/message/neo4j.ts index 8c8fb5d358bf..4234c3889060 100644 --- a/libs/langchain-community/src/stores/message/neo4j.ts +++ b/libs/langchain-community/src/stores/message/neo4j.ts @@ -1,5 +1,4 @@ -import neo4j from "neo4j-driver"; -import { Driver, Record, Neo4jError, auth } from "neo4j-driver"; +import neo4j, { Driver, Record, Neo4jError, auth } from "neo4j-driver"; import { v4 as uuidv4 } from "uuid"; import { BaseListChatMessageHistory } from "@langchain/core/chat_history"; import { @@ -25,9 +24,13 @@ const defaultConfig = { export class Neo4jChatMessageHistory extends BaseListChatMessageHistory { lc_namespace: string[] = ["langchain", "stores", "message", "neo4j"]; + sessionId: string | number; + sessionNodeLabel: string; + messageNodeLabel: string; + windowSize: number; private driver: Driver; @@ -100,12 +103,13 @@ export class Neo4jChatMessageHistory extends BaseListChatMessageHistory { `; try { - const { records } = await this.driver.executeQuery(getMessagesCypherQuery, { - sessionId: this.sessionId, - }); - const results = records.map((record: Record) => - record.get("result") + const { records } = await this.driver.executeQuery( + getMessagesCypherQuery, + { + sessionId: this.sessionId, + } ); + const results = records.map((record: Record) => record.get("result")); return mapStoredMessagesToChatMessages(results); } catch (e) { diff --git a/libs/langchain-community/src/stores/tests/neo4j.int.test.ts b/libs/langchain-community/src/stores/tests/neo4j.int.test.ts index bcd86e09619b..2f6c17d01ed6 100644 --- a/libs/langchain-community/src/stores/tests/neo4j.int.test.ts +++ b/libs/langchain-community/src/stores/tests/neo4j.int.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, beforeEach, afterEach } from "@jest/globals"; -import { Neo4jChatMessageHistory } from "../message/neo4j.js"; import { HumanMessage, AIMessage } from "@langchain/core/messages"; import neo4j from "neo4j-driver"; +import { Neo4jChatMessageHistory } from "../message/neo4j.js"; const goodConfig = { url: "bolt://host.docker.internal:7687", @@ -20,7 +20,7 @@ describe("The Neo4jChatMessageHistory class", () => { it("Requires a url, username and password, throwing an error if not provided", async () => { const badConfig = {}; await expect( - // @ts-expect-error + // @ts-expect-error Bad config Neo4jChatMessageHistory.initialize(badConfig) ).rejects.toThrow(neo4j.Neo4jError); }); @@ -113,7 +113,7 @@ describe("The Neo4jChatMessageHistory class", () => { new HumanMessage("How many bottles of beer are currently on the wall?"), new AIMessage("There are currently 98 bottles of beer on the wall."), ]; - for (let message of messages) { + for (const message of messages) { await instance?.addMessage(message); } const results = await instance?.getMessages();