tooluniverse.openalex_tool module

class tooluniverse.openalex_tool.BaseTool(tool_config)[source][source]

Bases: object

__init__(tool_config)[source][source]
classmethod get_default_config_file()[source][source]

Get the path to the default configuration file for this tool type.

This method uses a robust path resolution strategy that works across different installation scenarios:

  1. Installed packages: Uses importlib.resources for proper package resource access

  2. Development mode: Falls back to file-based path resolution

  3. Legacy Python: Handles importlib.resources and importlib_resources

Override this method in subclasses to specify a custom defaults file.

Returns:

Path or resource object pointing to the defaults file

classmethod load_defaults_from_file()[source][source]

Load defaults from the configuration file

run(arguments=None)[source][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.

check_function_call(function_call_json)[source][source]
get_required_parameters()[source][source]

Retrieve required parameters from the endpoint definition. Returns: list: List of required parameters for the given endpoint.

tooluniverse.openalex_tool.register_tool(tool_type_name=None, config=None)[source][source]

Decorator to automatically register tool classes and their configs.

Usage:

@register_tool(‘CustomToolName’, config={…}) class MyTool:

pass

class tooluniverse.openalex_tool.OpenAlexTool(tool_config)[source][source]

Bases: BaseTool

Tool to retrieve literature from OpenAlex based on search keywords.

__init__(tool_config)[source][source]
run(arguments)[source][source]

Main entry point for the tool.

search_literature(search_keywords, max_results=10, year_from=None, year_to=None, open_access=None)[source][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 of dictionaries containing paper information.

Return type:

list

get_paper_by_doi(doi)[source][source]

Retrieve a specific paper by its DOI.

Parameters:

doi (str) – DOI of the paper to retrieve.

Returns:

Paper information or None if not found.

Return type:

dict

get_papers_by_author(author_name, max_results=10)[source][source]

Retrieve papers by a specific author.

Parameters:
  • author_name (str) – Name of the author to search for.

  • max_results (int) – Maximum number of results to return.

Returns:

List of papers by the author.

Return type:

list