Spaces:
Build error
Build error
Yvann commited on
Commit ·
6ddae11
1
Parent(s): 61747c2
delete unuseful comments
Browse files- src/chatbot_csv.py +3 -13
src/chatbot_csv.py
CHANGED
|
@@ -63,32 +63,22 @@ def main():
|
|
| 63 |
if st.session_state["show_csv_agent"]:
|
| 64 |
query = st.text_input(label="Use CSV agent for precise information about the structure of your csv file")
|
| 65 |
if query != "":
|
| 66 |
-
|
| 67 |
-
# Redirigez temporairement la sortie standard vers un objet StringIO
|
| 68 |
old_stdout = sys.stdout
|
| 69 |
sys.stdout = captured_output = StringIO()
|
| 70 |
-
|
| 71 |
-
# Exécutez create_csv_agent et capturez la sortie
|
| 72 |
agent = create_csv_agent(ChatOpenAI(temperature=0), uploaded_file_content, verbose=True, max_iterations=4)
|
| 73 |
|
| 74 |
-
# Exécutez la méthode agent.run(query) et capturez la sortie
|
| 75 |
result = agent.run(query)
|
| 76 |
|
| 77 |
-
# Restaurez la sortie standard
|
| 78 |
sys.stdout = old_stdout
|
| 79 |
-
|
| 80 |
-
# Récupérez les pensées capturées
|
| 81 |
thoughts = captured_output.getvalue()
|
| 82 |
|
| 83 |
-
|
| 84 |
-
cleaned_thoughts = re.sub(r'\
|
| 85 |
-
cleaned_thoughts = re.sub(r'\[1m>', '', cleaned_thoughts) # Supprime les parties indésirables comme '[1m>'
|
| 86 |
|
| 87 |
-
# Affichez les pensées nettoyées dans un expander
|
| 88 |
with st.expander("Afficher les pensées de l'agent"):
|
| 89 |
st.write(cleaned_thoughts)
|
| 90 |
|
| 91 |
-
# Affichez le résultat de create_csv_agent
|
| 92 |
st.write(result)
|
| 93 |
|
| 94 |
except Exception as e:
|
|
|
|
| 63 |
if st.session_state["show_csv_agent"]:
|
| 64 |
query = st.text_input(label="Use CSV agent for precise information about the structure of your csv file")
|
| 65 |
if query != "":
|
| 66 |
+
|
|
|
|
| 67 |
old_stdout = sys.stdout
|
| 68 |
sys.stdout = captured_output = StringIO()
|
|
|
|
|
|
|
| 69 |
agent = create_csv_agent(ChatOpenAI(temperature=0), uploaded_file_content, verbose=True, max_iterations=4)
|
| 70 |
|
|
|
|
| 71 |
result = agent.run(query)
|
| 72 |
|
|
|
|
| 73 |
sys.stdout = old_stdout
|
|
|
|
|
|
|
| 74 |
thoughts = captured_output.getvalue()
|
| 75 |
|
| 76 |
+
cleaned_thoughts = re.sub(r'\x1b\[[0-9;]*[a-zA-Z]', '', thoughts)
|
| 77 |
+
cleaned_thoughts = re.sub(r'\[1m>', '', cleaned_thoughts)
|
|
|
|
| 78 |
|
|
|
|
| 79 |
with st.expander("Afficher les pensées de l'agent"):
|
| 80 |
st.write(cleaned_thoughts)
|
| 81 |
|
|
|
|
| 82 |
st.write(result)
|
| 83 |
|
| 84 |
except Exception as e:
|