-
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
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
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,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) | ||
|
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,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 not shown.