ogegadavis254 commited on
Commit
65eab1d
1 Parent(s): a645649

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -111,7 +111,8 @@ if st.button("Generate Prediction"):
111
 
112
  with st.spinner("Generating predictions..."):
113
  analysis_text = (
114
- f"Analyze the following text and extract a performance score based on the climate conditions and their impact: {initial_text}"
 
115
  )
116
  analysis_response = call_ai_model_analysis(analysis_text)
117
 
@@ -133,11 +134,11 @@ if st.button("Generate Prediction"):
133
  st.success("Predictions generated!")
134
 
135
  # Extract performance score from the analysis result
136
- # Assuming the performance score is provided in the text as "Performance Score: XX%"
137
  performance_score = "N/A"
138
  for line in analysis_result.split('\n'):
139
- if "Performance Score:" in line:
140
- performance_score = line.split(":")[1].strip()
 
141
 
142
  # Prepare data for visualization
143
  results_data = {
@@ -157,9 +158,13 @@ if st.button("Generate Prediction"):
157
  # Display performance score
158
  st.markdown(f"**Performance Score:** {performance_score}")
159
 
 
 
 
 
160
  except ValueError as ve:
161
  st.error(f"Configuration error: {ve}")
162
  except requests.exceptions.RequestException as re:
163
  st.error(f"Request error: {re}")
164
  except Exception as e:
165
- st.error(f"An unexpected error occurred: {e}")
 
111
 
112
  with st.spinner("Generating predictions..."):
113
  analysis_text = (
114
+ f"Analyze the following text and extract a performance score (as a percentage) based on the climate conditions and their impact. "
115
+ f"Please include a line that says 'Performance Score: XX%' in your response. Here's the text to analyze: {initial_text}"
116
  )
117
  analysis_response = call_ai_model_analysis(analysis_text)
118
 
 
134
  st.success("Predictions generated!")
135
 
136
  # Extract performance score from the analysis result
 
137
  performance_score = "N/A"
138
  for line in analysis_result.split('\n'):
139
+ if "performance" in line.lower() and "score" in line.lower():
140
+ performance_score = line.split(":")[-1].strip()
141
+ break
142
 
143
  # Prepare data for visualization
144
  results_data = {
 
158
  # Display performance score
159
  st.markdown(f"**Performance Score:** {performance_score}")
160
 
161
+ # Display raw analysis result for debugging
162
+ st.subheader("Raw Analysis Result")
163
+ st.text(analysis_result)
164
+
165
  except ValueError as ve:
166
  st.error(f"Configuration error: {ve}")
167
  except requests.exceptions.RequestException as re:
168
  st.error(f"Request error: {re}")
169
  except Exception as e:
170
+ st.error(f"An unexpected error occurred: {e}")