Spaces:
Sleeping
Sleeping
Remove fake data fallbacks, show real errors, and link patents to Google Patents
Browse filesReplace all silent fallbacks to hardcoded/simulated data with visible error
messages so attorneys never see fabricated results. Delete the Gemini-simulated
prior art search entirely. Add clickable patent number links to Google Patents.
Co-authored-by: Cursor <cursoragent@cursor.com>
Files changed (2)
- backend/server.py+3-30
- eddison-app.html+77-37
105 unmodified lines1061071081091091101111124 unmodified lines11711811912012012112212316 unmodified lines14014114214314314414514623 unmodified lines170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199173174175105 unmodified lines try: parsed = json.loads(clean) except json.JSONDecodeError: raise HTTPException(502, "Failed to parse Claude response as JSON") raise HTTPException(502, "Failed to parse Gemini response as JSON") return parsed
4 unmodified lines raise HTTPException(400, "At least one keyword is required")
if not PATENTSVIEW_API_KEY: return await _fallback_search_with_gemini(req) raise HTTPException(503, "PatentsView API key not configured. Add PATENTSVIEW_API_KEY to your .env file β request one at https://patentsview.org/apis/keyrequest")
query = build_patentsview_query(req.keywords, req.kind_codes)
16 unmodified lines if resp.status_code != 200: reason = resp.headers.get("X-Status-Reason", resp.text[:500]) print(f"[PatentsView] HTTP {resp.status_code}: {reason}") return await _fallback_search_with_gemini(req) raise HTTPException(502, f"PatentsView API error (HTTP {resp.status_code}): {reason}")
data = resp.json() patents = data.get("patents", [])23 unmodified lines return {"results": results, "source": "patentsview", "total": data.get("total_hits", len(results))}
async def _fallback_search_with_gemini(req: SearchRequest) -> dict: """If no PatentsView key is available, use Gemini to simulate results.""" if not GEMINI_API_KEY: raise HTTPException(503, "No API keys configured (need PATENTSVIEW_API_KEY or GEMINI_API_KEY)")
system_prompt = """You are a USPTO patent database expert. Simulate a prior art search and return 5 realistic patent results.Respond ONLY with valid JSON array, no markdown:[ { "patentNumber": "US10,XXX,XXX B1", "title": "...", "assignee": "Company Name", "year": 2020, "kindCode": "B1", "abstract": "2-3 sentence abstract..." }]""" user_msg = f"Search for prior art with keywords: {', '.join(req.keywords)}. Kind codes: {', '.join(req.kind_codes)}." raw = await call_gemini(system_prompt, user_msg) clean = raw.replace("```json", "").replace("```", "").strip() try: results = json.loads(clean) except json.JSONDecodeError: raise HTTPException(502, "Failed to parse Claude search response") return {"results": results, "source": "gemini_simulated", "total": len(results)}
@app.post("/api/generate-claim")async def generate_claim(req: ClaimRequest): """Step 3: Draft patent claims based on invention and approved prior art."""375 unmodified lines37637737837938038138238338438538638785 unmodified lines473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506163 unmodified lines670671672639673674675676677678679680681682683684685686687688689129 unmodified lines8198208217758228238248258268278286 unmodified lines835836837788789790791792793794795796797798799800838839840841842843131 unmodified lines9759769779389789799809819829839841 unmodified line986987988946947948949950951952989990991992993994995996997998999100015 unmodified lines101610171018974101910201021102266 unmodified lines108910901091104710921093109410951096109710981051105210531054105510561057105810591060106110621099110011011102110311041105375 unmodified lines border-radius: 4px; white-space: nowrap; flex-shrink: 0; text-decoration: none; transition: filter 0.15s, text-decoration 0.15s;}a.pa-num:hover { text-decoration: underline; filter: brightness(1.2);}.pa-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; font-weight: 300; }.pa-abstract { font-size: 13px; color: rgba(237,240,255,0.6); line-height: 1.55; font-weight: 300; }85 unmodified lines}.empty-icon { font-size: 40px; margin-bottom: 12px; }
/* βββ ERROR CARD βββ */.error-card { background: rgba(255,71,87,0.06); border: 1px solid rgba(255,71,87,0.3); border-radius: 12px; padding: 24px 28px; margin-top: 16px;}.error-card-header { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; color: var(--red); margin-bottom: 10px;}.error-card-detail { font-size: 13px; color: rgba(255,71,87,0.7); font-weight: 300; line-height: 1.5; margin-bottom: 16px; font-family: var(--mono); word-break: break-word;}.error-card .btn-ghost { border-color: rgba(255,71,87,0.3); color: var(--red);}.error-card .btn-ghost:hover { border-color: var(--red);}
/* βββ COPY BUTTON FEEDBACK βββ */.copied { color: var(--accent) !important; }</style>163 unmodified lines
<script>// βββ CONFIG ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββconst API_BASE = window.location.origin; // Backend runs on same originconst API_BASE = window.location.origin;
function renderError(container, message, detail, retryFn) { container.innerHTML = ` <div class="error-card"> <div class="error-card-header">β ${message}</div> ${detail ? `<div class="error-card-detail">${detail}</div>` : ''} ${retryFn ? `<button class="btn btn-ghost" id="_retryBtn">Try Again</button>` : ''} </div>`; if (retryFn) { container.querySelector('#_retryBtn').onclick = retryFn; } container.style.display = 'block';}
// βββ STATE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββconst STORAGE_KEY = 'eddison_state';129 unmodified lines headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text }) }); if (!response.ok) throw new Error(`API error: ${response.status}`); if (!response.ok) { const err = await response.json().catch(() => ({})); throw new Error(err.detail || `Server error (HTTP ${response.status})`); } const parsed = await response.json();
state.keywords = parsed.keywords || [];6 unmodified lines document.getElementById('extractedSection').style.display = 'block'; document.getElementById('extractedSection').scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch (err) { state.keywords = ['machine learning classification', 'patent routing', 'examiner assignment', 'NLP text analysis', 'USPTO workflow', 'automated categorization', 'claim parsing', 'IPC code mapping']; state.kindCodes = [ { code: 'A1', label: 'Published App', reason: 'Primary search target for published applications' }, { code: 'B1', label: 'Granted Patent', reason: 'Granted patents in AI/ML automation space' }, { code: 'B2', label: 'Grant (amended)', reason: 'Amended grants in document classification' }, { code: 'A2', label: 'Republication', reason: 'Republished applications worth reviewing' }, ]; state.selectedKeywords = [...state.keywords]; state.selectedKindCodes = state.kindCodes.map(k => k.code); renderKeywords(); renderKindCodes(); document.getElementById('extractedSection').style.display = 'block'; document.getElementById('extractedSection').scrollIntoView({ behavior: 'smooth', block: 'start' }); const section = document.getElementById('extractedSection'); renderError(section, 'Analysis failed', err.message, analyzeIdea); section.scrollIntoView({ behavior: 'smooth', block: 'start' }); }
saveState();131 unmodified lines headers: { "Content-Type": "application/json" }, body: JSON.stringify({ keywords, kind_codes: codes }) }); if (!response.ok) throw new Error(`API error: ${response.status}`); if (!response.ok) { const err = await response.json().catch(() => ({})); throw new Error(err.detail || `Server error (HTTP ${response.status})`); } const data = await response.json(); state.priorArt = data.results || []; const source = data.source || 'unknown';1 unmodified line console.log(`PatentsView returned ${data.total} total results`); } } catch(err) { state.priorArt = [ { patentNumber: 'US10,846,621 B1', title: 'Automated Patent Classification Using Deep Neural Networks', assignee: 'IBM Corporation', year: 2020, kindCode: 'B1', abstract: 'A system and method for automatically classifying patent applications using convolutional neural networks trained on historical USPTO filing data. The system extracts feature vectors from claim language and maps them to CPC classification codes.' }, { patentNumber: 'US11,023,533 B2', title: 'Natural Language Processing for Legal Document Routing', assignee: 'Microsoft Corporation', year: 2021, kindCode: 'B2', abstract: 'Disclosed is a document routing system employing transformer-based language models to analyze legal text and determine appropriate reviewers. The system integrates with existing workflow management platforms.' }, { patentNumber: 'US2022/0147798 A1', title: 'Machine Learning-Based Examiner Assignment in Patent Office Workflows', assignee: 'LexisNexis Group', year: 2022, kindCode: 'A1', abstract: 'A method for optimizing patent examiner workload using reinforcement learning to match application complexity with examiner specialization. Performance metrics are fed back to continuously improve assignment accuracy.' }, { patentNumber: 'US10,235,447 B1', title: 'Automated Prior Art Search Using Semantic Embedding', assignee: 'Google LLC', year: 2019, kindCode: 'B1', abstract: 'Systems and methods for conducting prior art searches by encoding patent claims into dense vector representations and performing approximate nearest neighbor search across a corpus of existing patents.' }, { patentNumber: 'US11,501,102 A1', title: 'End-to-End Patent Prosecution Automation System', assignee: 'Clarivate Analytics', year: 2022, kindCode: 'A1', abstract: 'A comprehensive platform that automates patent prosecution activities from filing through examination, including automated response generation, docketing, and deadline tracking using AI-assisted workflows.' }, ]; state.priorArt = []; const resultsDiv = document.getElementById('priorArtResults'); const listDiv = document.getElementById('paList'); renderError(listDiv, 'Prior art search failed', err.message, runPriorArtSearch); resultsDiv.style.display = 'block'; resultsDiv.scrollIntoView({ behavior: 'smooth' }); btn.disabled = false; btn.innerHTML = 'β Re-Search'; return; }
state.approvedArt = [];15 unmodified lines div.innerHTML = ` <div class="pa-header"> <div class="pa-title">${pa.title}</div> <div class="pa-num">${pa.patentNumber}</div> <a class="pa-num" href="https://patents.google.com/patent/${pa.patentNumber.replace(/[,\s\/]/g, '')}" target="_blank" rel="noopener" onclick="event.stopPropagation()">${pa.patentNumber}</a> </div> <div class="pa-meta">${pa.assignee} Β· ${pa.year} Β· Kind Code: <strong>${pa.kindCode}</strong></div> <div class="pa-abstract">${pa.abstract}</div>66 unmodified lines prior_art: approvedPatents }) }); if (!response.ok) throw new Error(`API error: ${response.status}`); if (!response.ok) { const err = await response.json().catch(() => ({})); throw new Error(err.detail || `Server error (HTTP ${response.status})`); } const data = await response.json(); state.claimDraft = data.claims || ''; } catch(err) { state.claimDraft = `1. A computer-implemented system for automated patent application processing, the system comprising: a natural language processing module configured to receive and parse a patent application document; a classification engine operatively coupled to the natural language processing module, wherein the classification engine is trained on a corpus of historical patent applications to assign Cooperative Patent Classification (CPC) codes; a routing module configured to assign a qualified patent examiner based on the assigned CPC codes and examiner specialization profiles; and a workflow management interface configured to track prosecution status and generate automated deadline notifications; wherein the system is further configured to continuously update the classification engine based on examination outcomes.
2. The system of claim 1, wherein the classification engine comprises a transformer-based neural network architecture fine-tuned on USPTO patent application data.
3. The system of claim 1, wherein the routing module applies a reinforcement learning algorithm to optimize examiner assignment based on historical performance metrics.
4. The system of claim 1, further comprising an anomaly detection module configured to flag applications with unusual claim structures or non-standard terminology for human review prior to routing.`; document.getElementById('claimLoading').style.display = 'none'; const wrap = document.getElementById('claimOutputWrap'); renderError(wrap, 'Claim generation failed', err.message, regenerateClaim); return; }
document.getElementById('claimContent').innerText = state.claimDraft;backend/server.py+3-30
eddison-app.html+77-37