Skip to content

Commit

Permalink
tutorial93
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Jun 24, 2024
1 parent 6a0b567 commit 119e67b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
Binary file added tutorial93/Hospital_Report.pdf
Binary file not shown.
36 changes: 36 additions & 0 deletions tutorial93/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from langchain_openai import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain_community.document_loaders import PyPDFLoader
import json


llm=ChatOpenAI(model="gpt-4o")
loader=PyPDFLoader(r"C:\Users\welcome\OneDrive\Documents\GitHub\LLMtutorial\tutorial93\Hospital_Report.pdf")
docs=loader.load()
template="""
you are an intelliegnt bot who can analyze any text with hospital information{doc_text} ,
your job is to read and analyse the information and create a json dictionary.
dictionary has the followinmg key:
Hospital Name
Address
City
State
Zip Code
Contact Number
Email Address
Website
output must be json nothing else
"""
prompt=PromptTemplate(template=template,input_variables=["doc_text"])
llmchain=LLMChain(llm=llm,prompt=prompt)
for doc in docs:
text=doc.page_content
response=llmchain.invoke({"doc_text":text})
data=response["text"]
data=data.replace("json","")
data=data.replace("`","")
data=json.loads(data)
print(data)

13 changes: 13 additions & 0 deletions tutorial93/prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
you are an intelliegnt bot who can analyze any text with hospital information{doc_text} ,
your job is to read and analyse the information and create a json dictionary.
dictionary has the followinmg key:
Hospital Name
Address
City
State
Zip Code
Contact Number
Email Address
Website

output must be json nothing else
Binary file added tutorial93/tutorial93.pptx
Binary file not shown.

0 comments on commit 119e67b

Please sign in to comment.