YashB1 commited on
Commit
25414e5
·
verified ·
1 Parent(s): 071b823

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +241 -70
app.py CHANGED
@@ -1,4 +1,200 @@
1
- import superimport
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import streamlit as st
3
  import os
4
  import pandas as pd
@@ -28,7 +224,10 @@ st.write(
28
 
29
  # Displaying the centered title
30
  st.markdown("<h2 class='title'>VayuBuddy</h2>", unsafe_allow_html=True)
 
31
 
 
 
32
  # os.environ["PANDASAI_API_KEY"] = "$2a$10$gbmqKotzJOnqa7iYOun8eO50TxMD/6Zw1pLI2JEoqncwsNx4XeBS2"
33
 
34
  # with open(join(self_path, "context1.txt")) as f:
@@ -44,20 +243,19 @@ model_name = st.sidebar.selectbox("Select LLM:", ["llama3","mixtral", "gemma"])
44
 
45
  questions = ('Custom Prompt',
46
  'Plot the monthly average PM2.5 for the year 2023.',
47
- 'Which month has the highest average PM2.5 overall?',
48
- 'Which month has the highest PM2.5 overall?',
49
  'Which month has the highest average PM2.5 in 2023 for Mumbai?',
50
  'Plot and compare monthly timeseries of pollution for Mumbai and Bengaluru.',
51
  'Plot the yearly average PM2.5.',
52
  'Plot the monthly average PM2.5 of Delhi, Mumbai and Bengaluru for the year 2022.',
53
  'Which month has the highest pollution?',
54
- 'Plot the monthly average PM2.5 of Delhi for the year 2022.',
55
  'Which city has the highest PM2.5 level in July 2022?',
56
  'Plot and compare monthly timeseries of PM2.5 for Mumbai and Bengaluru.',
57
  'Plot and compare the monthly average PM2.5 of Delhi, Mumbai and Bengaluru for the year 2022.',
58
  'Plot the monthly average PM2.5.',
59
  'Plot the monthly average PM10 for the year 2023.',
60
- 'Which month has the highest PM2.5?',
61
  'Plot the monthly average PM2.5 of Delhi for the year 2022.',
62
  'Plot the monthly average PM2.5 of Bengaluru for the year 2022.',
63
  'Plot the monthly average PM2.5 of Mumbai for the year 2022.',
@@ -105,8 +303,9 @@ if prompt := st.sidebar.selectbox("Select a Prompt:", questions):
105
  # select random waiting line
106
  with st.spinner(random.choice(waiting_lines)):
107
  ran = False
108
- for i in range(5):
109
- llm = ChatGroq(model=models[model_name], api_key=os.getenv("GROQ_API"), temperature=0.1)
 
110
 
111
  df_check = pd.read_csv("Data.csv")
112
  df_check["Timestamp"] = pd.to_datetime(df_check["Timestamp"])
@@ -114,62 +313,19 @@ if prompt := st.sidebar.selectbox("Select a Prompt:", questions):
114
 
115
  new_line = "\n"
116
 
117
- parameters = {"font.size": 18}
118
 
119
  template = f"""```python
120
  import pandas as pd
121
  import matplotlib.pyplot as plt
122
 
123
- plt.rcParams.update({parameters})
124
 
125
  df = pd.read_csv("Data.csv")
126
  df["Timestamp"] = pd.to_datetime(df["Timestamp"])
127
 
128
- def calculator(Pollutant, concentration):
129
- Calculator_index = Pollutant
130
- breakpoints_low = {{
131
- "O3": [0, 50, 100, 168, 208, 748],
132
- "PM2.5": [0, 30, 60, 90, 120, 250],
133
- "PM10": [0, 50, 100, 250, 350, 430],
134
- "CO": [0, 1000, 2000, 10000, 17000, 34000],
135
- "SO2": [0, 40, 80, 380, 800, 1600],
136
- "NO2": [0, 40, 80, 180, 280, 400]
137
- }}
138
-
139
- breakpoints_high = {{
140
- "O3": [50, 100, 168, 208, 748,1000],
141
- "PM2.5": [30, 60, 90, 120, 250,1000],
142
- "PM10": [50, 100, 250, 350, 430,1000],
143
- "CO": [1000, 2000, 10000, 17000, 34000,50000],
144
- "SO2": [40, 80, 380, 800, 1600,2000],
145
- "NO2": [ 40, 80, 180, 280, 400,1000]
146
- }}
147
- # Define corresponding AQI categories
148
- categories_low= [0, 50, 100, 200, 300, 400]
149
- categories_high = [50, 100, 200, 300, 400,500]
150
-
151
- # Find the appropriate AQI category based on concentration
152
-
153
- for i in range(len(breakpoints_high[Calculator_index])):
154
- if concentration <= breakpoints_high[Calculator_index][i]:
155
- BPHI = breakpoints_high[Calculator_index][i]
156
- IHI = categories_high[i]
157
- # Calculate AQI using India formula
158
- #AQI = ((categories[i] - categories[i-1]) / (breakpoints[Calculator_index][i] - breakpoints[Calculator_index][i-1])) * (concentration - breakpoints[Calculator_index][i-1]) + categories[i-1]
159
- #st.sidebar.write(f"The Air Quality Index (AQI) for {{Calculator_index}} is: {{AQI}}")
160
- break
161
-
162
- for i in range(len(breakpoints_low[Calculator_index])):
163
- if concentration >= breakpoints_low[Calculator_index][i]:
164
- BPLI = breakpoints_low[Calculator_index][i]
165
- ILI = categories_low[i]
166
- # Calculate AQI using India formula
167
- #AQI = ((categories[i] - categories[i-1]) / (breakpoints[Calculator_index][i] - breakpoints[Calculator_index][i-1])) * (concentration - breakpoints[Calculator_index][i-1]) + categories[i-1]
168
- #st.sidebar.write(f"The Air Quality Index (AQI) for {{Calculator_index}} is: {{AQI}}")
169
- break
170
-
171
- AQI = ((IHI - ILI) / (BPHI - BPLI)) * (round(concentration) - BPLI) + ILI
172
- return AQI
173
 
174
  # df.dtypes
175
  {new_line.join(map(lambda x: '# '+x, str(df_check.dtypes).split(new_line)))}
@@ -180,16 +336,21 @@ def calculator(Pollutant, concentration):
180
  """
181
 
182
  query = f"""I have a pandas dataframe data of PM2.5 and PM10.
 
183
  * Frequency of data is daily.
184
  * `pollution` generally means `PM2.5`.
185
  * You already have df, so don't read the csv file
186
- * Don't print, but save result in a variable `answer` and make it global.
187
  * Unless explicitly mentioned, don't consider the result as a plot.
188
  * PM2.5 guidelines: India: 60, WHO: 15.
189
  * PM10 guidelines: India: 100, WHO: 50.
190
  * If result is a plot, show the India and WHO guidelines in the plot.
191
  * If result is a plot make it in tight layout, save it and save path in `answer`. Example: `answer='plot.png'`
 
192
  * If result is not a plot, save it as a string in `answer`. Example: `answer='The city is Mumbai'`
 
 
 
193
  * Whenever you do any sort of aggregation, report the corresponding standard deviation, standard error and the number of data points for that aggregation.
194
  * Whenever you're reporting a floating point number, round it to 2 decimal places.
195
  * Always report the unit of the data. Example: `The average PM2.5 is 45.67 µg/m³`
@@ -199,21 +360,27 @@ def calculator(Pollutant, concentration):
199
  {template}
200
 
201
  """
202
-
203
- answer = llm.invoke(query)
204
- code = f"""
205
- {template.split("```python")[1].split("```")[0]}
206
- {answer.content.split("```python")[1].split("```")[0]}
207
- """
208
- # update variable `answer` when code is executed
209
  try:
 
 
 
 
 
 
210
  exec(code)
211
  ran = True
212
  no_response = False
213
  except Exception as e:
214
  no_response = True
215
  exception = e
216
-
 
 
 
 
 
217
  response = {"role": "assistant", "content": answer, "gen_code": code, "ex_code": code, "last_prompt": prompt, "no_response": no_response}
218
 
219
  # Get response from agent
@@ -221,15 +388,19 @@ def calculator(Pollutant, concentration):
221
  # response = ask_agent(agent, prompt)
222
 
223
  if ran:
224
- break
225
 
 
 
 
 
 
 
 
226
  if no_response:
 
227
  st.error(f"Failed to generate right output due to the following error:\n\n{exception}")
228
- # Add agent response to chat history
229
- st.session_state.responses.append(response)
230
 
231
- # Display agent response
232
- if not no_response:
233
- show_response(st, response)
234
 
235
- del prompt
 
1
+ # import streamlit as st
2
+ # import os
3
+ # import pandas as pd
4
+ # import random
5
+ # from os.path import join
6
+ # from src import preprocess_and_load_df, load_agent, ask_agent, decorate_with_code, show_response, get_from_user, load_smart_df, ask_question
7
+ # from dotenv import load_dotenv
8
+ # from langchain_groq.chat_models import ChatGroq
9
+
10
+ # load_dotenv("Groq.txt")
11
+ # Groq_Token = os.environ["GROQ_API_KEY"]
12
+ # models = {"llama3":"llama3-70b-8192","mixtral": "mixtral-8x7b-32768", "llama2": "llama2-70b-4096", "gemma": "gemma-7b-it"}
13
+
14
+ # self_path = os.path.dirname(os.path.abspath(__file__))
15
+
16
+ # # Using HTML and CSS to center the title
17
+ # st.write(
18
+ # """
19
+ # <style>
20
+ # .title {
21
+ # text-align: center;
22
+ # color: #17becf;
23
+ # }
24
+ # """,
25
+ # unsafe_allow_html=True,
26
+ # )
27
+
28
+ # # Displaying the centered title
29
+ # st.markdown("<h2 class='title'>VayuBuddy</h2>", unsafe_allow_html=True)
30
+
31
+ # # os.environ["PANDASAI_API_KEY"] = "$2a$10$gbmqKotzJOnqa7iYOun8eO50TxMD/6Zw1pLI2JEoqncwsNx4XeBS2"
32
+
33
+ # # with open(join(self_path, "context1.txt")) as f:
34
+ # # context = f.read().strip()
35
+
36
+ # # agent = load_agent(join(self_path, "app_trial_1.csv"), context)
37
+ # # df = preprocess_and_load_df(join(self_path, "Data.csv"))
38
+ # # inference_server = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2"
39
+ # # inference_server = "https://api-inference.huggingface.co/models/codellama/CodeLlama-13b-hf"
40
+ # # inference_server = "https://api-inference.huggingface.co/models/pandasai/bamboo-llm"
41
+
42
+ # model_name = st.sidebar.selectbox("Select LLM:", ["llama3","mixtral", "llama2", "gemma"])
43
+
44
+
45
+
46
+
47
+
48
+ # questions = ('Custom Prompt',
49
+ # 'Plot the monthly average PM2.5 for the year 2023.',
50
+ # 'Which month has the highest average PM2.5 overall?',
51
+ # 'Which month has the highest PM2.5 overall?',
52
+ # 'Which month has the highest average PM2.5 in 2023 for Mumbai?',
53
+ # 'Plot and compare monthly timeseries of pollution for Mumbai and Bengaluru.',
54
+ # 'Plot the yearly average PM2.5.',
55
+ # 'Plot the monthly average PM2.5 of Delhi',
56
+ # 'Mumbai and Bengaluru for the year 2022.',
57
+ # 'Which month has the highest pollution?',
58
+ # 'Plot the monthly average PM2.5 of Delhi for the year 2022.',
59
+ # 'Which city has the highest PM2.5 level in July 2022?',
60
+ # 'Plot and compare monthly timeseries of PM2.5 for Mumbai and Bengaluru.',
61
+ # 'Plot and compare the monthly average PM2.5 of Delhi, Mumbai and Bengaluru for the year 2022.',
62
+ # 'Plot the monthly average PM2.5.',
63
+ # 'Plot the monthly average PM10 for the year 2023.',
64
+ # 'Which month has the highest PM2.5?',
65
+ # 'Plot the monthly average PM2.5 of Delhi for the year 2022.',
66
+ # 'Plot the monthly average PM2.5 of Bengaluru for the year 2022.',
67
+ # 'Plot the monthly average PM2.5 of Mumbai for the year 2022.',
68
+ # 'Which state has the highest average PM2.5?',
69
+ # 'Plot monthly PM2.5 in Gujarat for 2023.',
70
+ # 'What is the name of the month with the highest average PM2.5 overall?')
71
+
72
+ # waiting_lines = ("Thinking...", "Just a moment...", "Let me think...", "Working on it...", "Processing...", "Hold on...", "One moment...", "On it...")
73
+
74
+ # # agent = load_agent(df, context="", inference_server=inference_server, name=model_name)
75
+
76
+ # # Initialize chat history
77
+ # if "responses" not in st.session_state:
78
+ # st.session_state.responses = []
79
+
80
+ # # Display chat responses from history on app rerun
81
+ # for response in st.session_state.responses:
82
+ # if not response["no_response"]:
83
+ # show_response(st, response)
84
+
85
+ # show = True
86
+
87
+ # prompt = st.sidebar.selectbox("Select a Prompt:", questions)
88
+
89
+ # # add a note "select custom prompt to ask your own question"
90
+
91
+
92
+ # if prompt == 'Custom Prompt':
93
+ # show = False
94
+ # # React to user input
95
+ # prompt = st.chat_input("Ask me anything about air quality!", key=10)
96
+ # if prompt:
97
+ # show = True
98
+
99
+
100
+ # if show:
101
+
102
+ # # Add user input to chat history
103
+ # response = get_from_user(prompt)
104
+ # response["no_response"] = False
105
+ # st.session_state.responses.append(response)
106
+
107
+ # # Display user input
108
+ # show_response(st, response)
109
+
110
+ # no_response = False
111
+
112
+ # # select random waiting line
113
+ # with st.spinner(random.choice(waiting_lines)):
114
+ # ran = False
115
+ # for i in range(5):
116
+ # llm = ChatGroq(model=models[model_name], api_key=os.getenv("GROQ_API"), temperature=0.1)
117
+
118
+ # df_check = pd.read_csv("Data.csv")
119
+ # df_check["Timestamp"] = pd.to_datetime(df_check["Timestamp"])
120
+ # df_check = df_check.head(5)
121
+
122
+ # new_line = "\n"
123
+
124
+ # template = f"""```python
125
+ # import pandas as pd
126
+ # import matplotlib.pyplot as plt
127
+
128
+ # df = pd.read_csv("Data.csv")
129
+ # df["Timestamp"] = pd.to_datetime(df["Timestamp"])
130
+
131
+ # # df.dtypes
132
+ # {new_line.join(map(lambda x: '# '+x, str(df_check.dtypes).split(new_line)))}
133
+
134
+ # # {prompt.strip()}
135
+ # # <your code here>
136
+ # ```
137
+ # """
138
+
139
+ # query = f"""I have a pandas dataframe data of PM2.5 and PM10.
140
+ # * Frequency of data is daily.
141
+ # * `pollution` generally means `PM2.5`.
142
+ # * You already have df, so don't read the csv file
143
+ # * Don't print, but save result in a variable `answer` and make it global.
144
+ # * Unless explicitly mentioned, don't consider the result as a plot.
145
+ # * PM2.5 guidelines: India: 60, WHO: 15.
146
+ # * PM10 guidelines: India: 100, WHO: 50.
147
+ # * If result is a plot, show the India and WHO guidelines in the plot.
148
+ # * If result is a plot make it in tight layout, save it and save path in `answer`. Example: `answer='plot.png'`
149
+ # * If result is a plot, rotate x-axis tick labels by 45 degrees,
150
+ # * If result is not a plot, save it as a string in `answer`. Example: `answer='The city is Mumbai'`
151
+ # * Whenever you do any sort of aggregation, report the corresponding standard deviation, standard error and the number of data points for that aggregation.
152
+ # * Whenever you're reporting a floating point number, round it to 2 decimal places.
153
+ # * Always report the unit of the data. Example: `The average PM2.5 is 45.67 µg/m³`
154
+
155
+
156
+ # Complete the following code.
157
+
158
+ # {template}
159
+
160
+ # """
161
+
162
+ # answer = llm.invoke(query)
163
+ # code = f"""
164
+ # {template.split("```python")[1].split("```")[0]}
165
+ # {answer.content.split("```python")[1].split("```")[0]}
166
+ # """
167
+ # # update variable `answer` when code is executed
168
+ # try:
169
+ # exec(code)
170
+ # ran = True
171
+ # no_response = False
172
+ # except Exception as e:
173
+ # no_response = True
174
+ # exception = e
175
+
176
+ # response = {"role": "assistant", "content": answer, "gen_code": code, "ex_code": code, "last_prompt": prompt, "no_response": no_response}
177
+
178
+ # # Get response from agent
179
+ # # response = ask_question(model_name=model_name, question=prompt)
180
+ # # response = ask_agent(agent, prompt)
181
+
182
+ # if ran:
183
+ # break
184
+
185
+ # if no_response:
186
+ # st.error(f"Failed to generate right output due to the following error:\n\n{exception}")
187
+ # # Add agent response to chat history
188
+ # st.session_state.responses.append(response)
189
+
190
+ # # Display agent response
191
+ # if not no_response:
192
+ # show_response(st, response)
193
+
194
+ # del prompt
195
+
196
+
197
+
198
  import streamlit as st
199
  import os
200
  import pandas as pd
 
224
 
225
  # Displaying the centered title
226
  st.markdown("<h2 class='title'>VayuBuddy</h2>", unsafe_allow_html=True)
227
+ st.markdown("<div style='text-align:center; padding: 20px;'>VayuBuddy makes pollution monitoring easier by bridging the gap between users and datasets.<br>No coding required—just meaningful insights at your fingertips!</div>", unsafe_allow_html=True)
228
 
229
+ # Center-aligned instruction text with bold formatting
230
+ st.markdown("<div style='text-align:center;'>Choose a query from <b>Select a prompt</b> or type a query in the <b>chat box</b>, select a <b>LLM</b> (Large Language Model), and press enter to generate a response.</div>", unsafe_allow_html=True)
231
  # os.environ["PANDASAI_API_KEY"] = "$2a$10$gbmqKotzJOnqa7iYOun8eO50TxMD/6Zw1pLI2JEoqncwsNx4XeBS2"
232
 
233
  # with open(join(self_path, "context1.txt")) as f:
 
243
 
244
  questions = ('Custom Prompt',
245
  'Plot the monthly average PM2.5 for the year 2023.',
246
+ 'Which month in which year has the highest average PM2.5 overall?',
247
+ 'Which month in which year has the highest PM2.5 overall?',
248
  'Which month has the highest average PM2.5 in 2023 for Mumbai?',
249
  'Plot and compare monthly timeseries of pollution for Mumbai and Bengaluru.',
250
  'Plot the yearly average PM2.5.',
251
  'Plot the monthly average PM2.5 of Delhi, Mumbai and Bengaluru for the year 2022.',
252
  'Which month has the highest pollution?',
 
253
  'Which city has the highest PM2.5 level in July 2022?',
254
  'Plot and compare monthly timeseries of PM2.5 for Mumbai and Bengaluru.',
255
  'Plot and compare the monthly average PM2.5 of Delhi, Mumbai and Bengaluru for the year 2022.',
256
  'Plot the monthly average PM2.5.',
257
  'Plot the monthly average PM10 for the year 2023.',
258
+ 'Which (month, year) has the highest PM2.5?',
259
  'Plot the monthly average PM2.5 of Delhi for the year 2022.',
260
  'Plot the monthly average PM2.5 of Bengaluru for the year 2022.',
261
  'Plot the monthly average PM2.5 of Mumbai for the year 2022.',
 
303
  # select random waiting line
304
  with st.spinner(random.choice(waiting_lines)):
305
  ran = False
306
+ for i in range(1):
307
+ print(f"Attempt {i+1}")
308
+ llm = ChatGroq(model=models[model_name], api_key=os.getenv("GROQ_API"), temperature=0)
309
 
310
  df_check = pd.read_csv("Data.csv")
311
  df_check["Timestamp"] = pd.to_datetime(df_check["Timestamp"])
 
313
 
314
  new_line = "\n"
315
 
316
+ parameters = {"font.size": 12}
317
 
318
  template = f"""```python
319
  import pandas as pd
320
  import matplotlib.pyplot as plt
321
 
322
+ # plt.rcParams.update({parameters})
323
 
324
  df = pd.read_csv("Data.csv")
325
  df["Timestamp"] = pd.to_datetime(df["Timestamp"])
326
 
327
+ import geopandas as gpd
328
+ india = gpd.read_file("https://gist.githubusercontent.com/jbrobst/56c13bbbf9d97d187fea01ca62ea5112/raw/e388c4cae20aa53cb5090210a42ebb9b765c0a36/india_states.geojson")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
 
330
  # df.dtypes
331
  {new_line.join(map(lambda x: '# '+x, str(df_check.dtypes).split(new_line)))}
 
336
  """
337
 
338
  query = f"""I have a pandas dataframe data of PM2.5 and PM10.
339
+ * The columns are 'Timestamp', 'station', 'PM2.5', 'PM10', 'address', 'city', 'latitude', 'longitude',and 'state'.
340
  * Frequency of data is daily.
341
  * `pollution` generally means `PM2.5`.
342
  * You already have df, so don't read the csv file
343
+ * Don't print anything, but save result in a variable `answer` and make it global.
344
  * Unless explicitly mentioned, don't consider the result as a plot.
345
  * PM2.5 guidelines: India: 60, WHO: 15.
346
  * PM10 guidelines: India: 100, WHO: 50.
347
  * If result is a plot, show the India and WHO guidelines in the plot.
348
  * If result is a plot make it in tight layout, save it and save path in `answer`. Example: `answer='plot.png'`
349
+ * If result is a plot, rotate x-axis tick labels by 45 degrees,
350
  * If result is not a plot, save it as a string in `answer`. Example: `answer='The city is Mumbai'`
351
+ * I have a geopandas.geodataframe india containining the coordinates required to plot Indian Map with states.
352
+ * If the query asks you to plot on India Map, use that geodataframe to plot and then add more points as per the requirements using the similar code as follows : v = ax.scatter(df['longitude'], df['latitude']). If the colorbar is required, use the following code : plt.colorbar(v)
353
+ * If the query asks you to plot on India Map plot the India Map in Beige color
354
  * Whenever you do any sort of aggregation, report the corresponding standard deviation, standard error and the number of data points for that aggregation.
355
  * Whenever you're reporting a floating point number, round it to 2 decimal places.
356
  * Always report the unit of the data. Example: `The average PM2.5 is 45.67 µg/m³`
 
360
  {template}
361
 
362
  """
363
+ answer = None
364
+ code = None
 
 
 
 
 
365
  try:
366
+ answer = llm.invoke(query)
367
+ code = f"""
368
+ {template.split("```python")[1].split("```")[0]}
369
+ {answer.content.split("```python")[1].split("```")[0]}
370
+ """
371
+ # update variable `answer` when code is executed
372
  exec(code)
373
  ran = True
374
  no_response = False
375
  except Exception as e:
376
  no_response = True
377
  exception = e
378
+ if code is not None:
379
+ answer = f"!!!Faced an error while working on your query. Please try again!!!"
380
+
381
+ if type(answer) != str:
382
+ answer = f"!!!Faced an error while working on your query. Please try again!!!"
383
+
384
  response = {"role": "assistant", "content": answer, "gen_code": code, "ex_code": code, "last_prompt": prompt, "no_response": no_response}
385
 
386
  # Get response from agent
 
388
  # response = ask_agent(agent, prompt)
389
 
390
  if ran:
391
+ break
392
 
393
+ # Display agent response
394
+ if code is not None:
395
+ # Add agent response to chat history
396
+ print("Adding response")
397
+ st.session_state.responses.append(response)
398
+ show_response(st, response)
399
+
400
  if no_response:
401
+ print("No response")
402
  st.error(f"Failed to generate right output due to the following error:\n\n{exception}")
403
+
 
404
 
 
 
 
405
 
406
+ prompt = 'Custom Prompt'