Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from langchain_helpper import create_embadding_from_csv, get_vector_db, react_agent_chat
|
3 |
+
import pandas as pd
|
4 |
+
from tempfile import NamedTemporaryFile
|
5 |
+
|
6 |
+
st.title('AI Conversational Agent')
|
7 |
+
|
8 |
+
bot_name = st.text_input("Enter the bot's name:", '')
|
9 |
+
|
10 |
+
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
11 |
+
|
12 |
+
if uploaded_file is not None:
|
13 |
+
with NamedTemporaryFile(delete=False) as tmp_file:
|
14 |
+
tmp_file.write(uploaded_file.getvalue())
|
15 |
+
create_embadding_from_csv(tmp_file.name, bot_name)
|
16 |
+
|
17 |
+
|
18 |
+
if bot_name:
|
19 |
+
vec_db = get_vector_db(bot_name)
|
20 |
+
|
21 |
+
user_input = st.text_input("You:", '')
|
22 |
+
if st.button('Send'):
|
23 |
+
if user_input: # Ensure the user has typed something
|
24 |
+
response = react_agent_chat(vec_db, user_input, bot_name)
|
25 |
+
st.text_area("AI:", value=response, height=100, max_chars=None, key="response")
|