Skip to content

Commit

Permalink
tutorial121
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Nov 7, 2024
1 parent 15d39e4 commit be85ce2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 123 deletions.
3 changes: 3 additions & 0 deletions tutorial121/.env
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 added tutorial121/cv1.pdf
Binary file not shown.
29 changes: 29 additions & 0 deletions tutorial121/main.py
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 added tutorial121/tutorial121.pptx
Binary file not shown.
2 changes: 1 addition & 1 deletion tutorial2/single_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from langchain_community.document_loaders import YoutubeLoader
import io

loader=YoutubeLoader.from_youtube_url("https://www.youtube.com/watch?v=HxTNuGnYZWM")
loader=YoutubeLoader.from_youtube_url("https://youtu.be/ozr3uI99v-E")
docs=loader.load()
print(docs)
with io.open("transcript.txt","w",encoding="utf-8")as f1:
Expand Down
123 changes: 1 addition & 122 deletions tutorial2/transcript.txt

Large diffs are not rendered by default.

0 comments on commit be85ce2

Please sign in to comment.