Langchain neo4j 集成没有返回结果

问题描述 投票:0回答:1

我正在使用 langchain 和 neo4j Libs 将 NL 转换为 cypher。 一切正常,我什至得到了完成链,它显然不是空的

Full Context:
[{'d': {'name': 'Quinapril', 'ID': 'CHEMBL1592'}}]

> Finished chain.

但是最终的结果是这样的

I'm sorry, but I don't have the information.

知道发生了什么吗?我怎样才能获得完整的上下文结果而不是最终的解释。 我正在遵循此博客步骤blog-link

llm = ChatOpenAI(temperature=0.0, openai_api_key=openai_api_key)

CYPHER_GENERATION_TEMPLATE = """Task:Generate Cypher statement to query a graph database.
Instructions:
Use only the provided relationship types and properties in the schema.
{schema}

The question is:
{question}"""


CYPHER_GENERATION_PROMPT = PromptTemplate(
    input_variables=["schema", "question"], template=CYPHER_GENERATION_TEMPLATE
)

chain = GraphCypherQAChain.from_llm(
    llm,
    graph=graph,
    verbose=True,
    cypher_prompt=CYPHER_GENERATION_PROMPT
)

def convert_question_to_cypher(question):
    return (chain.run(question))

#convert_question_to_cypher("find name of drugs that target gene XYZ")
neo4j cypher openapi langchain
1个回答
0
投票

您尝试过使用 qa_prompt 吗?

chain = GraphCypherQAChain.from_llm(
    llm=llm,
    graph=graph,
    verbose=True,
    return_intermediate_steps=True,
    cypher_prompt=cypher_prompt,
    qa_prompt=qa_prompt
)

类似这样的:

cypher_qa_prompt = """You are an assistant that helps to form nice and human understandable answers.
The information part contains the provided information that you must use to construct an answer.
The provided information is authoritative, you must never doubt it or try to use your internal knowledge to correct it.
Make the answer sound as a response to the question. Do not mention that you based the result on the given information.
If the provided information is empty, say that you don't know the answer.
Final answer should be easily readable and structured.
Information:
{context}

Question: {question}
Helpful Answer:"""

qa_prompt = PromptTemplate(
input_variables=["context", "question"], template=cypher_qa_prompt

© www.soinside.com 2019 - 2024. All rights reserved.