cogcorp commited on
Commit
0bbc874
·
1 Parent(s): 95cbc00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -6
app.py CHANGED
@@ -155,13 +155,14 @@ def process_file(client_file):
155
  common_list = [] # Reset the common_list for next vendor_file
156
  matches_found = True # Set the flag to True as matches were found
157
 
158
- highest_score_vendor = max(total_trellis_scores, key=total_trellis_scores.get)
159
- highest_score_vendor = highest_score_vendor.split(".")[0]
 
160
 
161
  if not matches_found: # In case there were no matches
162
  return "No matching data found.", None, None
163
  else:
164
- def gpt3_query(prompt, engine='gpt-3.5-turbo', max_tokens=100, temperature=0.3):
165
  try:
166
  response = openai.ChatCompletion.create(
167
  model=engine,
@@ -173,14 +174,39 @@ def process_file(client_file):
173
  temperature=temperature
174
  )
175
  return response['choices'][0]['message']['content'].strip()
 
176
  except Exception as e:
177
  print(f"Error in gpt3_query: {str(e)}")
178
  return None
179
 
180
  # Get GPT-3.5-turbo to create a summary text
181
- summary = gpt3_query(f"Based on the Trellis Score, the best vendor is {highest_score_vendor}. Please provide a brief summary.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
- return f"Matching data has been saved to 'matches.xlsx'.\n\n{summary}", os.path.abspath('matches.xlsx'), highest_score_vendor
184
 
185
 
186
  iface = gr.Interface(
@@ -189,7 +215,7 @@ iface = gr.Interface(
189
  outputs=[
190
  gr.components.Textbox(label="Status"),
191
  gr.components.File(label="Download Match Results"),
192
- gr.components.Textbox(label="Vendor with Highest Score")
193
  ],
194
  )
195
 
 
155
  common_list = [] # Reset the common_list for next vendor_file
156
  matches_found = True # Set the flag to True as matches were found
157
 
158
+ top_three_vendors = sorted(total_trellis_scores, key=total_trellis_scores.get, reverse=True)[:3]
159
+ top_three_vendors = [vendor.split(".")[0] for vendor in top_three_vendors]
160
+
161
 
162
  if not matches_found: # In case there were no matches
163
  return "No matching data found.", None, None
164
  else:
165
+ def gpt3_query(prompt, engine='gpt-3.5-turbo', max_tokens=3000, temperature=0.3):
166
  try:
167
  response = openai.ChatCompletion.create(
168
  model=engine,
 
174
  temperature=temperature
175
  )
176
  return response['choices'][0]['message']['content'].strip()
177
+
178
  except Exception as e:
179
  print(f"Error in gpt3_query: {str(e)}")
180
  return None
181
 
182
  # Get GPT-3.5-turbo to create a summary text
183
+ summary = gpt3_query(f"""Based on the Trellis Score, the top three vendors are {', '.join(top_three_vendors)}.
184
+
185
+ We have analyzed the performance of several vendors and identified the top three based on their Trellis Scores. Here are the key data points for each:
186
+
187
+ 1. [name vendor 1]
188
+ - Trellis Score: {total_trellis_scores}
189
+ - Strengths: [brief summary of strengths]
190
+ - Weaknesses: [brief summary of weaknesses]
191
+ - Key Features: [brief summary of key features]
192
+
193
+ 2. [name vendor 2]
194
+ - Strengths: [brief summary of strengths]
195
+ - Weaknesses: [brief summary of weaknesses]
196
+ - Key Features: [brief summary of key features]
197
+
198
+ 3. [name vendor 3]
199
+ - Strengths: [brief summary of strengths]
200
+ - Weaknesses: [brief summary of weaknesses]
201
+ - Key Features: [brief summary of key features]
202
+
203
+ Based on this format, please provide a detailed breakdown of the strengths and weaknesses of each vendor, along with an overall comparison.
204
+ """)
205
+
206
+
207
+ return f"Matching data has been saved to 'matches.xlsx'.\n\n{summary}", os.path.abspath('matches.xlsx'), top_three_vendors
208
+
209
 
 
210
 
211
 
212
  iface = gr.Interface(
 
215
  outputs=[
216
  gr.components.Textbox(label="Status"),
217
  gr.components.File(label="Download Match Results"),
218
+ gr.components.Textbox(label="Top Three Vendors")
219
  ],
220
  )
221