Skip to content

Commit

Permalink
fix formating
Browse files Browse the repository at this point in the history
  • Loading branch information
nelly-hateva committed Jan 3, 2024
1 parent 1f3759c commit 614596b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 5 additions & 3 deletions libs/community/langchain_community/graphs/rdf_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from typing import (
TYPE_CHECKING,
Dict,
List,
Optional,
Dict,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -127,8 +127,10 @@ def __init__(
:param update_endpoint: SPARQL endpoint for UPDATE queries, write access
:param standard: RDF, RDFS, or OWL
:param local_copy: new local copy for storing changes
:param graph_kwargs: Additional rdflib.Graph specific kwargs that will be used to initialize it.
If not provided, only identifier="urn:x-rdflib:default" is used to initialize the graph.
:param graph_kwargs: Additional rdflib.Graph specific kwargs
that will be used to initialize it.
If not provided, only identifier="urn:x-rdflib:default" is used
to initialize the graph.
"""
self.source_file = source_file
self.serialization = serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,30 @@ def test_sparql_insert() -> None:
def test_loading_schema_from_graphdb() -> None:
graph = RdfGraph(
query_endpoint="http://localhost:7200/repositories/langchain",
graph_kwargs={"bind_namespaces": "none"}
graph_kwargs={"bind_namespaces": "none"},
)
schema = graph.get_schema
prefix = (
"In the following, each IRI is followed by the local name and optionally its description in parentheses. \n"
"The RDF graph supports the following node types:")
"In the following, each IRI is followed by the local name and "
"optionally its description in parentheses. \n"
"The RDF graph supports the following node types:"
)
assert schema.startswith(prefix)

infix = "The RDF graph supports the following relationships:"
assert infix in schema

classes = schema[len(prefix):schema.index(infix)]
classes = schema[len(prefix) : schema.index(infix)]
assert len(re.findall("<[^>]+> \\([^)]+\\)", classes)) == 5

relationships = schema[schema.index(infix) + len(infix):]
relationships = schema[schema.index(infix) + len(infix) :]
assert len(re.findall("<[^>]+> \\([^)]+\\)", relationships)) == 58


def test_graph_qa_chain_with_graphdb() -> None:
graph = RdfGraph(
query_endpoint="http://localhost:7200/repositories/langchain",
graph_kwargs={"bind_namespaces": "none"}
graph_kwargs={"bind_namespaces": "none"},
)

chain = GraphSparqlQAChain.from_llm(OpenAI(temperature=0), graph=graph)
Expand Down

0 comments on commit 614596b

Please sign in to comment.