import gradio as gr import requests import urllib.parse LOL = "Bearer 49H9qqKCehrAC3zqzaaWifZBCYOS" def search_from_abstract(query): """ Search all patents by abstract using the EPO API. Parameters: query (str): Search query for patent abstracts Returns: str: XML response containing patent search results """ base_url = "https://ops.epo.org/3.2/rest-services/published-data/search" endpoint = "abstract" start_range = 1 end_range = 100 headers = { 'accept': 'application/xml', 'Authorization': LOL } url = f"{base_url}/{endpoint}?q={urllib.parse.quote_plus(query)}&Range={start_range}-{end_range}" response = requests.request("GET", url, headers=headers) return response.text app = gr.Interface( fn=search_from_abstract, inputs="text", outputs="text", title="Patent Abstract Search", description="Search patents by abstract using the European Patent Office API." ) app.launch(mcp_server=True)