Source code for tooluniverse.hal_tool

import requests
from .base_tool import BaseTool
from .tool_registry import register_tool


[docs] @register_tool("HALTool") class HALTool(BaseTool): """ Search the French HAL open archive via its public API. Arguments: query (str): Search term (Lucene syntax) max_results (int): Max results to return (default 10, max 100) """
[docs] def __init__( self, tool_config, base_url="https://api.archives-ouvertes.fr/search/", ): super().__init__(tool_config) self.base_url = base_url.rstrip("/") + "/"
[docs] def run(self, arguments=None): arguments = arguments or {} query = arguments.get("query") max_results = int(arguments.get("max_results", 10)) if not query: return {"error": "`query` parameter is required."} return self._search(query, max_results)