Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ import time
|
|
12 |
# Title and Application Introduction
|
13 |
st.title("Patent Strategy and Innovation Consultant")
|
14 |
st.sidebar.write(
|
15 |
-
"This
|
16 |
)
|
17 |
|
18 |
# User Input Section
|
@@ -132,7 +132,7 @@ def generate_pdf_report(result, charts=None, table_data=None, metadata=None):
|
|
132 |
pdf.set_auto_page_break(auto=True, margin=15)
|
133 |
|
134 |
pdf.set_font("Arial", size=16, style="B")
|
135 |
-
pdf.cell(200, 10, txt="Patent
|
136 |
pdf.ln(10)
|
137 |
|
138 |
if metadata:
|
@@ -178,11 +178,18 @@ def create_visualizations(analyst_output):
|
|
178 |
if validated_data:
|
179 |
data = pd.DataFrame(validated_data)
|
180 |
try:
|
181 |
-
|
182 |
-
st.plotly_chart(
|
183 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_chart:
|
184 |
-
|
185 |
chart_paths.append(temp_chart.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
except Exception as e:
|
187 |
st.error(f"Error generating visualization: {e}")
|
188 |
return chart_paths
|
@@ -231,7 +238,7 @@ if st.button("Generate Patent Insights"):
|
|
231 |
st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
|
232 |
pdf_path = generate_pdf_report(writer_output, charts=charts, table_data=table_data, metadata={"Technology Area": patent_area, "Stakeholder": stakeholder})
|
233 |
with open(pdf_path, "rb") as report_file:
|
234 |
-
st.download_button("Download Report", data=report_file, file_name="
|
235 |
|
236 |
except Exception as e:
|
237 |
-
st.error(f"An error occurred during execution: {e}")
|
|
|
12 |
# Title and Application Introduction
|
13 |
st.title("Patent Strategy and Innovation Consultant")
|
14 |
st.sidebar.write(
|
15 |
+
"This application uses AI to provide actionable insights and comprehensive analysis for patent-related strategies."
|
16 |
)
|
17 |
|
18 |
# User Input Section
|
|
|
132 |
pdf.set_auto_page_break(auto=True, margin=15)
|
133 |
|
134 |
pdf.set_font("Arial", size=16, style="B")
|
135 |
+
pdf.cell(200, 10, txt="Patent Strategy and Innovation Report", ln=True, align="C")
|
136 |
pdf.ln(10)
|
137 |
|
138 |
if metadata:
|
|
|
178 |
if validated_data:
|
179 |
data = pd.DataFrame(validated_data)
|
180 |
try:
|
181 |
+
bar_chart = px.bar(data, x="Category", y="Values", title="Patent Trends by Category")
|
182 |
+
st.plotly_chart(bar_chart)
|
183 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_chart:
|
184 |
+
bar_chart.write_image(temp_chart.name)
|
185 |
chart_paths.append(temp_chart.name)
|
186 |
+
|
187 |
+
pie_chart = px.pie(data, names="Category", values="Values", title="Category Distribution")
|
188 |
+
st.plotly_chart(pie_chart)
|
189 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_chart:
|
190 |
+
pie_chart.write_image(temp_chart.name)
|
191 |
+
chart_paths.append(temp_chart.name)
|
192 |
+
|
193 |
except Exception as e:
|
194 |
st.error(f"Error generating visualization: {e}")
|
195 |
return chart_paths
|
|
|
238 |
st.success(f"Analysis completed in {elapsed_time:.2f} seconds.")
|
239 |
pdf_path = generate_pdf_report(writer_output, charts=charts, table_data=table_data, metadata={"Technology Area": patent_area, "Stakeholder": stakeholder})
|
240 |
with open(pdf_path, "rb") as report_file:
|
241 |
+
st.download_button("Download Report", data=report_file, file_name="Patent_Strategy_Report.pdf")
|
242 |
|
243 |
except Exception as e:
|
244 |
+
st.error(f"An error occurred during execution: {e}")
|