Compare commits

...

2 Commits

Author SHA1 Message Date
Harrison Chase
10a73de9dc cr 2023-06-03 16:54:43 -07:00
YanchaoMa
62d2edd165 Update neo4j_graph.py (#5120)
Remove the version dependencies of neo4j-driver.
[neo4j-driver Test code of different
versions.](https://github.com/crazyyanchao/langchain-crash-course/blob/main/tool-5/app.py)
# Your PR Title (What it does)

<!--
Thank you for contributing to LangChain! Your PR will appear in our next
release under the title you set. Please make sure it highlights your
valuable contribution.

Replace this with a description of the change, the issue it fixes (if
applicable), and relevant context. List any dependencies required for
this change.

After you're done, someone will review your PR. They may suggest
improvements. If no one reviews your PR within a few days, feel free to
@-mention the same people again, as notifications can get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)

## Before submitting

<!-- If you're adding a new integration, include an integration test and
an example notebook showing its use! -->

## Who can review?

Community members can review the PR once tests pass. Tag
maintainers/contributors who might be interested:

<!-- For a quicker response, figure out the right person to tag with @

        @hwchase17 - project lead

        Tracing / Callbacks
        - @agola11

        Async
        - @agola11

        DataLoaders
        - @eyurtsev

        Models
        - @hwchase17
        - @agola11

        Agents / Tools / Toolkits
        - @vowelparrot
        
        VectorStores / Retrievers / Memory
        - @dev2049
        
 -->
2023-06-03 16:53:18 -07:00
2 changed files with 10 additions and 25 deletions

View File

@@ -47,15 +47,20 @@ class GraphCypherQAChain(Chain):
*,
qa_prompt: BasePromptTemplate = CYPHER_QA_PROMPT,
cypher_prompt: BasePromptTemplate = CYPHER_GENERATION_PROMPT,
qa_chain: Optional[LLMChain] = None,
cypher_generation_chain: Optional[LLMChain] = None,
**kwargs: Any,
) -> GraphCypherQAChain:
"""Initialize from LLM."""
qa_chain = LLMChain(llm=llm, prompt=qa_prompt)
cypher_generation_chain = LLMChain(llm=llm, prompt=cypher_prompt)
_qa_chain = qa_chain or LLMChain(llm=llm, prompt=qa_prompt)
_cypher_generation_chain = cypher_generation_chain or LLMChain(
llm=llm, prompt=cypher_prompt
)
return cls(
qa_chain=qa_chain,
cypher_generation_chain=cypher_generation_chain,
qa_chain=_qa_chain,
cypher_generation_chain=_cypher_generation_chain,
**kwargs,
)

View File

@@ -43,27 +43,7 @@ class Neo4jGraph:
self._driver = neo4j.GraphDatabase.driver(url, auth=(username, password))
self._database = database
self.schema = ""
# Verify connection
try:
self._driver.verify_connectivity()
except neo4j.exceptions.ServiceUnavailable:
raise ValueError(
"Could not connect to Neo4j database. "
"Please ensure that the url is correct"
)
except neo4j.exceptions.AuthError:
raise ValueError(
"Could not connect to Neo4j database. "
"Please ensure that the username and password are correct"
)
# Set schema
try:
self.refresh_schema()
except neo4j.exceptions.ClientError:
raise ValueError(
"Could not use APOC procedures. "
"Please install the APOC plugin in Neo4j."
)
self.refresh_schema()
@property
def get_schema(self) -> str: