import gradio as gr def arxiv_search(*kwargs): N = len(kwargs) assert N % 3 == 0, "Number of arguments must be a multiple of 3." part_size = N // 3 logics = kwargs[:part_size] terms = kwargs[part_size:2 * part_size] fields = kwargs[2 * part_size:] base_url = "https://arxiv.org/search/advanced?advanced=" # Ensure the lengths of logics, terms, and fields are the same assert len(logics) == len(terms) == len(fields), "Lengths of logic operators, terms, and fields must be the same." # Construct the query parameters dynamically params = {} for i, (logic, term, field) in enumerate(zip(logics, terms, fields)): params[f"terms-{i}-operator"] = logic params[f"terms-{i}-term"] = term params[f"terms-{i}-field"] = field.lower() params.update({ "classification-physics_archives": "all", "classification-include_cross_list": "include", "date-filter_by": "all_dates", "date-year": "", "date-from_date": "", "date-to_date": "", "date-date_type": "submitted_date", "abstracts": "show", "size": 50, "order": "-announced_date_first" }) # Construct the URL without making a request url_params = "&".join([f"{key}={value}" for key, value in params.items()]) result_url = base_url + url_params # Generate HTML link with explanatory text, larger font size, and centered alignment html_link = ( "
Click the link below to view the search results on arXiv:
" f"View ArXiv Search Results" "