-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
34 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
NEO4J_URI=bolt://1xxx | ||
NEO4J_USERNAME=neo4j | ||
NEO4J_PASSWORD=xxx |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from dotenv import load_dotenv | ||
from langchain_community.graphs import Neo4jGraph | ||
from langchain_experimental.graph_transformers import LLMGraphTransformer | ||
from langchain_community.document_loaders import PyPDFLoader | ||
from langchain_openai import ChatOpenAI | ||
from langchain_core.prompts import ChatPromptTemplate | ||
from langchain.docstore.document import Document | ||
from langchain.chains.combine_documents import create_stuff_documents_chain | ||
documents=[] | ||
llm=ChatOpenAI(model="gpt-4o") | ||
load_dotenv() | ||
graph=Neo4jGraph() | ||
llm_transformers=LLMGraphTransformer(llm=llm) | ||
|
||
loader=PyPDFLoader(file_path=r"C:\Users\welcome\OneDrive\Documents\GitHub\LLMtutorial\tutorial121\cv1.pdf") | ||
docs=loader.load() | ||
source=docs[0].metadata["source"] | ||
prompt=ChatPromptTemplate.from_template( | ||
"""Summarize this content with 4-5 sentences focusing on personal infomation,education,organization,experience in organization, | ||
project details,skills,programming language :{context} | ||
""") | ||
chain=create_stuff_documents_chain(llm,prompt) | ||
response=chain.invoke({"context":docs}) | ||
summary=Document(page_content=response,metadata={"source":source}) | ||
documents.append(summary) | ||
graph_documents=llm_transformers.convert_to_graph_documents(documents) | ||
graph.add_graph_documents(graph_documents) | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.