MCPcopy
hub / github.com/llmware-ai/llmware / biz_bot_ui_app

Function biz_bot_ui_app

solutions/use_cases/biz_bot.py:267–338  ·  view source on GitHub ↗
(db="postgres", table_name=None, fp=None,doc=None)

Source from the content-addressed store, hash-verified

265
266
267def biz_bot_ui_app (db="postgres", table_name=None, fp=None,doc=None):
268
269 st.title(f"Biz Bot")
270
271 parser_output = None
272
273 if os.path.exists(os.path.join(fp,doc)):
274 if not parser_output:
275 parser_output = Parser().parse_one(fp, doc, save_history=False)
276
277 prompter = load_prompt_model()
278 reranker_model = load_reranker_model()
279 agent = load_agent_model()
280
281 # initialize chat history
282 if "messages" not in st.session_state:
283 st.session_state.messages = []
284
285 # display chat messages from history on app rerun
286 for message in st.session_state.messages:
287 with st.chat_message(message["role"]):
288 st.markdown(message["content"])
289
290 with st.sidebar:
291
292 st.write("Biz Bot")
293 model_type = st.selectbox("Pick your mode", ("RAG","SQL"), index=0)
294
295 uploaded_doc = st.file_uploader("Upload Document")
296 uploaded_table = st.file_uploader("Upload CSV")
297
298 if uploaded_doc:
299 fp = LLMWareConfig().get_llmware_path()
300 doc = uploaded_doc.name
301 f = open(os.path.join(fp,doc), "wb")
302 f.write(uploaded_doc.getvalue())
303 f.close()
304 parser_output = parse_file(fp, doc)
305 st.write(f"Document Parsed and Ready - {len(parser_output)}")
306
307 if uploaded_table:
308 fp = LLMWareConfig().get_llmware_path()
309 tab = uploaded_table.name
310 f = open(os.path.join(fp,tab),"wb")
311 f.write(uploaded_table.getvalue())
312 f.close()
313 table_name = tab.split(".")[0]
314 st.write("Building Table - ", tab, table_name)
315 st.write(st.session_state['loaded_tables'])
316 row_count = build_table(db=db, table_name=table_name, load_fp=fp, load_file=tab)
317 st.write(f"Completed - Table - {table_name} - Rows - {row_count} - is Ready.")
318
319 # accept user input
320 prompt = st.chat_input("Say something")
321 if prompt:
322
323 with st.chat_message("user"):
324 st.markdown(prompt)

Callers 1

biz_bot.pyFile · 0.85

Calls 13

ParserClass · 0.90
LLMWareConfigClass · 0.90
load_prompt_modelFunction · 0.85
load_reranker_modelFunction · 0.85
load_agent_modelFunction · 0.85
parse_fileFunction · 0.85
get_rag_responseFunction · 0.85
get_sql_responseFunction · 0.85
parse_oneMethod · 0.80
writeMethod · 0.80
get_llmware_pathMethod · 0.80
build_tableFunction · 0.70

Tested by

no test coverage detected