Spaces:
Runtime error
Runtime error
Update pages/jarvis.py
Browse files- pages/jarvis.py +21 -13
pages/jarvis.py
CHANGED
@@ -77,24 +77,32 @@ def main():
|
|
77 |
chunk_size = st.slider("Chunk size", min_value=100, max_value=1000, value=600, step=20)
|
78 |
chunk_overlap = st.slider("Chunk overlap", min_value=10, max_value=200, value=40, step=10)
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
collection_name = create_collection_name(list_file_path[0])
|
83 |
-
doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
|
84 |
-
vector_db = create_db(doc_splits, collection_name)
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
90 |
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
93 |
|
94 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
message = st.text_input("Type your message")
|
96 |
if st.button("Submit"):
|
97 |
-
response = qa_chain({"question": message, "chat_history": []})
|
98 |
st.write("Assistant:", response["answer"])
|
99 |
|
100 |
if __name__ == "__main__":
|
|
|
77 |
chunk_size = st.slider("Chunk size", min_value=100, max_value=1000, value=600, step=20)
|
78 |
chunk_overlap = st.slider("Chunk overlap", min_value=10, max_value=200, value=40, step=10)
|
79 |
|
80 |
+
tabs = ["Process Document", "Initialize QA Chain", "Chatbot"]
|
81 |
+
selected_tab = st.radio("Select Tab", tabs)
|
|
|
|
|
|
|
82 |
|
83 |
+
if selected_tab == "Process Document":
|
84 |
+
if st.button("Generate Vector Database"):
|
85 |
+
list_file_path = [file.name for file in uploaded_files]
|
86 |
+
collection_name = create_collection_name(list_file_path[0])
|
87 |
+
doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
|
88 |
+
vector_db = create_db(doc_splits, collection_name)
|
89 |
|
90 |
+
elif selected_tab == "Initialize QA Chain":
|
91 |
+
if "vector_db" in st.session_state:
|
92 |
+
temperature = st.slider("Temperature", min_value=0.01, max_value=1.0, value=0.7, step=0.1)
|
93 |
+
max_tokens = st.slider("Max Tokens", min_value=224, max_value=4096, value=1024, step=32)
|
94 |
+
top_k = st.slider("Top-K Samples", min_value=1, max_value=10, value=3, step=1)
|
95 |
|
96 |
+
llm_model = st.selectbox("Choose LLM Model", list_llm)
|
97 |
+
|
98 |
+
if st.button("Initialize QA Chain"):
|
99 |
+
qa_chain = initialize_llmchain(llm_model, temperature, max_tokens, top_k, st.session_state["vector_db"])
|
100 |
+
|
101 |
+
elif selected_tab == "Chatbot":
|
102 |
+
if "qa_chain" in st.session_state:
|
103 |
message = st.text_input("Type your message")
|
104 |
if st.button("Submit"):
|
105 |
+
response = st.session_state["qa_chain"]({"question": message, "chat_history": []})
|
106 |
st.write("Assistant:", response["answer"])
|
107 |
|
108 |
if __name__ == "__main__":
|