Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,41 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
+
import urllib.parse
|
4 |
|
5 |
+
LOL = "Bearer 49H9qqKCehrAC3zqzaaWifZBCYOS"
|
|
|
6 |
|
7 |
+
def search_from_abstract(query):
|
8 |
+
"""
|
9 |
+
Search all patents by abstract using the EPO API.
|
10 |
+
|
11 |
+
Parameters:
|
12 |
+
query (str): Search query for patent abstracts
|
13 |
+
|
14 |
+
Returns:
|
15 |
+
str: XML response containing patent search results
|
16 |
+
"""
|
17 |
+
base_url = "https://ops.epo.org/3.2/rest-services/published-data/search"
|
18 |
+
endpoint = "abstract"
|
19 |
+
start_range = 1
|
20 |
+
end_range = 100
|
21 |
+
|
22 |
+
headers = {
|
23 |
+
'accept': 'application/xml',
|
24 |
+
'Authorization': LOL
|
25 |
+
}
|
26 |
+
|
27 |
+
url = f"{base_url}/{endpoint}?q={urllib.parse.quote_plus(query)}&Range={start_range}-{end_range}"
|
28 |
+
|
29 |
+
response = requests.request("GET", url, headers=headers)
|
30 |
+
return response.text
|
31 |
+
|
32 |
+
|
33 |
+
app = gr.Interface(
|
34 |
+
fn=search_from_abstract,
|
35 |
+
inputs="text",
|
36 |
+
outputs="text",
|
37 |
+
title="Patent Abstract Search",
|
38 |
+
description="Search patents by abstract using the European Patent Office API."
|
39 |
+
)
|
40 |
+
|
41 |
+
app.launch(mcp_server=True)
|