Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,18 +41,24 @@ async def root():
|
|
| 41 |
return {"message": "Patent Analyzer API is running"}
|
| 42 |
|
| 43 |
@app.post("/search")
|
| 44 |
-
async def search(
|
| 45 |
-
if not
|
| 46 |
raise HTTPException(status_code=400, detail="No query provided")
|
| 47 |
|
| 48 |
try:
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
return {"results": results}
|
| 53 |
except Exception as e:
|
| 54 |
raise HTTPException(status_code=500, detail=f"Error performing search: {str(e)}")
|
| 55 |
|
|
|
|
| 56 |
@app.post("/analyze")
|
| 57 |
async def analyze(request: AnalysisRequest):
|
| 58 |
if not request.patent_background or not request.pdf_url:
|
|
|
|
| 41 |
return {"message": "Patent Analyzer API is running"}
|
| 42 |
|
| 43 |
@app.post("/search")
|
| 44 |
+
async def search(query: str, data_type: str = None):
|
| 45 |
+
if not query:
|
| 46 |
raise HTTPException(status_code=400, detail="No query provided")
|
| 47 |
|
| 48 |
try:
|
| 49 |
+
if data_type == "pdf" or data_type is None:
|
| 50 |
+
search_query = f"{query} filetype:pdf"
|
| 51 |
+
elif data_type == "patent":
|
| 52 |
+
search_query = f"{query} site:patents.google.com"
|
| 53 |
+
else:
|
| 54 |
+
search_query = query
|
| 55 |
+
|
| 56 |
+
results = search_web(search_query, max_references=5)
|
| 57 |
return {"results": results}
|
| 58 |
except Exception as e:
|
| 59 |
raise HTTPException(status_code=500, detail=f"Error performing search: {str(e)}")
|
| 60 |
|
| 61 |
+
|
| 62 |
@app.post("/analyze")
|
| 63 |
async def analyze(request: AnalysisRequest):
|
| 64 |
if not request.patent_background or not request.pdf_url:
|