Spaces:
Sleeping
Sleeping
Update pages/AI_Chatbot.py
Browse files- pages/AI_Chatbot.py +4 -6
pages/AI_Chatbot.py
CHANGED
|
@@ -4,7 +4,7 @@ import streamlit as st
|
|
| 4 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 5 |
from langchain.document_loaders import PyPDFLoader
|
| 6 |
|
| 7 |
-
st.title("
|
| 8 |
|
| 9 |
uploaded_file = st.file_uploader("Choose a file")
|
| 10 |
def extract(uploaded_file):
|
|
@@ -15,8 +15,8 @@ def extract(uploaded_file):
|
|
| 15 |
res.append(i.page_content.replace('\n',''))
|
| 16 |
a = " ".join(res)
|
| 17 |
return a
|
| 18 |
-
|
| 19 |
-
|
| 20 |
docs = Document(page_content=context)
|
| 21 |
index2 = VectorstoreIndexCreator().from_documents([docs])
|
| 22 |
answer = index2.query(llm = model, question = ques)
|
|
@@ -25,11 +25,9 @@ def lang(ques):
|
|
| 25 |
def qna(uploaded_file,ques):
|
| 26 |
session_state['answer']= lang(jury_url)
|
| 27 |
|
| 28 |
-
st.title("Jury Records")
|
| 29 |
-
|
| 30 |
ques= st.text_area(label= "Please enter the Question that you wanna ask.",
|
| 31 |
placeholder="Question")
|
| 32 |
|
| 33 |
st.text_area("result", value=session_state['answer'])
|
| 34 |
|
| 35 |
-
st.button("Get answer dictionary", on_click=qna, args=[ques])
|
|
|
|
| 4 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 5 |
from langchain.document_loaders import PyPDFLoader
|
| 6 |
|
| 7 |
+
st.title("Chat with data")
|
| 8 |
|
| 9 |
uploaded_file = st.file_uploader("Choose a file")
|
| 10 |
def extract(uploaded_file):
|
|
|
|
| 15 |
res.append(i.page_content.replace('\n',''))
|
| 16 |
a = " ".join(res)
|
| 17 |
return a
|
| 18 |
+
def lang(uploaded_file,ques):
|
| 19 |
+
context = extract(uploaded_file)
|
| 20 |
docs = Document(page_content=context)
|
| 21 |
index2 = VectorstoreIndexCreator().from_documents([docs])
|
| 22 |
answer = index2.query(llm = model, question = ques)
|
|
|
|
| 25 |
def qna(uploaded_file,ques):
|
| 26 |
session_state['answer']= lang(jury_url)
|
| 27 |
|
|
|
|
|
|
|
| 28 |
ques= st.text_area(label= "Please enter the Question that you wanna ask.",
|
| 29 |
placeholder="Question")
|
| 30 |
|
| 31 |
st.text_area("result", value=session_state['answer'])
|
| 32 |
|
| 33 |
+
st.button("Get answer dictionary", on_click=qna, args=[uploaded_file,ques])
|