Spaces:
Sleeping
Sleeping
Commit
·
932638a
1
Parent(s):
0a4637e
Update app.py
Browse files
app.py
CHANGED
@@ -97,7 +97,8 @@ st.write(f"向量库构建结束:{end_3}")
|
|
97 |
st.write(f"向量库构建耗时:{end_3 - start_3}")
|
98 |
|
99 |
if "directory_path" not in st.session_state:
|
100 |
-
|
|
|
101 |
|
102 |
st.session_state.new_index.storage_context.persist("st.session_state.directory_path")
|
103 |
|
@@ -114,16 +115,14 @@ st.write(f"向量库装载耗时:{end_4 - start_4}")
|
|
114 |
|
115 |
if "query_engine" not in st.session_state:
|
116 |
st.session_state.query_engine = st.session_state.loadedindex.as_query_engine()
|
117 |
-
os.makedirs(st.session_state.directory_path)
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
print("user question: "+st.session_state.user_question)
|
123 |
with st.spinner("AI Thinking...Please wait a while to Cheers!"):
|
124 |
start_5 = timeit.default_timer() # Start timer
|
125 |
st.write(f"Query Engine - AI QA开始:{start_5}")
|
126 |
-
initial_response = st.session_state.query_engine.query(
|
127 |
temp_ai_response=str(initial_response)
|
128 |
final_ai_response=temp_ai_response.partition('<|end|>')[0]
|
129 |
print("AI Response:\n"+final_ai_response)
|
|
|
97 |
st.write(f"向量库构建耗时:{end_3 - start_3}")
|
98 |
|
99 |
if "directory_path" not in st.session_state:
|
100 |
+
st.session_state.directory_path = generate_random_string(20)
|
101 |
+
os.makedirs(st.session_state.directory_path)
|
102 |
|
103 |
st.session_state.new_index.storage_context.persist("st.session_state.directory_path")
|
104 |
|
|
|
115 |
|
116 |
if "query_engine" not in st.session_state:
|
117 |
st.session_state.query_engine = st.session_state.loadedindex.as_query_engine()
|
|
|
118 |
|
119 |
+
user_question = st.text_input("Enter your query:")
|
120 |
+
if user_question !="" and not user_question.strip().isspace() and not user_question == "" and not user_question.strip() == "" and not user_question.isspace():
|
121 |
+
print("user question: "+user_question)
|
|
|
122 |
with st.spinner("AI Thinking...Please wait a while to Cheers!"):
|
123 |
start_5 = timeit.default_timer() # Start timer
|
124 |
st.write(f"Query Engine - AI QA开始:{start_5}")
|
125 |
+
initial_response = st.session_state.query_engine.query(user_question)
|
126 |
temp_ai_response=str(initial_response)
|
127 |
final_ai_response=temp_ai_response.partition('<|end|>')[0]
|
128 |
print("AI Response:\n"+final_ai_response)
|