Spaces:
Runtime error
Runtime error
Zwea Htet
commited on
Commit
•
91caeb5
1
Parent(s):
402c1d3
fixed authentication
Browse files
app.py
CHANGED
@@ -14,7 +14,10 @@ st.header("Powered by `LlamaIndex🦙` and `OpenAI API`")
|
|
14 |
if "messages" not in st.session_state:
|
15 |
st.session_state.messages = []
|
16 |
|
|
|
|
|
17 |
api_key = st.text_input("Enter your OpenAI API key here:", type="password")
|
|
|
18 |
if api_key:
|
19 |
resp = validate(api_key)
|
20 |
if "error" in resp.json():
|
@@ -26,15 +29,16 @@ if api_key:
|
|
26 |
index = create_index(bloom)
|
27 |
|
28 |
st.write("---")
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
if
|
33 |
-
st.
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
38 |
|
39 |
# Display previous messages
|
40 |
msg_key = 0
|
|
|
14 |
if "messages" not in st.session_state:
|
15 |
st.session_state.messages = []
|
16 |
|
17 |
+
index = None
|
18 |
+
|
19 |
api_key = st.text_input("Enter your OpenAI API key here:", type="password")
|
20 |
+
|
21 |
if api_key:
|
22 |
resp = validate(api_key)
|
23 |
if "error" in resp.json():
|
|
|
29 |
index = create_index(bloom)
|
30 |
|
31 |
st.write("---")
|
32 |
+
if index:
|
33 |
+
input_text = st.text_area("Ask your question")
|
34 |
+
|
35 |
+
if input_text:
|
36 |
+
if st.button("Ask"):
|
37 |
+
st.session_state.messages.append(("User", input_text))
|
38 |
+
with st.spinner("Processing your query..."):
|
39 |
+
bot_response = get_response(index, input_text)
|
40 |
+
print("bot: ", bot_response)
|
41 |
+
st.session_state.messages.append(("Bot", bot_response))
|
42 |
|
43 |
# Display previous messages
|
44 |
msg_key = 0
|