Spaces:
Build error
Build error
Yvann commited on
Commit ·
1ba6387
1
Parent(s): 1b72b3a
Change sample file more data on fishfry
Browse files- src/chatbot_csv.py +1 -6
- src/csv_agent.py +0 -17
- src/modules/sidebar.py +20 -3
- src/modules/utils.py +1 -1
src/chatbot_csv.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
import os
|
| 2 |
import streamlit as st
|
| 3 |
-
import asyncio
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
from modules.history import ChatHistory
|
| 7 |
from modules.layout import Layout
|
| 8 |
from modules.utils import Utilities
|
| 9 |
from modules.sidebar import Sidebar
|
| 10 |
-
from csv_agent import extra_chatbot_page
|
| 11 |
|
| 12 |
def init():
|
| 13 |
load_dotenv()
|
|
@@ -57,10 +55,7 @@ def main():
|
|
| 57 |
|
| 58 |
except Exception as e:
|
| 59 |
st.error(f"Error: {str(e)}")
|
| 60 |
-
|
| 61 |
-
if st.sidebar.button("Aller au chatbot supplémentaire"):
|
| 62 |
-
st.session_state["extra_chatbot"] = True
|
| 63 |
-
extra_chatbot_page()
|
| 64 |
|
| 65 |
sidebar.about()
|
| 66 |
|
|
|
|
| 1 |
import os
|
| 2 |
import streamlit as st
|
|
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
|
| 5 |
from modules.history import ChatHistory
|
| 6 |
from modules.layout import Layout
|
| 7 |
from modules.utils import Utilities
|
| 8 |
from modules.sidebar import Sidebar
|
|
|
|
| 9 |
|
| 10 |
def init():
|
| 11 |
load_dotenv()
|
|
|
|
| 55 |
|
| 56 |
except Exception as e:
|
| 57 |
st.error(f"Error: {str(e)}")
|
| 58 |
+
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
sidebar.about()
|
| 61 |
|
src/csv_agent.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
from langchain.agents import create_csv_agent
|
| 2 |
-
import streamlit as st
|
| 3 |
-
|
| 4 |
-
from langchain.llms import OpenAI
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
def extra_chatbot_page():
|
| 8 |
-
|
| 9 |
-
query = st.text_input(label="Use CSV agent for precise informations about the csv file itself")
|
| 10 |
-
|
| 11 |
-
if query :
|
| 12 |
-
agent = create_csv_agent(OpenAI(temperature=0), 'poto-associations-sample.csv', verbose=True)
|
| 13 |
-
if agent :
|
| 14 |
-
st.write(agent.run(query))
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/modules/sidebar.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
class Sidebar:
|
| 5 |
MODEL_OPTIONS = ["gpt-3.5-turbo", "gpt-4"]
|
|
@@ -20,6 +21,7 @@ class Sidebar:
|
|
| 20 |
for section in sections:
|
| 21 |
about.write(section)
|
| 22 |
|
|
|
|
| 23 |
@staticmethod
|
| 24 |
def reset_chat_button():
|
| 25 |
if st.button("Reset chat"):
|
|
@@ -39,14 +41,29 @@ class Sidebar:
|
|
| 39 |
step=self.TEMPERATURE_STEP,
|
| 40 |
)
|
| 41 |
st.session_state["temperature"] = temperature
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def show_options(self):
|
| 44 |
-
with st.sidebar.expander("🛠️
|
| 45 |
|
| 46 |
self.reset_chat_button()
|
|
|
|
| 47 |
self.model_selector()
|
| 48 |
self.temperature_slider()
|
| 49 |
st.session_state.setdefault("model", self.MODEL_OPTIONS[0])
|
| 50 |
st.session_state.setdefault("temperature", self.TEMPERATURE_DEFAULT_VALUE)
|
| 51 |
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from langchain.agents import create_csv_agent
|
| 3 |
+
from langchain.chat_models import ChatOpenAI
|
| 4 |
|
| 5 |
class Sidebar:
|
| 6 |
MODEL_OPTIONS = ["gpt-3.5-turbo", "gpt-4"]
|
|
|
|
| 21 |
for section in sections:
|
| 22 |
about.write(section)
|
| 23 |
|
| 24 |
+
|
| 25 |
@staticmethod
|
| 26 |
def reset_chat_button():
|
| 27 |
if st.button("Reset chat"):
|
|
|
|
| 41 |
step=self.TEMPERATURE_STEP,
|
| 42 |
)
|
| 43 |
st.session_state["temperature"] = temperature
|
| 44 |
+
def csv_agent_button(self):
|
| 45 |
+
st.session_state.setdefault("show_csv_agent", False)
|
| 46 |
+
if st.sidebar.button("CSV Agent"):
|
| 47 |
+
st.session_state["show_csv_agent"] = True
|
| 48 |
+
else:
|
| 49 |
+
st.session_state["show_csv_agent"] = False
|
| 50 |
+
|
| 51 |
def show_options(self):
|
| 52 |
+
with st.sidebar.expander("🛠️ Tools", expanded=False):
|
| 53 |
|
| 54 |
self.reset_chat_button()
|
| 55 |
+
self.csv_agent_button()
|
| 56 |
self.model_selector()
|
| 57 |
self.temperature_slider()
|
| 58 |
st.session_state.setdefault("model", self.MODEL_OPTIONS[0])
|
| 59 |
st.session_state.setdefault("temperature", self.TEMPERATURE_DEFAULT_VALUE)
|
| 60 |
|
| 61 |
|
| 62 |
+
""" def csv_agent(self, ):
|
| 63 |
+
# Ajout du bouton pour naviguer vers la page du chatbot supplémentaire
|
| 64 |
+
if csv_agent_button = st.sidebar.button("CSV Agent"):
|
| 65 |
+
query = st.text_input(label="Use CSV agent for precise informations about the csv file itself")
|
| 66 |
+
|
| 67 |
+
if query != "" :
|
| 68 |
+
agent = create_csv_agent(ChatOpenAI(temperature=0), 'poto-associations-sample.csv', verbose=True)
|
| 69 |
+
st.write(agent.run(query))"""
|
src/modules/utils.py
CHANGED
|
@@ -42,7 +42,7 @@ class Utilities:
|
|
| 42 |
else:
|
| 43 |
st.sidebar.info(
|
| 44 |
"👆 Upload your CSV file to get started, "
|
| 45 |
-
"sample for try : [fishfry-locations.csv](https://drive.google.com/file/d/
|
| 46 |
)
|
| 47 |
st.session_state["reset_chat"] = True
|
| 48 |
return uploaded_file
|
|
|
|
| 42 |
else:
|
| 43 |
st.sidebar.info(
|
| 44 |
"👆 Upload your CSV file to get started, "
|
| 45 |
+
"sample for try : [fishfry-locations.csv](https://drive.google.com/file/d/1TpP3thVnTcDO1_lGSh99EKH2iF3GDE7_/view?usp=sharing)"
|
| 46 |
)
|
| 47 |
st.session_state["reset_chat"] = True
|
| 48 |
return uploaded_file
|