tooluniverse.openalex_tool module¶
- class tooluniverse.openalex_tool.OpenAlexTool[source]¶
Bases:
BaseToolTool to retrieve literature from OpenAlex based on search keywords.
- search_literature(search_keywords, max_results=10, year_from=None, year_to=None, open_access=None)[source]¶
Search for literature using OpenAlex API.
- Parameters
search_keywords (str): Keywords to search for in title, abstract, and content. max_results (int): Maximum number of results to return (default: 10). year_from (int): Start year for publication date filter (optional). year_to (int): End year for publication date filter (optional). open_access (bool): Filter for open access papers only (optional).
- Returns
list: List of dictionaries containing paper information.
- _extract_paper_info(work)[source]¶
Extract relevant information from a work object returned by OpenAlex API.
- Parameters
work (dict): Work object from OpenAlex API response.
- Returns
dict: Formatted paper information.
- class tooluniverse.openalex_tool.OpenAlexRESTTool[source]¶
Bases:
BaseToolGeneric JSON-config driven OpenAlex REST tool.
Notes: - OpenAlex strongly encourages providing a contact email via the mailto query param. - This tool returns a consistent wrapper: {status, data, url} (plus error fields on failure).
- run(arguments)[source]¶
Execute the tool.
The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.
- Parameters:
arguments (
dict, optional) – Tool-specific argumentsstream_callback (
callable, optional) – Callback for streaming responsesuse_cache (
bool, optional) – Whether result caching is enabledvalidate (
bool, optional) – Whether parameter validation was performed
Note
These additional parameters (stream_callback, use_cache, validate) are passed from run_one_function() to provide context about the execution. Tools can use these for optimization or special handling.
For backward compatibility, tools that don’t accept these parameters will still work - they will only receive the arguments parameter.