import streamlit as st from langchain_helpper import create_embadding_from_csv, get_vector_db, react_agent_chat import pandas as pd from tempfile import NamedTemporaryFile st.title('AI Conversational Agent') bot_name = st.text_input("Enter the bot's name:", '') uploaded_file = st.file_uploader("Choose a CSV file", type="csv") if uploaded_file is not None: with NamedTemporaryFile(delete=False) as tmp_file: tmp_file.write(uploaded_file.getvalue()) create_embadding_from_csv(tmp_file.name, bot_name) if bot_name: vec_db = get_vector_db(bot_name) user_input = st.text_input("You:", '') if st.button('Send'): if user_input: # Ensure the user has typed something response = react_agent_chat(vec_db, user_input, bot_name) st.text_area("AI:", value=response, height=100, max_chars=None, key="response")