kangxiaojiang's picture
Update app.py
fecfaaa verified
import gradio as gr
import time
def patsnap_assistant(domain, query):
if not query:
yield "⚠️ Please enter keywords first.", ""
return
yield f"πŸ” Initializing PatSnap {domain} Engine...", ""
time.sleep(1)
if domain == "βš–οΈ IP & Innovation Intelligence":
yield "πŸ“‚ Retrieving global patent databases...", "### Analyzing: " + query
time.sleep(1.5)
result = f"""
## βš–οΈ IP Insight Report: {query}
### 1. Patent Landscape
- **Core Technology**: Analysis shows a high concentration in the fusion of high-precision sensors and AI algorithms.
- **Key Assignees**: Identified 3 major industry leaders and 5 high-growth startups.
### 2. Innovation Risk (FTO Check)
- **Risk Assessment**: Preliminary scan found no direct infringement risks, but 2 patent families published in 2024 require monitoring.
### 3. Strategic Recommendations
- Recommended to prioritize **Path B (Modular Integration)**, as the patent barriers are relatively lower in this direction.
"""
yield "βœ… Analysis Complete!", result
else: # Life Sciences
yield "🧬 Retrieving biomedical and clinical trial data...", "### Analyzing: " + query
time.sleep(1.5)
result = f"""
## 🧬 Life Sciences Research Report: {query}
### 1. Biomarker Investigation
- **Diagnostic Markers**: Identified 4 protein indicators highly correlated with this condition.
- **Clinical Value**: Predictive accuracy reported at over 85% in the latest literature.
### 2. R&D Pipeline
- **Drugs in Development**: Currently 12 related drugs are in Clinical Phase II globally.
- **Competitive Landscape**: Leading pharmaceutical companies have already established multi-target combination therapies.
### 3. Expert Recommendations
- Suggest focusing on the development of **Predictive Biomarkers** to improve patient stratification efficiency in clinical trials.
"""
yield "βœ… Analysis Complete!", result
# Optimized CSS: Removed fixed background to support Dark Mode
custom_css = """
#title { text-align: center; color: #1a73e8; margin-bottom: 20px; }
.feedback { font-weight: bold; color: #1a73e8; }
"""
# Using gr.Themes.Soft() for a more professional look that adapts to Dark/Light mode
with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, title="PatSnap Intelligence Assistant") as demo:
gr.Markdown("# 🧬 PatSnap Intelligence Assistant", elem_id="title")
gr.Markdown("Experience the power of PatSnap AI Agent Skills. Select a domain and enter your keywords.")
with gr.Row():
with gr.Column(scale=1):
domain_input = gr.Radio(
choices=["βš–οΈ IP & Innovation Intelligence", "🧬 Life Sciences & Pharma"],
label="Select Intelligence Domain",
value="βš–οΈ IP & Innovation Intelligence"
)
query_input = gr.Textbox(
label="Keywords (e.g., 'Solid-state battery' or 'EGFR Inhibitors')",
placeholder="Enter keywords here..."
)
submit_btn = gr.Button("Start Intelligence Analysis", variant="primary")
with gr.Column(scale=2):
# Added a clear container for status and results
status_output = gr.Markdown("Waiting for input...", elem_classes="feedback")
result_output = gr.Markdown("Analysis results will appear here.")
submit_btn.click(
fn=patsnap_assistant,
inputs=[domain_input, query_input],
outputs=[status_output, result_output]
)
demo.launch()