Spaces:
Sleeping
Sleeping
Update interim_v2.py
Browse files- interim_v2.py +100 -27
interim_v2.py
CHANGED
@@ -66,27 +66,33 @@ with st.sidebar.expander("Customize Agent Goals", expanded=False):
|
|
66 |
value=(
|
67 |
"Conduct in-depth, data-driven research on leading companies' recent patent filings, technological innovation, R&D investments,"
|
68 |
"strategic partnerships and market dynamics strictly within the {topic} sector."
|
69 |
-
"Avoid unrelated or generic recommendations."
|
70 |
"Identify key players, emerging technologies, competitor strategies, and market gaps with factually accurate and verifiable data. "
|
71 |
-
"Develop a Competitor Benchmark Matrix highlighting leaders in material innovations vs. integration techniques."
|
72 |
"Summarize key market trends and shifts in competitive positioning with bullet-point insights."
|
73 |
"Strictly avoid hallucinated, fabricated, or speculative findings. "
|
74 |
"Develop a phased Patent Filing Roadmap targeting emerging technologies and high-growth regions tailored to the specific needs"
|
75 |
"and strategic goals of {stakeholder}. Conduct a Risk Assessment covering regulatory barriers, supply chain risks, and material"
|
76 |
"costs with mitigation strategies. Suggest Investment Opportunities by identifying startups or strategic partnerships in {topic}."
|
77 |
"Present findings using a Phased Patent Strategy Table (short-term, mid-term, long-term) and a Risk Matrix."
|
|
|
78 |
)
|
79 |
)
|
80 |
writer_goal = st.text_area(
|
81 |
"Writer Goal",
|
82 |
value=(
|
83 |
-
"Develop a high-impact, professionally structured insights report that integrates verified research data and strategic analysis"
|
84 |
-
"
|
85 |
-
"
|
86 |
-
"
|
87 |
-
"
|
88 |
-
"
|
89 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
)
|
91 |
)
|
92 |
analyst_goal = st.text_area(
|
@@ -106,26 +112,85 @@ with st.sidebar.expander("Customize Agent Goals", expanded=False):
|
|
106 |
)
|
107 |
)
|
108 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
planner_goal = (
|
110 |
-
"Conduct comprehensive, data-driven research on patent filings, technological
|
111 |
-
"Avoid unrelated or generic recommendations."
|
112 |
-
"
|
113 |
-
|
114 |
-
"
|
115 |
-
"
|
116 |
-
"
|
117 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
)
|
|
|
|
|
119 |
writer_goal = (
|
120 |
-
"Develop a high-impact, professionally structured insights report that integrates verified research data and strategic analysis"
|
121 |
-
"
|
122 |
-
"
|
123 |
-
"
|
124 |
-
"
|
125 |
-
"
|
126 |
-
"
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
)
|
|
|
|
|
129 |
analyst_goal = (
|
130 |
"Perform precise, data-driven statistical analysis of patent filings, growth trends, and innovation distribution strictly within the {topic} sector, "
|
131 |
"specifically customized to the strategic needs of {stakeholder}. "
|
@@ -407,24 +472,32 @@ def parse_analyst_output(raw_output):
|
|
407 |
data_insights = []
|
408 |
|
409 |
try:
|
|
|
410 |
structured_data = ast.literal_eval(raw_output) if isinstance(raw_output, str) else raw_output
|
411 |
|
412 |
for item in structured_data:
|
413 |
-
if "Category" not in item:
|
414 |
-
logging.warning(f"Missing 'Category' in item: {item}")
|
415 |
continue
|
416 |
|
417 |
if item.get("Type") == "Key Insight":
|
418 |
key_insights.append(item["Values"])
|
419 |
elif item.get("Type") == "Data Insight":
|
420 |
-
|
|
|
|
|
|
|
|
|
|
|
421 |
else:
|
422 |
data_insights.append(item)
|
|
|
423 |
except Exception as e:
|
424 |
logging.error(f"Error parsing analyst output: {e}")
|
425 |
|
426 |
return key_insights, data_insights
|
427 |
|
|
|
428 |
# Main Execution Block
|
429 |
if st.button("Generate Patent Insights"):
|
430 |
with st.spinner('Processing...'):
|
|
|
66 |
value=(
|
67 |
"Conduct in-depth, data-driven research on leading companies' recent patent filings, technological innovation, R&D investments,"
|
68 |
"strategic partnerships and market dynamics strictly within the {topic} sector."
|
|
|
69 |
"Identify key players, emerging technologies, competitor strategies, and market gaps with factually accurate and verifiable data. "
|
70 |
+
"Develop a Competitor Benchmark Matrix highlighting leaders in material/structural/software innovations vs. integration techniques."
|
71 |
"Summarize key market trends and shifts in competitive positioning with bullet-point insights."
|
72 |
"Strictly avoid hallucinated, fabricated, or speculative findings. "
|
73 |
"Develop a phased Patent Filing Roadmap targeting emerging technologies and high-growth regions tailored to the specific needs"
|
74 |
"and strategic goals of {stakeholder}. Conduct a Risk Assessment covering regulatory barriers, supply chain risks, and material"
|
75 |
"costs with mitigation strategies. Suggest Investment Opportunities by identifying startups or strategic partnerships in {topic}."
|
76 |
"Present findings using a Phased Patent Strategy Table (short-term, mid-term, long-term) and a Risk Matrix."
|
77 |
+
"Avoid unrelated or generic recommendations."
|
78 |
)
|
79 |
)
|
80 |
writer_goal = st.text_area(
|
81 |
"Writer Goal",
|
82 |
value=(
|
83 |
+
"Develop a high-impact, professionally structured insights report that integrates verified research data and strategic analysis into the following sections:\n\n"
|
84 |
+
"1. Executive Summary: Provide a concise overview of key insights and strategic recommendations strictly aligned with {stakeholder}'s strategic objectives.\n"
|
85 |
+
"2. Market Trends & Competitive Landscape: Detailed profiles, benchmarking, and market entry insights.\n"
|
86 |
+
"3. Emerging Technologies: Spotlight key technologies, TRL classification, adoption timelines.\n"
|
87 |
+
"4. Untapped Innovation Hotspots: Highlight regions with potential, innovation clusters, and readiness analysis.\n"
|
88 |
+
"5. Strategic Opportunities & Actionable Recommendations: Patent filing roadmap, risk mitigation, partnerships, and differentiation.\n"
|
89 |
+
"6. Future Growth Projections: Market forecasts, technology adoption, scenario analysis.\n"
|
90 |
+
"7. Industry Risk & Compliance Analysis: Risk matrix and mitigation strategies.\n"
|
91 |
+
"8. Summary & Appendix: Bullet-point insights and supporting data.\n\n"
|
92 |
+
|
93 |
+
"Ensure all insights, emerging technologies, and identified innovation gaps are fact-based, verifiable, and directly relevant to the {topic}."
|
94 |
+
"Present findings with clarity through well-structured sections, bullet points, and tables. Explicitly avoid hallucinated, fabricated, or speculative content throughout the report."
|
95 |
+
|
96 |
)
|
97 |
)
|
98 |
analyst_goal = st.text_area(
|
|
|
112 |
)
|
113 |
)
|
114 |
else:
|
115 |
+
#planner_goal = (
|
116 |
+
# "Conduct comprehensive, data-driven research on patent filings, technological innovation, and market dynamics strictly within the {topic} sector."
|
117 |
+
# "Avoid unrelated or generic recommendations."
|
118 |
+
# "Identify key players, emerging technologies, competitor strategies, and market gaps with factually accurate and verifiable data. "
|
119 |
+
# "Strictly avoid hallucinated, fabricated, or speculative findings. "
|
120 |
+
# "Develop a phased Patent Filing Roadmap targeting emerging technologies and high-growth regions tailored to the specific needs"
|
121 |
+
# "and strategic goals of {stakeholder}. Conduct a Risk Assessment covering regulatory barriers, supply chain risks, and"
|
122 |
+
# "material costs with mitigation strategies. Suggest Investment Opportunities by identifying startups or strategic partnerships in {topic}."
|
123 |
+
# "Present findings using a Phased Patent Strategy Table (short-term, mid-term, long-term) and a Risk Matrix."
|
124 |
+
#)
|
125 |
planner_goal = (
|
126 |
+
"Conduct comprehensive, data-driven research on patent filings, technological innovations, and market dynamics strictly within the {topic} sector. "
|
127 |
+
"Deliver factually accurate and verifiable insights with no hallucinated, fabricated, or speculative findings. Avoid unrelated or generic recommendations. "
|
128 |
+
"Provide detailed outputs in the following structure:\n\n"
|
129 |
+
|
130 |
+
"1. Market Trends & Competitive Landscape:\n"
|
131 |
+
"- In-depth company profiles (recent patent filings, R&D investments, partnerships).\n"
|
132 |
+
"- Competitor Benchmarking (material innovations vs. integration techniques, etc.).\n"
|
133 |
+
"- Competitor Comparison Matrix (tabular comparison on innovation focus, market share, partnerships).\n"
|
134 |
+
"- Competitor Expansion Plans (predict market entries, M&A, product launches).\n\n"
|
135 |
+
|
136 |
+
"2. Emerging Technologies:\n"
|
137 |
+
"- Identify 4–5 key emerging technologies shaping the {topic} market.\n"
|
138 |
+
"- Classify technologies by Technology Readiness Level (TRL).\n"
|
139 |
+
"- Highlight disruptive technologies (e.g., metamaterials, quantum antennas).\n"
|
140 |
+
"- Analyze breakthroughs related to {topic} domain.\n"
|
141 |
+
"- Predict adoption timelines with Technology Adoption Curves.\n\n"
|
142 |
+
|
143 |
+
"3. Untapped Innovation Hotspots:\n"
|
144 |
+
"- Provide a Regional Patent Trends.\n"
|
145 |
+
"- Identify Innovation Clusters (universities, startups).\n"
|
146 |
+
"- Conduct Regulatory Landscape Analysis.\n"
|
147 |
+
"- Explore Application Expansion (non-traditional sectors).\n"
|
148 |
+
"- Evaluate Infrastructure Readiness (supply chains, logistics).\n\n"
|
149 |
+
|
150 |
+
"4. Strategic Opportunities & Actionable Recommendations:\n"
|
151 |
+
"- Develop a Phased Patent Strategy (short-term, mid-term, long-term).\n"
|
152 |
+
"- Conduct Risk Assessments (regulatory, supply chain, operational risks).\n"
|
153 |
+
"- Suggest Open Innovation Partnerships (universities, labs).\n"
|
154 |
+
"- Propose a Supply Chain Strategy (risk mitigation, diversification).\n"
|
155 |
+
"- Identify Investment Opportunities (startups, partnerships).\n"
|
156 |
+
"- Recommend Competitive Differentiation Strategies (blocking patents, cross-licensing).\n"
|
157 |
+
"- Market Entry Roadmap aligning patent filings with market strategies.\n\n"
|
158 |
+
|
159 |
+
"5. Future Growth Projections:\n"
|
160 |
+
"- Provide Market Size Forecasts (CAGR, revenue projections for 1–3 and 5–10 years).\n"
|
161 |
+
"- Analyze Demand Drivers and Barriers (tech adoption, regulatory hurdles, etc.).\n"
|
162 |
+
"- Conduct Scenario Analysis (best-case, worst-case, base-case).\n"
|
163 |
+
"- Predict Competitor Expansion Plans.\n"
|
164 |
+
"- Present Growth Projection Graphs and Forecast Summaries.\n\n"
|
165 |
+
|
166 |
+
"6. Industry Risk & Compliance Analysis:\n"
|
167 |
+
"- Identify Market, Operational, and Regulatory Risks.\n"
|
168 |
+
"- Develop Mitigation Strategies (compliance pathways, supply chain diversification).\n"
|
169 |
+
"- Provide a Regulatory Risk Matrix.\n\n"
|
170 |
+
|
171 |
+
"7. Summary & Appendix:\n"
|
172 |
+
"- Summarize key insights in bullet-point format.\n"
|
173 |
+
"- Include supplementary data, raw analysis, and research methodology."
|
174 |
)
|
175 |
+
|
176 |
+
|
177 |
writer_goal = (
|
178 |
+
"Develop a high-impact, professionally structured insights report that integrates verified research data and strategic analysis into the following sections:\n\n"
|
179 |
+
"1. Executive Summary: Provide a concise overview of key insights and strategic recommendations strictly aligned with {stakeholder}'s strategic objectives.\n"
|
180 |
+
"2. Market Trends & Competitive Landscape: Detailed profiles, benchmarking, and market entry insights.\n"
|
181 |
+
"3. Emerging Technologies: Spotlight key technologies, TRL classification, adoption timelines.\n"
|
182 |
+
"4. Untapped Innovation Hotspots: Highlight regions with potential, innovation clusters, and readiness analysis.\n"
|
183 |
+
"5. Strategic Opportunities & Actionable Recommendations: Patent filing roadmap, risk mitigation, partnerships, and differentiation.\n"
|
184 |
+
"6. Future Growth Projections: Market forecasts, technology adoption, scenario analysis.\n"
|
185 |
+
"7. Industry Risk & Compliance Analysis: Risk matrix and mitigation strategies.\n"
|
186 |
+
"8. Summary & Appendix: Bullet-point insights and supporting data.\n\n"
|
187 |
+
|
188 |
+
"Ensure all insights, emerging technologies, and identified innovation gaps are fact-based, verifiable, and directly relevant to the {topic}."
|
189 |
+
"Present findings with clarity through well-structured sections, bullet points, and tables. Explicitly avoid hallucinated, fabricated, or speculative content throughout the report."
|
190 |
|
191 |
)
|
192 |
+
|
193 |
+
|
194 |
analyst_goal = (
|
195 |
"Perform precise, data-driven statistical analysis of patent filings, growth trends, and innovation distribution strictly within the {topic} sector, "
|
196 |
"specifically customized to the strategic needs of {stakeholder}. "
|
|
|
472 |
data_insights = []
|
473 |
|
474 |
try:
|
475 |
+
# Correctly parse the raw output
|
476 |
structured_data = ast.literal_eval(raw_output) if isinstance(raw_output, str) else raw_output
|
477 |
|
478 |
for item in structured_data:
|
479 |
+
if "Category" not in item or "Values" not in item:
|
480 |
+
logging.warning(f"Missing 'Category' or 'Values' in item: {item}")
|
481 |
continue
|
482 |
|
483 |
if item.get("Type") == "Key Insight":
|
484 |
key_insights.append(item["Values"])
|
485 |
elif item.get("Type") == "Data Insight":
|
486 |
+
# Handle nested structures (e.g., Technology Spotlight Cards)
|
487 |
+
if isinstance(item["Values"], list):
|
488 |
+
for sub_item in item["Values"]:
|
489 |
+
data_insights.append({"Category": item["Category"], "Values": sub_item})
|
490 |
+
else:
|
491 |
+
data_insights.append(item)
|
492 |
else:
|
493 |
data_insights.append(item)
|
494 |
+
|
495 |
except Exception as e:
|
496 |
logging.error(f"Error parsing analyst output: {e}")
|
497 |
|
498 |
return key_insights, data_insights
|
499 |
|
500 |
+
|
501 |
# Main Execution Block
|
502 |
if st.button("Generate Patent Insights"):
|
503 |
with st.spinner('Processing...'):
|