Spaces:
Runtime error
Runtime error
changes to app.py
Browse files
app.py
CHANGED
@@ -63,7 +63,7 @@ def process_documents(files, save_location=None):
|
|
63 |
chat_state.document_retrieval.init_retriever(vectorstore)
|
64 |
chat_state.conversation = chat_state.document_retrieval.get_qa_retrieval_chain()
|
65 |
chat_state.input_disabled = False
|
66 |
-
return "
|
67 |
except Exception as e:
|
68 |
return f"An error occurred while processing: {str(e)}"
|
69 |
|
@@ -90,31 +90,33 @@ caution_text = """⚠️ Note: depending on the size of your document, this coul
|
|
90 |
|
91 |
with gr.Blocks() as demo:
|
92 |
#gr.Markdown("# SambaNova Analyst Assistant") # title
|
93 |
-
gr.Markdown("#
|
94 |
elem_id="title")
|
95 |
|
96 |
-
gr.Markdown("Powered by SambaNova Cloud. Get your API key [here](https://cloud.sambanova.ai/apis).")
|
97 |
|
98 |
api_key = gr.Textbox(label="API Key", type="password", placeholder="(Optional) Enter your API key here for more availability")
|
99 |
|
100 |
# Step 1: Add PDF file
|
101 |
-
gr.Markdown("## 1️⃣
|
102 |
-
docs = gr.File(label="Add PDF file", file_types=["pdf"], file_count="single")
|
103 |
|
104 |
# Step 2: Process PDF file
|
105 |
-
gr.Markdown(("## 2️⃣ Process
|
|
|
|
|
106 |
process_btn = gr.Button("🔄 Process")
|
107 |
gr.Markdown(caution_text)
|
108 |
-
|
109 |
|
110 |
process_btn.click(process_documents, inputs=[docs], outputs=setup_output, concurrency_limit=10)
|
111 |
#process_save_btn.click(process_documents, inputs=[file_upload, save_location], outputs=setup_output)
|
112 |
#load_db_btn.click(load_existing_db, inputs=[db_path], outputs=setup_output)
|
113 |
|
114 |
# Step 3: Chat with your data
|
115 |
-
gr.Markdown("## 3️⃣ Chat")
|
116 |
chatbot = gr.Chatbot(label="Chatbot", show_label=True, show_share_button=False, show_copy_button=True, likeable=True)
|
117 |
-
msg = gr.Textbox(label="Ask questions about your data", placeholder="Enter your message...")
|
118 |
clear = gr.Button("Clear chat")
|
119 |
#show_sources = gr.Checkbox(label="Show sources", value=True)
|
120 |
sources_output = gr.Textbox(label="Sources", visible=False)
|
|
|
63 |
chat_state.document_retrieval.init_retriever(vectorstore)
|
64 |
chat_state.conversation = chat_state.document_retrieval.get_qa_retrieval_chain()
|
65 |
chat_state.input_disabled = False
|
66 |
+
return "Complete! You can now ask questions."
|
67 |
except Exception as e:
|
68 |
return f"An error occurred while processing: {str(e)}"
|
69 |
|
|
|
90 |
|
91 |
with gr.Blocks() as demo:
|
92 |
#gr.Markdown("# SambaNova Analyst Assistant") # title
|
93 |
+
gr.Markdown("# Enterprise Knowledge Retriever",
|
94 |
elem_id="title")
|
95 |
|
96 |
+
gr.Markdown("Powered by LLama3.1-8B-Instruct on SambaNova Cloud. Get your API key [here](https://cloud.sambanova.ai/apis).")
|
97 |
|
98 |
api_key = gr.Textbox(label="API Key", type="password", placeholder="(Optional) Enter your API key here for more availability")
|
99 |
|
100 |
# Step 1: Add PDF file
|
101 |
+
gr.Markdown("## 1️⃣ Upload PDF")
|
102 |
+
docs = gr.File(label="Add PDF file (single)", file_types=["pdf"], file_count="single")
|
103 |
|
104 |
# Step 2: Process PDF file
|
105 |
+
gr.Markdown(("## 2️⃣ Process document and create vector store"))
|
106 |
+
db_btn = gr.Radio(["ChromaDB"], label="Vector store type", value = "ChromaDB", type="index", info="Choose your vector store")
|
107 |
+
setup_output = gr.Textbox(label="Processing status", visible=True, value="None")
|
108 |
process_btn = gr.Button("🔄 Process")
|
109 |
gr.Markdown(caution_text)
|
110 |
+
|
111 |
|
112 |
process_btn.click(process_documents, inputs=[docs], outputs=setup_output, concurrency_limit=10)
|
113 |
#process_save_btn.click(process_documents, inputs=[file_upload, save_location], outputs=setup_output)
|
114 |
#load_db_btn.click(load_existing_db, inputs=[db_path], outputs=setup_output)
|
115 |
|
116 |
# Step 3: Chat with your data
|
117 |
+
gr.Markdown("## 3️⃣ Chat with your document")
|
118 |
chatbot = gr.Chatbot(label="Chatbot", show_label=True, show_share_button=False, show_copy_button=True, likeable=True)
|
119 |
+
msg = gr.Textbox(label="Ask questions about your data", show_label=True, placeholder="Enter your message...")
|
120 |
clear = gr.Button("Clear chat")
|
121 |
#show_sources = gr.Checkbox(label="Show sources", value=True)
|
122 |
sources_output = gr.Textbox(label="Sources", visible=False)
|