Skip to content

Commit

Permalink
tutorial124
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Nov 13, 2024
1 parent 9dad183 commit ade2c42
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 2 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions tutorial124/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NEO4J_URI=bolt://xxx
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=xxx
NEO4J_DATABASE=neo4j
33 changes: 33 additions & 0 deletions tutorial124/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from langchain_openai import ChatOpenAI
from langchain_community.graphs import Neo4jGraph
from langchain.prompts import PromptTemplate
from dotenv import load_dotenv
import json
load_dotenv()
graph=Neo4jGraph()
schema=graph.get_schema
llm=ChatOpenAI(model="gpt-4o")
template="""
Task: Generate Cypher statement to query a graph database.
Instructions:
Use only the provided nodes, relationship and properties from the schema provided below:
{schema}
Do not use any other relationship types or properties that are not provided.
sample question and queries given below:
question:display the os name which is used maximum time
query:MATCH (:Machine)-[:RUNS]->(os:OS) RETURN os.name AS osName ,count(os) as os order by os DESC limit 1
The question is:
{question}
your response will be only json with below key nothing else
'query':
"""
prompt=PromptTemplate.from_template(template)
chain=prompt | llm
response=chain.invoke({"schema":schema,"question":"display all racks name and count of machine it is holding"})
response=response.content
response=response.replace("json","")
response=response.replace("`","")
query=json.loads(response)["query"]
print(query)
result=graph.query(query=query)
print(result)
9 changes: 9 additions & 0 deletions tutorial124/prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Task: Generate Cypher statement to query a graph database.
Instructions:
Use only the provided nodes, relationship and properties from the schema provided below:
{schema}
Do not use any other relationship types or properties that are not provided.
The question is:
{question}
your response will be only json with below key nothing else
'query':
3 changes: 3 additions & 0 deletions tutorial124/qsn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
display all distinctint os count
display all distinctint machine count based on os
display all racks name and count of machine it is holding
Binary file added tutorial124/tutorial124.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://youtu.be/autGxyHszc4")
loader=YoutubeLoader.from_youtube_url("https://youtu.be/RwxgHJQwdRk")
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.

0 comments on commit ade2c42

Please sign in to comment.