WHG2023
commited on
Commit
·
8d57868
1
Parent(s):
670430a
feat: Redesign UI for clarity and improve backend agents
Browse files- README.md +145 -40
- app.py +150 -232
- real_ai_agents_implementation.py +41 -10
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: Patent Architect AI v2
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
|
@@ -8,59 +8,164 @@ sdk_version: 4.44.0
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description:
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
|
| 16 |
-
**
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
###
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
-
|
| 26 |
-
-
|
| 27 |
|
| 28 |
-
###
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
-
|
| 39 |
-
-
|
| 40 |
-
-
|
| 41 |
-
-
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
-
**Backend**: Modal serverless with Groq Llama 3.3 70B
|
| 47 |
-
**Intelligence**: Multi-agent negotiation with weighted consensus
|
| 48 |
-
**Visualization**: Gemini 2.0 Flash figure generation
|
| 49 |
-
**Design**: 80s cyberpunk neon noir aesthetic
|
| 50 |
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
-
|
| 55 |
-
-
|
| 56 |
-
-
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
```
|
| 65 |
|
| 66 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Patent Architect AI v2
|
| 3 |
+
emoji: 🏗️
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
short_description: AI Patent Intelligence with Enhanced Dual Output
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# 🏗️ Patent Architect AI v2 - Enhanced Dual Output
|
| 15 |
|
| 16 |
+
**Revolutionary AI Patent Intelligence System with Enhanced Dual Output Technology**
|
| 17 |
|
| 18 |
+
## 🌟 New Enhanced Dual Output Features
|
| 19 |
|
| 20 |
+
Patent Architect AI v2 now provides **BOTH** detailed technical descriptions AND professional LaTeX/TikZ code for patent figures:
|
| 21 |
|
| 22 |
+
### ✨ **What You Get:**
|
| 23 |
+
- **📝 Immediate Understanding**: Read detailed technical descriptions instantly
|
| 24 |
+
- **🎨 Professional LaTeX Code**: USPTO-ready vector graphics for patent submission
|
| 25 |
+
- **🖼️ Multiple Compilation Options**: Overleaf, local, or web-based compilation
|
| 26 |
+
- **🚀 Best of Both Worlds**: No more choosing between readability and quality
|
| 27 |
|
| 28 |
+
### **Example Enhanced Output:**
|
| 29 |
+
```
|
| 30 |
+
📝 Technical Description:
|
| 31 |
+
The smart coffee mug comprises a cylindrical vessel (1) with integrated
|
| 32 |
+
phase-change material chamber (2) positioned between walls (3,4)...
|
| 33 |
+
|
| 34 |
+
🎨 LaTeX/TikZ Code:
|
| 35 |
+
\documentclass{article}
|
| 36 |
+
\usepackage{tikz}
|
| 37 |
+
\begin{tikzpicture}[scale=1.2]
|
| 38 |
+
\draw[thick] (0,0) rectangle (4,6);
|
| 39 |
+
\node at (2,5.5) {1};
|
| 40 |
+
...
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
## 🎯 Key Features
|
| 44 |
|
| 45 |
+
### **🤖 Real AI Agent Intelligence**
|
| 46 |
+
- **Technical Completeness Agent**: Identifies missing technical specifications
|
| 47 |
+
- **Prior Art Landscape Agent**: Comprehensive competitive analysis
|
| 48 |
+
- **Claim Architecture Agent**: Strategic patent claim optimization
|
| 49 |
+
- **Enhanced Figure Generation**: Professional LaTeX/TikZ patent drawings
|
| 50 |
|
| 51 |
+
### **🎨 Enhanced Figure Generation**
|
| 52 |
+
- **Dual Output Technology**: Descriptions + LaTeX code simultaneously
|
| 53 |
+
- **Multiple Viewing Options**: Overleaf, local compilation, web preview
|
| 54 |
+
- **Professional Quality**: USPTO-standard vector graphics
|
| 55 |
+
- **Immediate Accessibility**: Read descriptions without any compilation
|
| 56 |
|
| 57 |
+
### **📊 Business Intelligence**
|
| 58 |
+
- **Market Opportunity Discovery**: Find related patent opportunities
|
| 59 |
+
- **Competitive Analysis**: Key competitors and patent landscapes
|
| 60 |
+
- **Strategic Planning**: Timeline and cost estimates
|
| 61 |
+
- **Risk Assessment**: Realistic patentability scoring
|
| 62 |
|
| 63 |
+
## 🚀 How Enhanced Dual Output Works
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
### **1. Input Your Invention**
|
| 66 |
+
```
|
| 67 |
+
"A smart coffee mug with adaptive temperature control using phase-change
|
| 68 |
+
materials and IoT connectivity..."
|
| 69 |
+
```
|
| 70 |
|
| 71 |
+
### **2. Get Dual Output**
|
| 72 |
+
- **📝 Technical Descriptions**: Immediate understanding, no compilation needed
|
| 73 |
+
- **🎨 LaTeX/TikZ Code**: Professional patent figures for USPTO submission
|
| 74 |
+
- **🖼️ Compiled Images**: When compilation tools available
|
| 75 |
|
| 76 |
+
### **3. Multiple Usage Options**
|
| 77 |
+
- **Quick Understanding**: Read the descriptions immediately
|
| 78 |
+
- **Professional Submission**: Use LaTeX code with Overleaf.com
|
| 79 |
+
- **Custom Editing**: Modify LaTeX for specific requirements
|
| 80 |
+
- **Instant Preview**: View compiled images when available
|
| 81 |
|
| 82 |
+
## 💡 Usage Examples
|
| 83 |
+
|
| 84 |
+
### **Enhanced Technical Input:**
|
| 85 |
+
```
|
| 86 |
+
A modular vertical farming system with adaptive LED lighting using full-spectrum
|
| 87 |
+
arrays (400-700nm) controlled by neural network analysis. The system employs
|
| 88 |
+
RGB+NIR sensors to monitor chlorophyll content and adjusts light intensity
|
| 89 |
+
(50-1000 μmol/m²/s) based on growth stage detection.
|
| 90 |
```
|
| 91 |
|
| 92 |
+
### **Enhanced Output:**
|
| 93 |
+
```
|
| 94 |
+
✨ Generated 3 complete figure sets with both detailed descriptions AND LaTeX/TikZ code
|
| 95 |
+
🖼️ 2/3 figures successfully compiled to images
|
| 96 |
+
|
| 97 |
+
📝 Technical Description Available: Read immediately for understanding
|
| 98 |
+
🎨 LaTeX Code Available: Upload to Overleaf.com for professional PDF
|
| 99 |
+
🚀 Multiple Viewing Options: Local, web-based, or mobile preview
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
## 🔧 Technical Capabilities
|
| 103 |
+
|
| 104 |
+
### **Real AI Analysis:**
|
| 105 |
+
- **Technical Gap Detection**: Missing specifications and requirements
|
| 106 |
+
- **Patentability Assessment**: Realistic scoring based on technical depth
|
| 107 |
+
- **Competitive Intelligence**: Competitor analysis and patent landscapes
|
| 108 |
+
- **Business Planning**: Cost estimates and development timelines
|
| 109 |
+
|
| 110 |
+
### **Professional Figure Generation:**
|
| 111 |
+
- **Gemini 2.0 Flash Integration**: High-quality LaTeX/TikZ code generation
|
| 112 |
+
- **Vector Graphics**: Infinitely scalable, USPTO-preferred format
|
| 113 |
+
- **Numbered Components**: Professional patent figure standards
|
| 114 |
+
- **Multiple Compilation Methods**: Flexibility for all skill levels
|
| 115 |
+
|
| 116 |
+
## 🏆 Why Enhanced Dual Output is Revolutionary
|
| 117 |
+
|
| 118 |
+
### **Traditional Approaches:**
|
| 119 |
+
- ❌ Either readable descriptions OR professional figures
|
| 120 |
+
- ❌ Technical barriers for non-LaTeX users
|
| 121 |
+
- ❌ Manual compilation required
|
| 122 |
+
- ❌ Choose between immediate use and quality
|
| 123 |
+
|
| 124 |
+
### **Enhanced Dual Output:**
|
| 125 |
+
- ✅ **Both descriptions AND professional code**
|
| 126 |
+
- ✅ **Immediate understanding + publication quality**
|
| 127 |
+
- ✅ **Multiple compilation options**
|
| 128 |
+
- ✅ **Accessibility for all skill levels**
|
| 129 |
+
|
| 130 |
+
## 🎯 Perfect For
|
| 131 |
+
|
| 132 |
+
- **Inventors**: Understand your patent immediately while getting professional output
|
| 133 |
+
- **Patent Attorneys**: USPTO-ready figures with detailed technical descriptions
|
| 134 |
+
- **Engineers**: Technical precision with professional formatting
|
| 135 |
+
- **Students**: Learn patent writing while seeing professional examples
|
| 136 |
+
- **Entrepreneurs**: Business planning with technical validation
|
| 137 |
+
|
| 138 |
+
## 📚 Getting Started
|
| 139 |
+
|
| 140 |
+
### **Quick Start:**
|
| 141 |
+
1. Enter your detailed invention description
|
| 142 |
+
2. Get both technical descriptions AND LaTeX code
|
| 143 |
+
3. Read descriptions for immediate understanding
|
| 144 |
+
4. Use LaTeX code with Overleaf.com for professional figures
|
| 145 |
+
|
| 146 |
+
### **For Professional Quality:**
|
| 147 |
+
1. Upload generated .tex files to Overleaf.com
|
| 148 |
+
2. Click "Recompile" for instant professional PDF
|
| 149 |
+
3. Download for USPTO submission
|
| 150 |
+
4. Modify LaTeX code for custom requirements
|
| 151 |
+
|
| 152 |
+
## 🔮 Technology Stack
|
| 153 |
+
|
| 154 |
+
- **Frontend**: Enhanced Gradio with real-time dual output visualization
|
| 155 |
+
- **Backend**: Modal serverless with Groq Llama 3.3 70B
|
| 156 |
+
- **Figure Generation**: Google Gemini 2.0 Flash with LaTeX/TikZ
|
| 157 |
+
- **Real AI**: Multi-agent analysis with business intelligence
|
| 158 |
+
- **Compilation**: Local, web-based, and Overleaf integration
|
| 159 |
+
|
| 160 |
+
## 📞 Support & Documentation
|
| 161 |
+
|
| 162 |
+
- **Enhanced Features Guide**: See `ENHANCED_DUAL_OUTPUT_FEATURES.md`
|
| 163 |
+
- **Setup Instructions**: Environment configuration and API keys
|
| 164 |
+
- **Example Outputs**: Professional patent figure examples
|
| 165 |
+
- **Compilation Options**: Multiple viewing and usage methods
|
| 166 |
+
|
| 167 |
+
---
|
| 168 |
+
|
| 169 |
+
**Patent Architect AI v2 - Where Innovation Meets Professional Intelligence** 🏆
|
| 170 |
+
|
| 171 |
+
*Providing both immediate understanding AND professional quality in one revolutionary system.*
|
app.py
CHANGED
|
@@ -28,37 +28,69 @@ except ImportError:
|
|
| 28 |
GEMINI_IMAGE_AVAILABLE = False
|
| 29 |
|
| 30 |
def compile_latex_to_image(latex_code: str) -> Optional[str]:
|
| 31 |
-
"""Try to compile LaTeX code to an image using a web service."""
|
| 32 |
if not latex_code:
|
| 33 |
return None
|
|
|
|
|
|
|
| 34 |
try:
|
| 35 |
-
#
|
| 36 |
-
|
| 37 |
-
match = re.search(r'(\\documentclass.*?\\end{document})|(\\begin{tikzpicture}.*?\\end{tikzpicture})', latex_code, re.DOTALL)
|
| 38 |
if match:
|
| 39 |
-
|
| 40 |
-
content_to_render = match.group(1) if match.group(1) else match.group(2)
|
| 41 |
else:
|
| 42 |
-
# Fallback if
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
#
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
return None
|
| 59 |
-
|
| 60 |
except Exception as e:
|
| 61 |
-
print(f"
|
| 62 |
return None
|
| 63 |
|
| 64 |
def create_negotiation_transcript_display(transcript: List[Dict]) -> str:
|
|
@@ -176,214 +208,110 @@ def run_patent_architect_in_ui(invention_disclosure: str) -> Generator[List, Non
|
|
| 176 |
status = "Agentic Negotiation Complete."
|
| 177 |
yield [negotiation_html, prior_art_section, summary_section, figures_section, claims_section, status]
|
| 178 |
|
| 179 |
-
with gr.Blocks(theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"), title="Patent Architect
|
| 180 |
gr.HTML("""
|
| 181 |
-
<div style="background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a
|
| 182 |
-
border: 2px solid #00ff41;
|
| 183 |
-
|
| 184 |
-
color: #00ff41;
|
| 185 |
-
padding: 40px;
|
| 186 |
text-align: center;
|
| 187 |
-
border-radius: 0;
|
| 188 |
-
margin-bottom: 30px;
|
| 189 |
-
position: relative;
|
| 190 |
font-family: 'Courier New', monospace;">
|
| 191 |
-
<
|
| 192 |
-
background: repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0,255,65,0.03) 2px, rgba(0,255,65,0.03) 4px);"></div>
|
| 193 |
-
<h1 style="font-size: 3.5em;
|
| 194 |
margin: 0;
|
| 195 |
-
text-shadow: 0 0 10px #00ff41
|
| 196 |
color: #00ff41;
|
| 197 |
font-weight: 900;
|
| 198 |
-
letter-spacing:
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
<p style="font-size: 1.
|
| 202 |
-
margin:
|
| 203 |
color: #ffff00;
|
| 204 |
text-shadow: 0 0 5px #ffff00;
|
| 205 |
-
font-weight: 600;
|
| 206 |
-
|
| 207 |
-
position: relative;
|
| 208 |
-
z-index: 1;">NEURAL IP INTELLIGENCE SYSTEM</p>
|
| 209 |
-
<p style="font-size: 1em;
|
| 210 |
-
margin: 10px 0 0 0;
|
| 211 |
-
color: #ff8c00;
|
| 212 |
-
text-shadow: 0 0 3px #ff8c00;
|
| 213 |
-
font-weight: 500;
|
| 214 |
-
position: relative;
|
| 215 |
-
z-index: 1;">DEEP ANALYSIS • PRIOR ART MATRIX • QUANTUM CLAIMS • SYNTHETIC FIGURES</p>
|
| 216 |
-
<p style="font-size: 0.9em;
|
| 217 |
-
margin: 10px 0 0 0;
|
| 218 |
-
color: #00ff41;
|
| 219 |
-
opacity: 0.8;
|
| 220 |
-
position: relative;
|
| 221 |
-
z-index: 1;">POWERED BY GEMINI & IDEOGRAM 3.0 + AUTONOMOUS AI AGENTS</p>
|
| 222 |
-
</div>
|
| 223 |
-
""")
|
| 224 |
-
|
| 225 |
-
gr.HTML("""
|
| 226 |
-
<div style="background: linear-gradient(45deg, #0a0a0a, #1a1a1a);
|
| 227 |
-
border-left: 3px solid #00ff41;
|
| 228 |
-
padding: 25px;
|
| 229 |
-
margin: 20px 0;
|
| 230 |
-
font-family: 'Courier New', monospace;
|
| 231 |
-
color: #00ff41;
|
| 232 |
-
box-shadow: 0 0 15px rgba(0,255,65,0.3);">
|
| 233 |
-
<h2 style="color: #ffff00;
|
| 234 |
-
text-shadow: 0 0 5px #ffff00;
|
| 235 |
-
font-size: 1.8em;
|
| 236 |
-
margin: 0 0 20px 0;
|
| 237 |
-
text-transform: uppercase;
|
| 238 |
-
letter-spacing: 2px;">NEXT-GEN NEURAL PATENT INTELLIGENCE</h2>
|
| 239 |
-
|
| 240 |
-
<p style="color: #ff8c00;
|
| 241 |
-
font-size: 1.1em;
|
| 242 |
-
margin-bottom: 25px;
|
| 243 |
-
text-shadow: 0 0 3px #ff8c00;">
|
| 244 |
-
<strong>PATENT ARCHITECT v2</strong> deploys autonomous AI agents with neural intelligence for comprehensive patent analysis and strategic IP development.
|
| 245 |
</p>
|
| 246 |
-
|
| 247 |
-
<h3 style="color: #00ff41;
|
| 248 |
-
text-shadow: 0 0 3px #00ff41;
|
| 249 |
-
font-size: 1.4em;
|
| 250 |
-
margin: 25px 0 15px 0;
|
| 251 |
-
text-transform: uppercase;">AUTONOMOUS AGENT MATRIX</h3>
|
| 252 |
-
|
| 253 |
-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0;">
|
| 254 |
-
<div style="border: 1px solid #00ff41; padding: 15px; background: rgba(0,255,65,0.05);">
|
| 255 |
-
<strong style="color: #ffff00;">PRIOR ART DETECTIVE</strong><br>
|
| 256 |
-
<span style="color: #ff8c00;">Multi-domain patent landscape analysis</span>
|
| 257 |
-
</div>
|
| 258 |
-
<div style="border: 1px solid #ffff00; padding: 15px; background: rgba(255,255,0,0.05);">
|
| 259 |
-
<strong style="color: #00ff41;">TECHNICAL ANALYST</strong><br>
|
| 260 |
-
<span style="color: #ff8c00;">Precision technical documentation</span>
|
| 261 |
-
</div>
|
| 262 |
-
<div style="border: 1px solid #ff8c00; padding: 15px; background: rgba(255,140,0,0.05);">
|
| 263 |
-
<strong style="color: #ffff00;">FIGURE SYNTHESIZER</strong><br>
|
| 264 |
-
<span style="color: #00ff41;">Gemini-powered technical visualization</span>
|
| 265 |
-
</div>
|
| 266 |
-
<div style="border: 1px solid #00ff41; padding: 15px; background: rgba(0,255,65,0.05);">
|
| 267 |
-
<strong style="color: #ff8c00;">CLAIMS ARCHITECT</strong><br>
|
| 268 |
-
<span style="color: #ffff00;">Strategic legal protection design</span>
|
| 269 |
-
</div>
|
| 270 |
-
</div>
|
| 271 |
-
|
| 272 |
-
<h3 style="color: #ffff00;
|
| 273 |
-
text-shadow: 0 0 3px #ffff00;
|
| 274 |
-
font-size: 1.4em;
|
| 275 |
-
margin: 25px 0 15px 0;
|
| 276 |
-
text-transform: uppercase;">NEURAL CAPABILITIES</h3>
|
| 277 |
-
|
| 278 |
-
<ul style="color: #ff8c00; line-height: 1.8; list-style: none; padding: 0;">
|
| 279 |
-
<li style="margin: 8px 0;">▶ REAL-TIME TECHNICAL GAP ANALYSIS</li>
|
| 280 |
-
<li style="margin: 8px 0;">▶ MULTI-DIMENSIONAL PATENTABILITY SCORING</li>
|
| 281 |
-
<li style="margin: 8px 0;">▶ AUTONOMOUS COMPETITIVE INTELLIGENCE</li>
|
| 282 |
-
<li style="margin: 8px 0;">▶ SYNTHETIC FIGURE GENERATION</li>
|
| 283 |
-
<li style="margin: 8px 0;">▶ QUANTUM CLAIMS OPTIMIZATION</li>
|
| 284 |
-
</ul>
|
| 285 |
</div>
|
| 286 |
""")
|
| 287 |
|
| 288 |
-
with gr.Row():
|
| 289 |
-
with gr.Column(scale=
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
box-shadow: 0 0 10px rgba(255,255,0,0.3);">
|
| 297 |
-
<h3 style="color: #ffff00;
|
| 298 |
-
text-shadow: 0 0 5px #ffff00;
|
| 299 |
-
font-size: 1.4em;
|
| 300 |
-
margin: 0 0 15px 0;
|
| 301 |
-
text-transform: uppercase;">INVENTION INPUT MATRIX</h3>
|
| 302 |
</div>
|
| 303 |
""")
|
| 304 |
invention_input = gr.Textbox(
|
| 305 |
-
lines=
|
| 306 |
-
label="
|
| 307 |
-
placeholder="
|
| 308 |
-
|
| 309 |
-
info="The new agentic backend requires a detailed technical disclosure to function effectively."
|
| 310 |
)
|
|
|
|
| 311 |
|
| 312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
status_display = gr.Textbox(
|
| 315 |
-
label="
|
| 316 |
interactive=False,
|
| 317 |
-
value="
|
| 318 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
|
| 320 |
-
gr.HTML(""
|
| 321 |
-
<div style="height: 2px;
|
| 322 |
-
background: linear-gradient(90deg, #00ff41, #ffff00, #ff8c00, #00ff41);
|
| 323 |
-
margin: 30px 0;
|
| 324 |
-
box-shadow: 0 0 10px #00ff41;">
|
| 325 |
-
</div>
|
| 326 |
-
""")
|
| 327 |
-
|
| 328 |
-
gr.HTML("""
|
| 329 |
-
<div style="background: linear-gradient(45deg, #0a0a0a, #1a1a1a);
|
| 330 |
-
border: 1px solid #ff8c00;
|
| 331 |
-
padding: 20px;
|
| 332 |
-
margin: 20px 0;
|
| 333 |
-
font-family: 'Courier New', monospace;
|
| 334 |
-
box-shadow: 0 0 10px rgba(255,140,0,0.3);">
|
| 335 |
-
<h2 style="color: #ff8c00;
|
| 336 |
-
text-shadow: 0 0 5px #ff8c00;
|
| 337 |
-
font-size: 1.6em;
|
| 338 |
-
margin: 0;
|
| 339 |
-
text-transform: uppercase;">LIVE AGENT NEGOTIATION & STRATEGY</h2>
|
| 340 |
-
</div>
|
| 341 |
-
""")
|
| 342 |
-
|
| 343 |
-
with gr.Row():
|
| 344 |
-
with gr.Column(scale=2):
|
| 345 |
-
negotiation_display = gr.HTML("...")
|
| 346 |
-
|
| 347 |
-
gr.HTML("""
|
| 348 |
-
<div style="height: 2px;
|
| 349 |
-
background: linear-gradient(90deg, #ff8c00, #ffff00, #00ff41, #ff8c00);
|
| 350 |
-
margin: 30px 0;
|
| 351 |
-
box-shadow: 0 0 10px #ff8c00;">
|
| 352 |
-
</div>
|
| 353 |
-
""")
|
| 354 |
-
|
| 355 |
-
gr.HTML("""
|
| 356 |
-
<div style="background: linear-gradient(45deg, #0a0a0a, #1a1a1a);
|
| 357 |
-
border: 1px solid #00ff41;
|
| 358 |
-
padding: 20px;
|
| 359 |
-
margin: 20px 0;
|
| 360 |
-
font-family: 'Courier New', monospace;
|
| 361 |
-
box-shadow: 0 0 10px rgba(0,255,65,0.3);">
|
| 362 |
-
<h2 style="color: #00ff41;
|
| 363 |
-
text-shadow: 0 0 5px #00ff41;
|
| 364 |
-
font-size: 1.6em;
|
| 365 |
-
margin: 0;
|
| 366 |
-
text-transform: uppercase;">STRATEGY-ALIGNED PATENT DRAFT</h2>
|
| 367 |
-
</div>
|
| 368 |
-
""")
|
| 369 |
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
with gr.TabItem("TECHNICAL FIGURES"):
|
| 380 |
-
figures_output = gr.Markdown(
|
| 381 |
-
value="### Technical Figures\n\n*The Figure Drafter's output, illustrating the core strategic concept, will appear here.*"
|
| 382 |
-
)
|
| 383 |
-
with gr.TabItem("PATENT CLAIMS"):
|
| 384 |
-
claims_output = gr.Markdown(
|
| 385 |
-
value="### Patent Claims\n\n*The Claims Drafter's claims, focused on the strategic mandate, will appear here.*"
|
| 386 |
-
)
|
| 387 |
|
| 388 |
generate_btn.click(
|
| 389 |
fn=run_patent_architect_in_ui,
|
|
@@ -391,18 +319,14 @@ The agentic system will analyze your input, formulate a patent strategy, and gen
|
|
| 391 |
outputs=[negotiation_display, prior_art_output, summary_output, figures_output, claims_output, status_display]
|
| 392 |
)
|
| 393 |
|
| 394 |
-
gr.Examples(
|
| 395 |
-
[
|
| 396 |
-
["My invention is a smart coffee mug that uses a novel phase-change material to keep coffee at a perfect temperature. It also has a mobile app that connects via Bluetooth to let the user set their preferred temperature. The key innovation is a machine learning algorithm that learns the user's drinking habits to pre-warm or cool the mug, optimizing energy use."],
|
| 397 |
-
["A modular vertical farming system with adaptive LED lighting using full-spectrum arrays (400-700nm) controlled by neural network analysis of plant reflectance spectra. The system employs RGB+NIR sensors to monitor chlorophyll content and adjusts light intensity (50-1000 μmol/m²/s) and spectrum ratios based on growth stage detection. Machine learning models trained on 500+ crop cycles optimize photosynthetic photon flux density while reducing energy consumption by 35% compared to static lighting systems."],
|
| 398 |
-
],
|
| 399 |
-
inputs=[invention_input],
|
| 400 |
-
label="HIGH-SPECIFICATION TECHNICAL INPUT EXAMPLES"
|
| 401 |
-
)
|
| 402 |
-
|
| 403 |
gr.HTML("""
|
| 404 |
<style>
|
| 405 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
.gradio-button.primary {
|
| 407 |
background: linear-gradient(45deg, #00ff41, #ffff00) !important;
|
| 408 |
border: 2px solid #00ff41 !important;
|
|
@@ -415,19 +339,13 @@ The agentic system will analyze your input, formulate a patent strategy, and gen
|
|
| 415 |
box-shadow: 0 0 15px #00ff41, inset 0 0 10px rgba(0,255,65,0.2) !important;
|
| 416 |
font-family: 'Courier New', monospace !important;
|
| 417 |
transition: all 0.3s ease !important;
|
|
|
|
| 418 |
}
|
| 419 |
-
|
| 420 |
.gradio-button.primary:hover {
|
| 421 |
background: linear-gradient(45deg, #ffff00, #ff8c00) !important;
|
| 422 |
box-shadow: 0 0 25px #ffff00, inset 0 0 15px rgba(255,255,0,0.3) !important;
|
| 423 |
border-color: #ffff00 !important;
|
| 424 |
}
|
| 425 |
-
|
| 426 |
-
.gradio-container {
|
| 427 |
-
background: #0a0a0a !important;
|
| 428 |
-
font-family: 'Courier New', monospace !important;
|
| 429 |
-
}
|
| 430 |
-
|
| 431 |
.tab-nav button {
|
| 432 |
background: linear-gradient(45deg, #1a1a1a, #0a0a0a) !important;
|
| 433 |
border: 1px solid #00ff41 !important;
|
|
@@ -435,26 +353,26 @@ The agentic system will analyze your input, formulate a patent strategy, and gen
|
|
| 435 |
font-family: 'Courier New', monospace !important;
|
| 436 |
text-transform: uppercase !important;
|
| 437 |
letter-spacing: 1px !important;
|
|
|
|
| 438 |
}
|
| 439 |
-
|
| 440 |
.tab-nav button.selected {
|
| 441 |
background: linear-gradient(45deg, #00ff41, #ffff00) !important;
|
| 442 |
color: #0a0a0a !important;
|
| 443 |
box-shadow: 0 0 10px #00ff41 !important;
|
| 444 |
}
|
| 445 |
-
|
| 446 |
-
.gr-textbox {
|
| 447 |
background: linear-gradient(45deg, #0a0a0a, #1a1a1a) !important;
|
| 448 |
border: 1px solid #00ff41 !important;
|
| 449 |
color: #00ff41 !important;
|
| 450 |
font-family: 'Courier New', monospace !important;
|
| 451 |
}
|
| 452 |
-
|
| 453 |
-
.gr-textbox:focus {
|
| 454 |
border-color: #ffff00 !important;
|
| 455 |
box-shadow: 0 0 10px #ffff00 !important;
|
| 456 |
}
|
| 457 |
-
|
|
|
|
|
|
|
| 458 |
* {
|
| 459 |
font-family: 'Courier New', monospace !important;
|
| 460 |
}
|
|
@@ -462,7 +380,7 @@ The agentic system will analyze your input, formulate a patent strategy, and gen
|
|
| 462 |
""")
|
| 463 |
|
| 464 |
if __name__ == "__main__":
|
| 465 |
-
print("PATENT ARCHITECT
|
| 466 |
print(f"Agentic Backend: {'ONLINE' if AGENTIC_BACKEND_AVAILABLE else 'OFFLINE'}")
|
| 467 |
if not os.getenv("GEMINI_API_KEY"):
|
| 468 |
print("⚠️ WARNING: GEMINI_API_KEY environment variable not set. Gemini-powered agents will not function.")
|
|
|
|
| 28 |
GEMINI_IMAGE_AVAILABLE = False
|
| 29 |
|
| 30 |
def compile_latex_to_image(latex_code: str) -> Optional[str]:
|
| 31 |
+
"""Try to compile LaTeX code to an image using a web service, with fallbacks."""
|
| 32 |
if not latex_code:
|
| 33 |
return None
|
| 34 |
+
|
| 35 |
+
content_to_render = None
|
| 36 |
try:
|
| 37 |
+
# A more robust regex to find the complete document, even with surrounding text.
|
| 38 |
+
match = re.search(r'(\\documentclass.*?\\end{document})', latex_code, re.DOTALL)
|
|
|
|
| 39 |
if match:
|
| 40 |
+
content_to_render = match.group(1)
|
|
|
|
| 41 |
else:
|
| 42 |
+
# Fallback for tikzpicture only if full document not found
|
| 43 |
+
match = re.search(r'(\\begin{tikzpicture}.*?\\end{tikzpicture})', latex_code, re.DOTALL)
|
| 44 |
+
if match:
|
| 45 |
+
# If only tikz is found, wrap it in a standard document class
|
| 46 |
+
content_to_render = f"""\\documentclass[border=5mm]{{standalone}}
|
| 47 |
+
\\usepackage{{tikz}}
|
| 48 |
+
\\usetikzlibrary{{shapes,arrows}}
|
| 49 |
+
{match.group(0)}
|
| 50 |
+
"""
|
| 51 |
+
else:
|
| 52 |
+
# If no specific block is found, take the whole code and hope for the best
|
| 53 |
+
content_to_render = latex_code
|
| 54 |
|
| 55 |
+
# --- Attempt 1: codecogs API (fast but limited) ---
|
| 56 |
+
try:
|
| 57 |
+
encoded_latex = urllib.parse.quote(content_to_render)
|
| 58 |
+
api_url = f"https://latex.codecogs.com/png.latex?{encoded_latex}"
|
| 59 |
+
response = requests.get(api_url, timeout=15)
|
| 60 |
+
if response.status_code == 200 and response.headers.get('content-type', '').startswith('image/'):
|
| 61 |
+
image_b64 = base64.b64encode(response.content).decode('utf-8')
|
| 62 |
+
return f"data:image/png;base64,{image_b64}"
|
| 63 |
+
else:
|
| 64 |
+
print(f"LaTeX compilation (codecogs) failed with status: {response.status_code}")
|
| 65 |
+
except Exception as e:
|
| 66 |
+
print(f"An error occurred during codecogs LaTeX compilation: {e}")
|
| 67 |
+
|
| 68 |
+
# --- Attempt 2: A more robust secondary API (slower but more capable) ---
|
| 69 |
+
print("Codecogs failed, trying secondary LaTeX service...")
|
| 70 |
+
try:
|
| 71 |
+
api_url_secondary = "https://latex.ytotech.com/api/v1"
|
| 72 |
+
payload = {
|
| 73 |
+
"latex": content_to_render,
|
| 74 |
+
"format": "png",
|
| 75 |
+
"quality": 85,
|
| 76 |
+
"density": 300
|
| 77 |
+
}
|
| 78 |
+
response = requests.post(api_url_secondary, json=payload, timeout=30)
|
| 79 |
+
if response.status_code == 200:
|
| 80 |
+
response_data = response.json()
|
| 81 |
+
if response_data.get("status") == "success" and response_data.get("result"):
|
| 82 |
+
# The result is already base64 encoded
|
| 83 |
+
image_b64 = response_data["result"]
|
| 84 |
+
return f"data:image/png;base64,{image_b64}"
|
| 85 |
+
else:
|
| 86 |
+
print(f"LaTeX compilation (secondary) failed with status: {response.status_code}")
|
| 87 |
+
return None
|
| 88 |
+
except Exception as e:
|
| 89 |
+
print(f"An error occurred during secondary LaTeX compilation: {e}")
|
| 90 |
return None
|
| 91 |
+
|
| 92 |
except Exception as e:
|
| 93 |
+
print(f"A critical error occurred during LaTeX preparation: {e}")
|
| 94 |
return None
|
| 95 |
|
| 96 |
def create_negotiation_transcript_display(transcript: List[Dict]) -> str:
|
|
|
|
| 208 |
status = "Agentic Negotiation Complete."
|
| 209 |
yield [negotiation_html, prior_art_section, summary_section, figures_section, claims_section, status]
|
| 210 |
|
| 211 |
+
with gr.Blocks(theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"), title="Patent Architect") as demo:
|
| 212 |
gr.HTML("""
|
| 213 |
+
<div style="background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
|
| 214 |
+
border-bottom: 2px solid #00ff41;
|
| 215 |
+
padding: 30px 20px;
|
|
|
|
|
|
|
| 216 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
| 217 |
font-family: 'Courier New', monospace;">
|
| 218 |
+
<h1 style="font-size: 2.8em;
|
|
|
|
|
|
|
| 219 |
margin: 0;
|
| 220 |
+
text-shadow: 0 0 10px #00ff41;
|
| 221 |
color: #00ff41;
|
| 222 |
font-weight: 900;
|
| 223 |
+
letter-spacing: 2px;">
|
| 224 |
+
PATENT ARCHITECT
|
| 225 |
+
</h1>
|
| 226 |
+
<p style="font-size: 1.2em;
|
| 227 |
+
margin: 10px 0 0 0;
|
| 228 |
color: #ffff00;
|
| 229 |
text-shadow: 0 0 5px #ffff00;
|
| 230 |
+
font-weight: 600;">
|
| 231 |
+
From Raw Idea to Strategized Patent Draft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
</div>
|
| 234 |
""")
|
| 235 |
|
| 236 |
+
with gr.Row(variant="panel", style={"margin": "0", "padding": "0"}):
|
| 237 |
+
with gr.Column(scale=2, min_width=600):
|
| 238 |
+
# --- STEP 1: INPUT ---
|
| 239 |
+
gr.Markdown("""
|
| 240 |
+
<div style="border: 1px solid #ffff00; padding: 20px; margin-top: 20px; box-shadow: 0 0 10px rgba(255,255,0,0.2);">
|
| 241 |
+
<h2 style="color: #ffff00; font-size: 1.5em; margin: 0 0 15px 0; text-transform: uppercase; letter-spacing: 1px;">
|
| 242 |
+
Step 1: Disclose Your Invention
|
| 243 |
+
</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
</div>
|
| 245 |
""")
|
| 246 |
invention_input = gr.Textbox(
|
| 247 |
+
lines=10,
|
| 248 |
+
label="Invention Disclosure",
|
| 249 |
+
placeholder="Describe the core of your invention. Focus on what it does and what makes it novel. The AI agent team will analyze the technical fundamentals.",
|
| 250 |
+
info="Provide a clear, concise description. Details are good, but the core concept is essential."
|
|
|
|
| 251 |
)
|
| 252 |
+
generate_btn = gr.Button("Develop Patent Strategy", variant="primary", size="lg")
|
| 253 |
|
| 254 |
+
# --- STEP 2: LIVE ANALYSIS ---
|
| 255 |
+
gr.Markdown("""
|
| 256 |
+
<div style="border: 1px solid #ff8c00; padding: 20px; margin-top: 30px; box-shadow: 0 0 10px rgba(255,140,0,0.2);">
|
| 257 |
+
<h2 style="color: #ff8c00; font-size: 1.5em; margin: 0 0 15px 0; text-transform: uppercase; letter-spacing: 1px;">
|
| 258 |
+
Step 2: Observe the Agent Team
|
| 259 |
+
</h2>
|
| 260 |
+
</div>
|
| 261 |
+
""")
|
| 262 |
+
negotiation_display = gr.HTML("The agent negotiation log will appear here once you begin.")
|
| 263 |
|
| 264 |
+
with gr.Column(scale=1, min_width=300):
|
| 265 |
+
# --- SIDEBAR: STATUS & DELIVERABLES ---
|
| 266 |
+
gr.Markdown("""
|
| 267 |
+
<div style="border: 1px solid #00ff41; padding: 20px; margin-top: 20px; box-shadow: 0 0 10px rgba(0,255,65,0.2);">
|
| 268 |
+
<h2 style="color: #00ff41; font-size: 1.5em; margin: 0 0 15px 0; text-transform: uppercase; letter-spacing: 1px;">
|
| 269 |
+
System Status & Output
|
| 270 |
+
</h2>
|
| 271 |
+
</div>
|
| 272 |
+
""")
|
| 273 |
status_display = gr.Textbox(
|
| 274 |
+
label="Current Status",
|
| 275 |
interactive=False,
|
| 276 |
+
value="Ready"
|
| 277 |
)
|
| 278 |
+
gr.Markdown("""
|
| 279 |
+
<h3 style="color: #00ff41; font-size: 1.3em; margin: 20px 0 15px 0; text-transform: uppercase;">
|
| 280 |
+
Step 3: Review Deliverables
|
| 281 |
+
</h3>
|
| 282 |
+
<p style="color: #ff8c00; font-size: 0.9em; margin-bottom: 15px;">
|
| 283 |
+
The final, strategy-aligned patent draft will appear below.
|
| 284 |
+
</p>
|
| 285 |
+
""")
|
| 286 |
+
with gr.Tabs():
|
| 287 |
+
with gr.TabItem("Prior Art & Strategy"):
|
| 288 |
+
prior_art_output = gr.Markdown(
|
| 289 |
+
value="*The Prior Art Detective's findings and the Chief Strategist's resulting mandate will be shown here.*"
|
| 290 |
+
)
|
| 291 |
+
with gr.TabItem("Technical Summary"):
|
| 292 |
+
summary_output = gr.Markdown(
|
| 293 |
+
value="*The Technical Writer's summary, aligned with the final strategy, will appear here.*"
|
| 294 |
+
)
|
| 295 |
+
with gr.TabItem("Technical Figures"):
|
| 296 |
+
figures_output = gr.Markdown(
|
| 297 |
+
value="*A conceptual image from the Ideogram API and a technical figure from the Figure Drafter will appear here.*"
|
| 298 |
+
)
|
| 299 |
+
with gr.TabItem("Patent Claims"):
|
| 300 |
+
claims_output = gr.Markdown(
|
| 301 |
+
value="*The Claims Drafter's claims, focused on the strategic mandate, will appear here.*"
|
| 302 |
+
)
|
| 303 |
|
| 304 |
+
gr.HTML("<hr style='border: 1px solid #00ff41; margin: 40px 0;'>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
+
gr.Examples(
|
| 307 |
+
[
|
| 308 |
+
["A smart coffee mug using phase-change materials and a machine learning algorithm that learns user habits to optimize temperature and energy use."],
|
| 309 |
+
["A modular vertical farming system with AI-controlled, adaptive full-spectrum LED lighting based on real-time plant reflectance spectra analysis."],
|
| 310 |
+
["Non-invasive glucose monitoring using Raman spectroscopy."],
|
| 311 |
+
],
|
| 312 |
+
inputs=[invention_input],
|
| 313 |
+
label="Invention Examples (click one to get started)"
|
| 314 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
generate_btn.click(
|
| 317 |
fn=run_patent_architect_in_ui,
|
|
|
|
| 319 |
outputs=[negotiation_display, prior_art_output, summary_output, figures_output, claims_output, status_display]
|
| 320 |
)
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
gr.HTML("""
|
| 323 |
<style>
|
| 324 |
+
.gradio-container {
|
| 325 |
+
background: #0a0a0a !important;
|
| 326 |
+
font-family: 'Courier New', monospace !important;
|
| 327 |
+
max-width: 1400px !important;
|
| 328 |
+
margin: auto !important;
|
| 329 |
+
}
|
| 330 |
.gradio-button.primary {
|
| 331 |
background: linear-gradient(45deg, #00ff41, #ffff00) !important;
|
| 332 |
border: 2px solid #00ff41 !important;
|
|
|
|
| 339 |
box-shadow: 0 0 15px #00ff41, inset 0 0 10px rgba(0,255,65,0.2) !important;
|
| 340 |
font-family: 'Courier New', monospace !important;
|
| 341 |
transition: all 0.3s ease !important;
|
| 342 |
+
margin-top: 20px;
|
| 343 |
}
|
|
|
|
| 344 |
.gradio-button.primary:hover {
|
| 345 |
background: linear-gradient(45deg, #ffff00, #ff8c00) !important;
|
| 346 |
box-shadow: 0 0 25px #ffff00, inset 0 0 15px rgba(255,255,0,0.3) !important;
|
| 347 |
border-color: #ffff00 !important;
|
| 348 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
.tab-nav button {
|
| 350 |
background: linear-gradient(45deg, #1a1a1a, #0a0a0a) !important;
|
| 351 |
border: 1px solid #00ff41 !important;
|
|
|
|
| 353 |
font-family: 'Courier New', monospace !important;
|
| 354 |
text-transform: uppercase !important;
|
| 355 |
letter-spacing: 1px !important;
|
| 356 |
+
border-radius: 0 !important;
|
| 357 |
}
|
|
|
|
| 358 |
.tab-nav button.selected {
|
| 359 |
background: linear-gradient(45deg, #00ff41, #ffff00) !important;
|
| 360 |
color: #0a0a0a !important;
|
| 361 |
box-shadow: 0 0 10px #00ff41 !important;
|
| 362 |
}
|
| 363 |
+
.gr-textbox, .gr-markdown {
|
|
|
|
| 364 |
background: linear-gradient(45deg, #0a0a0a, #1a1a1a) !important;
|
| 365 |
border: 1px solid #00ff41 !important;
|
| 366 |
color: #00ff41 !important;
|
| 367 |
font-family: 'Courier New', monospace !important;
|
| 368 |
}
|
| 369 |
+
.gr-textbox:focus, .gr-markdown:focus {
|
|
|
|
| 370 |
border-color: #ffff00 !important;
|
| 371 |
box-shadow: 0 0 10px #ffff00 !important;
|
| 372 |
}
|
| 373 |
+
.gr-info {
|
| 374 |
+
color: #ff8c00 !important;
|
| 375 |
+
}
|
| 376 |
* {
|
| 377 |
font-family: 'Courier New', monospace !important;
|
| 378 |
}
|
|
|
|
| 380 |
""")
|
| 381 |
|
| 382 |
if __name__ == "__main__":
|
| 383 |
+
print("PATENT ARCHITECT - True Agentic Negotiation Workflow")
|
| 384 |
print(f"Agentic Backend: {'ONLINE' if AGENTIC_BACKEND_AVAILABLE else 'OFFLINE'}")
|
| 385 |
if not os.getenv("GEMINI_API_KEY"):
|
| 386 |
print("⚠️ WARNING: GEMINI_API_KEY environment variable not set. Gemini-powered agents will not function.")
|
real_ai_agents_implementation.py
CHANGED
|
@@ -106,19 +106,49 @@ class PriorArtDetective(BaseAgent):
|
|
| 106 |
def analyze(self, invention_disclosure: str) -> Dict:
|
| 107 |
# Phase 1: Extract Key Concepts
|
| 108 |
concept_prompt = f"""
|
| 109 |
-
Analyze the following invention disclosure
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
Invention: "{invention_disclosure}"
|
| 113 |
|
| 114 |
-
Example
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
"""
|
| 117 |
response_text = self._execute_prompt(concept_prompt)
|
|
|
|
| 118 |
try:
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
except json.JSONDecodeError:
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
if not key_concepts:
|
| 124 |
return {"key_concepts": [], "real_prior_art": [], "landscape_summary": "Could not identify key concepts to search for."}
|
|
@@ -224,7 +254,7 @@ class ClaimsDrafterAgent(BaseAgent):
|
|
| 224 |
class FigureDrafterAgent(BaseAgent):
|
| 225 |
def describe_figure(self, invention_disclosure: str, strategic_mandate: str) -> str:
|
| 226 |
prompt = f"""
|
| 227 |
-
You are a patent illustrator's assistant. You need to
|
| 228 |
|
| 229 |
Invention Disclosure: "{invention_disclosure}"
|
| 230 |
|
|
@@ -232,10 +262,11 @@ class FigureDrafterAgent(BaseAgent):
|
|
| 232 |
**Strategic Mandate: "{strategic_mandate}"**
|
| 233 |
|
| 234 |
1. Decide on the best type of figure to illustrate the mandate (e.g., flowchart, system diagram, cross-section).
|
| 235 |
-
2.
|
| 236 |
-
3. Generate the LaTeX/TikZ code to create this figure.
|
| 237 |
|
| 238 |
-
|
|
|
|
|
|
|
| 239 |
"""
|
| 240 |
return self._execute_prompt(prompt)
|
| 241 |
|
|
|
|
| 106 |
def analyze(self, invention_disclosure: str) -> Dict:
|
| 107 |
# Phase 1: Extract Key Concepts
|
| 108 |
concept_prompt = f"""
|
| 109 |
+
Analyze the following invention disclosure. Your task is to extract the most important, specific, and searchable technical keywords or concepts.
|
| 110 |
+
- If the disclosure is detailed, extract up to 3-5 key concepts.
|
| 111 |
+
- If the disclosure is short or a single phrase, the main phrase itself may be the best concept.
|
| 112 |
+
|
| 113 |
+
Return these concepts as a simple JSON array of strings. Do not add any other text or explanation. Your output MUST be only the JSON array.
|
| 114 |
|
| 115 |
Invention: "{invention_disclosure}"
|
| 116 |
|
| 117 |
+
Example for detailed input:
|
| 118 |
+
Invention: "My invention is a smart coffee mug that uses a novel phase-change material to keep coffee at a perfect temperature. It also has a mobile app that connects via Bluetooth to let the user set their preferred temperature. The key innovation is a machine learning algorithm that learns the user's drinking habits to pre-warm or cool the mug, optimizing energy use."
|
| 119 |
+
Output:
|
| 120 |
+
["phase-change material thermal management", "predictive pre-warming algorithm for beverage container", "user habit machine learning for temperature control"]
|
| 121 |
+
|
| 122 |
+
Example for short input:
|
| 123 |
+
Invention: "Non-invasive glucose monitoring using Raman spectroscopy"
|
| 124 |
+
Output:
|
| 125 |
+
["non-invasive glucose monitoring", "Raman spectroscopy for glucose detection"]
|
| 126 |
"""
|
| 127 |
response_text = self._execute_prompt(concept_prompt)
|
| 128 |
+
key_concepts = []
|
| 129 |
try:
|
| 130 |
+
# More robust JSON parsing
|
| 131 |
+
match = re.search(r'\[(.*?)\]', response_text, re.DOTALL)
|
| 132 |
+
if match:
|
| 133 |
+
# Handle cases where the model might just return comma-separated strings without brackets
|
| 134 |
+
key_concepts = json.loads(match.group(0))
|
| 135 |
+
else:
|
| 136 |
+
cleaned_response = response_text.strip().replace('"', '').replace("'", "")
|
| 137 |
+
if cleaned_response:
|
| 138 |
+
key_concepts = [c.strip() for c in cleaned_response.split(',') if c.strip()]
|
| 139 |
+
|
| 140 |
except json.JSONDecodeError:
|
| 141 |
+
# The model likely failed to return JSON. Try to parse it as a simple list.
|
| 142 |
+
cleaned_response = response_text.strip().replace('"', '').replace("'", "").replace('[', '').replace(']', '')
|
| 143 |
+
if cleaned_response:
|
| 144 |
+
key_concepts = [c.strip() for c in cleaned_response.split(',') if c.strip()]
|
| 145 |
+
|
| 146 |
+
# Fallback for very short disclosures if LLM still fails
|
| 147 |
+
if not key_concepts and len(invention_disclosure.split()) < 10:
|
| 148 |
+
# Also correct common typos as a courtesy
|
| 149 |
+
corrected_disclosure = invention_disclosure.replace("Non-invasice", "Non-invasive")
|
| 150 |
+
key_concepts = [corrected_disclosure]
|
| 151 |
+
|
| 152 |
|
| 153 |
if not key_concepts:
|
| 154 |
return {"key_concepts": [], "real_prior_art": [], "landscape_summary": "Could not identify key concepts to search for."}
|
|
|
|
| 254 |
class FigureDrafterAgent(BaseAgent):
|
| 255 |
def describe_figure(self, invention_disclosure: str, strategic_mandate: str) -> str:
|
| 256 |
prompt = f"""
|
| 257 |
+
You are a patent illustrator's assistant. You need to generate the LaTeX/TikZ code for a key technical figure.
|
| 258 |
|
| 259 |
Invention Disclosure: "{invention_disclosure}"
|
| 260 |
|
|
|
|
| 262 |
**Strategic Mandate: "{strategic_mandate}"**
|
| 263 |
|
| 264 |
1. Decide on the best type of figure to illustrate the mandate (e.g., flowchart, system diagram, cross-section).
|
| 265 |
+
2. Generate the complete LaTeX/TikZ code to create this figure.
|
|
|
|
| 266 |
|
| 267 |
+
**CRITICAL OUTPUT FORMAT:**
|
| 268 |
+
Return ONLY the raw LaTeX code, starting with `\\documentclass` and ending with `\\end{document}`.
|
| 269 |
+
DO NOT include any description, explanation, or any text outside of the LaTeX code block.
|
| 270 |
"""
|
| 271 |
return self._execute_prompt(prompt)
|
| 272 |
|