Facing Issue with the GraphCypherQAChain with FewshotPromptTemplate #5657
Replies: 1 comment
-
Hey @Nimmalapudi-Pratyusha! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind. I'm a bot designed to assist you while waiting for a human maintainer. Let's dive into this issue and see how we can tackle it together! To resolve the Neo4j error indicating an invalid input 'I' when using the import { Neo4jGraph } from "@langchain/community/graphs/neo4j_graph";
import { OpenAI } from "@langchain/openai";
import { GraphCypherQAChain } from "langchain/chains/graph_qa/cypher";
import { CYPHER_GENERATION_PROMPT } from "langchain/src/chains/graph_qa/prompts";
const url = "bolt://localhost:7687";
const username = "neo4j";
const password = "pleaseletmein";
const graph = await Neo4jGraph.initialize({ url, username, password });
const model = new OpenAI({ temperature: 0 });
// Populate the database with two nodes and a relationship
await graph.query(
"CREATE (a:Actor {name:'Bruce Willis'})" +
"-[:ACTED_IN]->(:Movie {title: 'Pulp Fiction'})"
);
// Refresh schema
await graph.refreshSchema();
const chain = GraphCypherQAChain.fromLLM({
llm: model,
graph,
cypherPrompt: CYPHER_GENERATION_PROMPT,
});
const res = await chain.run("Who played in Pulp Fiction?");
console.log(res);
// Bruce Willis played in Pulp Fiction. Ensure that the |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
Passing some Examples for the Cypher Queries and using the FewshotPromptTemplate with the examples and the prompt to it and finally invoking with the GraphCypherQAChain
System Info
Node version = v16.15.1
Beta Was this translation helpful? Give feedback.
All reactions