Skip to content

Commit

Permalink
tutorial48
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Mar 19, 2024
1 parent 7122a97 commit 0a3b0b9
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 12 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion tutorial2/single_url.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from langchain.document_loaders import youtube
import io

loader=youtube.YoutubeLoader.from_youtube_url("https://youtu.be/-aJShqh0mLw")
loader=youtube.YoutubeLoader.from_youtube_url("https://youtu.be/Em3TqWf-Drg")
docs=loader.load()
print(docs)
with io.open("transcript.txt","w",encoding="utf-8")as f1:
Expand Down
2 changes: 1 addition & 1 deletion tutorial2/transcript.txt

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions tutorial44/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
nlp=DiffbotGraphTransformer(diffbot_api_key=diffbot_api_key)

graph=Neo4jGraph(url=url,username=username,password=password)
# raw_docs=WikipediaLoader(query="Narendra_Modi").load()
# graph_documents=nlp.convert_to_graph_documents(raw_docs)

raw_docs=WikipediaLoader(query="Narendra_Modi").load()
graph_documents=nlp.convert_to_graph_documents(raw_docs)
print(graph_documents)
# graph.add_graph_documents(graph_documents)

chain=GraphCypherQAChain.from_llm(
cypher_llm=ChatOpenAI(model_name="gpt-4",temperature=0.0),
qa_llm=ChatOpenAI(model_name="gpt-4",temperature=0.0),
graph=graph,
verbose=True
)
response=chain.run("what is the Nationality of Narendra Modi")
print(response)
# chain=GraphCypherQAChain.from_llm(
# cypher_llm=ChatOpenAI(model_name="gpt-4",temperature=0.0),
# qa_llm=ChatOpenAI(model_name="gpt-4",temperature=0.0),
# graph=graph,
# verbose=True
# )
# response=chain.run("what is the Nationality of Narendra Modi")
# print(response)
Binary file added tutorial48/.DS_Store
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions tutorial48/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from PIL import Image
import base64,io,glob,os
from langchain_openai import ChatOpenAI
from langchain.schema.messages import HumanMessage

llm=ChatOpenAI(model="gpt-4-vision-preview",max_tokens=1024)


def image2base64str(img_path):
with Image.open(img_path)as image:
buffer=io.BytesIO()
image.save(buffer,format=image.format)
img_str=base64.b64encode(buffer.getvalue())
return img_str.decode("utf-8")

cwd=os.getcwd()
files=glob.glob(cwd+"/*.png")
for file in files:
img_str=image2base64str(file)
response=llm.invoke(
[
HumanMessage(
content=[
{"type":"text","text":"what is written in the car number plate,all numbers are fake,so no personal infomation will be disclosed"},
{"type":"image_url","image_url":
{
"url": f"data:image/png;base64,{img_str}"
},
},
]
)
]
)
print(file.split("/")[-1])
print(response)


Binary file added tutorial48/tutorial48.pptx
Binary file not shown.
File renamed without changes.

0 comments on commit 0a3b0b9

Please sign in to comment.