-
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
17 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-23.1 MB
...205655-AWS-certified-devops-engineer-professional-certification-and-Beyond-1801074453.pdf
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,16 @@ | ||
from langchain_community.document_loaders import PyPDFLoader | ||
from langchain.text_splitter import RecursiveCharacterTextSplitter | ||
from langchain.vectorstores import Chroma | ||
from langchain_openai import OpenAIEmbeddings | ||
import os | ||
|
||
loader=PyPDFLoader("vedas.pdf") | ||
docs=loader.load() | ||
text_splitter=RecursiveCharacterTextSplitter(chunk_size=1000,chunk_overlap=50) | ||
chunked_documents=text_splitter.split_documents(docs) | ||
vectordb=Chroma.from_documents( | ||
documents=chunked_documents, | ||
embedding=OpenAIEmbeddings(), | ||
persist_directory=os.getcwd()+"/vector_index" | ||
) | ||
vectordb.persist() |
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,19 @@ | ||
""" | ||
You are very smart AI assistant who is very good in explaining and expressing answer for anything asked by the user | ||
user will ask question as {question} | ||
you must give answer with detailed explanation with bullets, heading , subheading etc. based on the {context} only | ||
always rename the title ,headings, subheaing in your answer but keep the meaning same. | ||
you must follow this very stricty , dont use anything else other than the given {context} | ||
if no related information found from the {context} just reply with "I dont know", this is very important | ||
answer: | ||
""" | ||
|
||
|
||
""" | ||
You are very smart AI assistant who is very good in explaining and expressing answer for anything asked by the user | ||
user will ask question as {question} | ||
you must give answer with detailed explanation based on the {context} only | ||
you must follow this very stricty , dont use anything else other than the given {context} | ||
if no related information found from the {context} just reply with "I dont know", this is very important | ||
answer: | ||
""" |
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,37 @@ | ||
from langchain_community.vectorstores import Chroma | ||
from langchain_openai import ChatOpenAI,OpenAIEmbeddings | ||
from langchain.chains import LLMChain | ||
from langchain.prompts import PromptTemplate | ||
import streamlit as st | ||
import os | ||
st.title("TALK TO ME") | ||
st.write("promting example with rag") | ||
|
||
vectordb=Chroma(persist_directory=os.getcwd()+"/vector_index",embedding_function=OpenAIEmbeddings()) | ||
prompt_template=""" | ||
You are very smart AI assistant who is very good in explaining and expressing answer for anything asked by the user | ||
user will ask question as {question} | ||
you must give answer with detailed explanation with bullets, heading , subheading etc. based on the {context} only | ||
always rewrite the title ,headings, subheading in your ,try to avoid section numbers chapter numbers in the title or heading dont keep the same as the given in the {context} but keep the meaning same. | ||
you must follow this very stricty , dont use anything else other than the given {context} | ||
if no related information found from the {context} just reply with "I dont know", this is very important | ||
answer: | ||
answer: | ||
""" | ||
llm=ChatOpenAI(model="gpt-4-turbo",max_tokens=1024) | ||
qa_chain=LLMChain(llm=llm,prompt=PromptTemplate.from_template(prompt_template)) | ||
question=st.text_area("ask your question") | ||
|
||
if question is not None: | ||
button=st.button("submit") | ||
if button: | ||
rd=vectordb.similarity_search(question,k=12) | ||
context="" | ||
for d in rd: | ||
context +=d.page_content | ||
response=qa_chain.invoke({"question":question,"context":context}) | ||
result=response["text"] | ||
st.write(result) | ||
|
||
|
||
|
Binary file not shown.
Binary file added
BIN
+5.99 MB
tutorial60/vector_index/1a295913-4835-460d-bf9b-619c1dfea5aa/data_level0.bin
Binary file not shown.
Binary file added
BIN
+100 Bytes
tutorial60/vector_index/1a295913-4835-460d-bf9b-619c1dfea5aa/header.bin
Binary file not shown.
Binary file added
BIN
+3.91 KB
tutorial60/vector_index/1a295913-4835-460d-bf9b-619c1dfea5aa/length.bin
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
File renamed without changes.