Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Dec 14, 2024
1 parent 18d4b76 commit 7ac3b00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 11 additions & 7 deletions libs/langchain-community/src/stores/message/neo4j.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions libs/langchain-community/src/stores/tests/neo4j.int.test.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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);
});
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7ac3b00

Please sign in to comment.