Spaces:
Runtime error
Runtime error
Commit
Β·
261f709
1
Parent(s):
395b8cd
Update app.py
Browse files
app.py
CHANGED
|
@@ -72,7 +72,6 @@ if load_button:
|
|
| 72 |
#********SIDE BAR Funtionality ended*******
|
| 73 |
|
| 74 |
#Captures User Inputs
|
| 75 |
-
api_key = st.session_state['API_Key'] = st.text_input("Paste in your OPENAI API key?", type="password")
|
| 76 |
prompt = st.text_input('Ask a question about your uploaded website: β',key="prompt") # The box for the text prompt
|
| 77 |
document_count = st.slider('No.Of links to return π - (0 LOW || 5 HIGH)', 0, 5, 2,step=1)
|
| 78 |
|
|
@@ -81,7 +80,7 @@ submit = st.button("Search")
|
|
| 81 |
|
| 82 |
if submit:
|
| 83 |
#Proceed only if API keys are provided
|
| 84 |
-
if st.session_state['Website_URL'] !="" and st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_ENV'] !="" and st.session_state['Pinecone_API_Key']!=""
|
| 85 |
|
| 86 |
|
| 87 |
#Creating embeddings instance
|
|
@@ -106,64 +105,7 @@ if submit:
|
|
| 106 |
st.write("**Info**: "+document.page_content)
|
| 107 |
st.write("**Link**: "+ document.metadata['source'])
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
'''
|
| 112 |
-
q = st.text_input('Ask a question about the content of your file:')
|
| 113 |
-
if q: # if the user entered a question and hit enter
|
| 114 |
-
if 'vs' in st.session_state: # if there's the vector store (user uploaded, split and embedded a file)
|
| 115 |
-
#vector_store = st.session_state.vs
|
| 116 |
-
#Creating embeddings instance
|
| 117 |
-
embeddings=create_embeddings()
|
| 118 |
-
st.write("Embeddings instance creation done...")
|
| 119 |
-
st.write(f'k: {k}')
|
| 120 |
-
answer = ask_and_get_answer(embeddings, q, k)
|
| 121 |
-
|
| 122 |
-
# text area widget for the LLM answer
|
| 123 |
-
st.text_area('LLM Answer: ', value=answer)
|
| 124 |
-
|
| 125 |
-
st.divider()
|
| 126 |
-
|
| 127 |
-
# if there's no chat history in the session state, create it
|
| 128 |
-
if 'history' not in st.session_state:
|
| 129 |
-
st.session_state.history = ''
|
| 130 |
|
| 131 |
-
# the current question and answer
|
| 132 |
-
value = f'Q: {q} \nA: {answer}'
|
| 133 |
-
|
| 134 |
-
st.session_state.history = f'{value} \n {"-" * 100} \n {st.session_state.history}'
|
| 135 |
-
h = st.session_state.history
|
| 136 |
-
|
| 137 |
-
# text area widget for the chat history
|
| 138 |
-
st.text_area(label='Chat History', value=h, key='history', height=400)
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
#Creating embeddings instance
|
| 143 |
-
embeddings=create_embeddings()
|
| 144 |
-
st.write("Embeddings instance creation done...")
|
| 145 |
-
|
| 146 |
-
#Pull index data from Pinecone
|
| 147 |
-
index=pull_from_pinecone(st.session_state['Pinecone_API_Key'],st.session_state['Pinecone_ENV'],st.session_state['Pinecone_Index'],embeddings)
|
| 148 |
-
st.write("Pinecone index retrieval done...")
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
#Fetch relavant documents from Pinecone index
|
| 153 |
-
relavant_docs=get_similar_docs(index,prompt,document_count)
|
| 154 |
-
st.write(relavant_docs)
|
| 155 |
-
|
| 156 |
-
#Displaying search results
|
| 157 |
-
st.success("Please find the search results :")
|
| 158 |
-
#Displaying search results
|
| 159 |
-
st.write("search results list....")
|
| 160 |
-
for document in relavant_docs:
|
| 161 |
-
|
| 162 |
-
st.write("π**Result : "+ str(relavant_docs.index(document)+1)+"**")
|
| 163 |
-
st.write("**Info**: "+document.page_content)
|
| 164 |
-
st.write("**Link**: "+ document.metadata['source'])
|
| 165 |
-
|
| 166 |
-
'''
|
| 167 |
|
| 168 |
else:
|
| 169 |
st.sidebar.error("Ooopssss!!! Please provide API keys.....")
|
|
|
|
| 72 |
#********SIDE BAR Funtionality ended*******
|
| 73 |
|
| 74 |
#Captures User Inputs
|
|
|
|
| 75 |
prompt = st.text_input('Ask a question about your uploaded website: β',key="prompt") # The box for the text prompt
|
| 76 |
document_count = st.slider('No.Of links to return π - (0 LOW || 5 HIGH)', 0, 5, 2,step=1)
|
| 77 |
|
|
|
|
| 80 |
|
| 81 |
if submit:
|
| 82 |
#Proceed only if API keys are provided
|
| 83 |
+
if st.session_state['Website_URL'] !="" and st.session_state['HuggingFace_API_Key'] !="" and st.session_state['Pinecone_ENV'] !="" and st.session_state['Pinecone_API_Key']!="":
|
| 84 |
|
| 85 |
|
| 86 |
#Creating embeddings instance
|
|
|
|
| 105 |
st.write("**Info**: "+document.page_content)
|
| 106 |
st.write("**Link**: "+ document.metadata['source'])
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
else:
|
| 111 |
st.sidebar.error("Ooopssss!!! Please provide API keys.....")
|