mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
513e491ce9
- **Description:** The generated relationships in the graph had no properties, but the Relationship class was properly defined with properties. This made it very difficult to transform conditional sentences into a graph. Adding properties to relationships can solve this issue elegantly. The changes expand on the existing LLMGraphTransformer implementation but add the possibility to define allowed relationship properties like this: LLMGraphTransformer(llm=llm, relationship_properties=["Condition", "Time"],) - **Issue:** no issue found - **Dependencies:** n/a - **Twitter handle:** @IstvanSpace -Quick Test ================================================================= from dotenv import load_dotenv import os from langchain_community.graphs import Neo4jGraph from langchain_experimental.graph_transformers import LLMGraphTransformer from langchain_openai import ChatOpenAI from langchain_core.prompts import ChatPromptTemplate from langchain_core.documents import Document load_dotenv() os.environ["NEO4J_URI"] = os.getenv("NEO4J_URI") os.environ["NEO4J_USERNAME"] = os.getenv("NEO4J_USERNAME") os.environ["NEO4J_PASSWORD"] = os.getenv("NEO4J_PASSWORD") graph = Neo4jGraph() llm = ChatOpenAI(temperature=0, model_name="gpt-4o") llm_transformer = LLMGraphTransformer(llm=llm) #text = "Harry potter likes pies, but only if it rains outside" text = "Jack has a dog named Max. Jack only walks Max if it is sunny outside." documents = [Document(page_content=text)] llm_transformer_props = LLMGraphTransformer( llm=llm, relationship_properties=["Condition"], ) graph_documents_props = llm_transformer_props.convert_to_graph_documents(documents) print(f"Nodes:{graph_documents_props[0].nodes}") print(f"Relationships:{graph_documents_props[0].relationships}") graph.add_graph_documents(graph_documents_props) --------- Co-authored-by: Istvan Lorincz <istvan.lorincz@pm.me> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> |
||
---|---|---|
.. | ||
agents | ||
autonomous_agents | ||
chat_models | ||
comprehend_moderation | ||
cpal | ||
data_anonymizer | ||
fallacy_removal | ||
generative_agents | ||
graph_transformers | ||
llm_bash | ||
llm_symbolic_math | ||
llms | ||
open_clip | ||
openai_assistant | ||
pal_chain | ||
plan_and_execute | ||
prompt_injection_identifier | ||
prompts | ||
pydantic_v1 | ||
recommenders | ||
retrievers | ||
rl_chain | ||
smart_llm | ||
sql | ||
synthetic_data | ||
tabular_synthetic_data | ||
tools | ||
tot | ||
utilities | ||
video_captioning | ||
__init__.py | ||
py.typed | ||
text_splitter.py |