TaskWeaver Arxiv Latest Papers Plugin

parmarjatin4911@gmail.com - Jan 28 - - Dev Community

TaskWeaver Arxiv Latest Papers Plugin

latest_papers.yaml

name: latest_papers
enabled: true
required: false
description: >-
The LatestPapersPlugin connects to the arXiv API to fetch information about the latest papers on a specified topic.

parameters:

  • name: topic type: str required: true description: The topic for which the latest papers are to be retrieved.

returns:

  • name: papers_data type: str description: >- A string containing the latest papers' information on the specified topic, returned as XML data from arXiv.

latest_papers.py

import requests
from taskweaver.plugin import Plugin, register_plugin

@register_plugin
class LatestPapersPlugin(Plugin):
def call(self, topic: str):
url = "http://export.arxiv.org/api/query"
params = {
"search_query": f"all:{topic}",
"sortBy": "submittedDate",
"sortOrder": "descending",
"max_results": 5
}
response = requests.get(url, params=params)
return response.text

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .