langchain icon indicating copy to clipboard operation
langchain copied to clipboard

enhance the code in searxng tool to define 'retmax' value when using pubmed as engine

Open amani-acog opened this issue 1 year ago • 0 comments

Feature request

The Searxng tool has num_results argument to return user wanted number of results...But while using 'pubmed' as engine its not working if num_results are set >10 because it is sought of hardcoded in pubmed engine module of searx api to 10. I tried to figure out how searxng tool is calling searx api but failed.

Motivation

Please help me to fix this issue because i want to fetch the documents iteratively from pubmed for my research. It wont be helpful if it only returns top 10 articles for user query, it may not have answer in all the cases specially in research.

Your contribution

I found out that searx api has module for pubmed engine and it is sought of hardcoded for retmax argument as follows:


base_url = (
    'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi' + '?db=pubmed&{query}&retstart={offset}&retmax={hits}'
)

# engine dependent config
number_of_results = 10
pubmed_url = 'https://www.ncbi.nlm.nih.gov/pubmed/'


def request(query, params):
    # basic search
    offset = (params['pageno'] - 1) * number_of_results

    string_args = dict(query=urlencode({'term': query}), offset=offset, hits=number_of_results)

    params['url'] = base_url.format(**string_args)

    return params

please also enhance the code to accept additional filters Thank you in advance

amani-acog avatar May 07 '23 17:05 amani-acog