DrishtiSharma commited on
Commit
8e73956
·
verified ·
1 Parent(s): 9ecee75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -38
app.py CHANGED
@@ -32,6 +32,9 @@ elif model_choice == "OpenAI":
32
  else:
33
  llm = ChatOpenAI(api_key=openai_api_key, model="gpt-4o")
34
 
 
 
 
35
 
36
  # Title and Application Introduction
37
  st.title("Patent Strategy and Innovation Consultant")
@@ -252,41 +255,49 @@ def display_table(analyst_output):
252
 
253
  # Main Execution Block
254
  if st.button("Generate Insights"):
255
- with st.spinner('Processing...'):
256
- try:
257
- start_time = time.time()
258
- results = crew.kickoff(inputs={"topic": patent_area, "stakeholder": stakeholder})
259
- elapsed_time = time.time() - start_time
260
-
261
- writer_output = getattr(results.tasks_output[2], "raw", "No details available.")
262
- if writer_output:
263
- st.markdown("### Final Report")
264
- st.write(writer_output)
265
- else:
266
- st.warning("No final report available.")
267
-
268
- with st.expander("Explore Detailed Insights"):
269
- tab1, tab2 = st.tabs(["Planner's Insights", "Analyst's Analysis"])
270
-
271
- with tab1:
272
- planner_output = getattr(results.tasks_output[0], "raw", "No details available.")
273
- st.write(planner_output)
274
-
275
- with tab2:
276
- analyst_output = getattr(results.tasks_output[1], "raw", "No details available.")
277
- st.write(analyst_output)
278
-
279
- charts = []
280
- if enable_advanced_analysis:
281
- charts = create_visualizations(analyst_output)
282
-
283
- table_data = display_table(analyst_output)
284
-
285
- st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
286
- pdf_path = generate_pdf_report(writer_output, charts=charts, table_data=table_data, metadata={"Technology Area": patent_area, "Stakeholder": stakeholder})
287
- with open(pdf_path, "rb") as report_file:
288
- st.download_button("Download Report", data=report_file, file_name="Patent_Strategy_Report.pdf")
289
-
290
- except Exception as e:
291
- logging.error(f"An error occurred during execution: {e}")
292
- st.error(f"An error occurred during execution: {e}")
 
 
 
 
 
 
 
 
 
32
  else:
33
  llm = ChatOpenAI(api_key=openai_api_key, model="gpt-4o")
34
 
35
+ # Model Selection on Main Screen
36
+ st.header("Model Selection")
37
+ model_choice = st.selectbox("Select LLM Provider", ["Groq-based LLM", "OpenAI"])
38
 
39
  # Title and Application Introduction
40
  st.title("Patent Strategy and Innovation Consultant")
 
255
 
256
  # Main Execution Block
257
  if st.button("Generate Insights"):
258
+ if llm is None:
259
+ st.error("Cannot proceed without a valid API key for the selected model.")
260
+ else:
261
+ with st.spinner('Processing...'):
262
+ try:
263
+ start_time = time.time()
264
+ results = crew.kickoff(inputs={"topic": patent_area, "stakeholder": stakeholder})
265
+ elapsed_time = time.time() - start_time
266
+
267
+ writer_output = getattr(results.tasks_output[2], "raw", "No details available.")
268
+ if writer_output:
269
+ st.markdown("### Final Report")
270
+ st.write(writer_output)
271
+ else:
272
+ st.warning("No final report available.")
273
+
274
+ with st.expander("Explore Detailed Insights"):
275
+ tab1, tab2 = st.tabs(["Planner's Insights", "Analyst's Analysis"])
276
+
277
+ with tab1:
278
+ planner_output = getattr(results.tasks_output[0], "raw", "No details available.")
279
+ st.write(planner_output)
280
+
281
+ with tab2:
282
+ analyst_output = getattr(results.tasks_output[1], "raw", "No details available.")
283
+ st.write(analyst_output)
284
+
285
+ charts = []
286
+ if enable_advanced_analysis:
287
+ charts = create_visualizations(analyst_output)
288
+
289
+ table_data = display_table(analyst_output)
290
+
291
+ st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
292
+ pdf_path = generate_pdf_report(
293
+ writer_output,
294
+ charts=charts,
295
+ table_data=table_data,
296
+ metadata={"Technology Area": patent_area, "Stakeholder": stakeholder}
297
+ )
298
+ with open(pdf_path, "rb") as report_file:
299
+ st.download_button("Download Report", data=report_file, file_name="Patent_Strategy_Report.pdf")
300
+
301
+ except Exception as e:
302
+ logging.error(f"An error occurred during execution: {e}")
303
+ st.error(f"An error occurred during execution: {e}")