pyspur icon indicating copy to clipboard operation
pyspur copied to clipboard

Custom Tool creation

Open sankethgadadinni opened this issue 8 months ago • 1 comments

from pyspur.nodes.decorator import tool_function

@tool_function(
    name="united_healthcare_insurance",
    display_name="United HealthCare Tool",
    description="Checks if a United Healthcare insurance is active using API key and policyholder details.",
    category="Insurance"
)
def united_healthcare(
    api_key: str, 
    insurance_id: str, 
    first_name: str, 
    last_name: str
) -> Dict[str, Any]:
    """Simulates an API call to United Healthcare to check if the insurance is active."""
    
    # Dummy logic simulating an API response
    # In real life, you would use requests.post(...) here
    if insurance_id.startswith("UHC") and api_key:
        is_active = True
    else:
        is_active = False
    
    return {
        "insurance_id": insurance_id,
        "first_name": first_name,
        "last_name": last_name,
        "active": is_active
    }

I'm adding this file to the tools folder, but still in the logs, I get

2025-04-11 13:16:53.100 | ERROR | pyspur.nodes.registry:discover_tool_functions:198 - Tools directory does not exist: agent_workflow/tools

Am I doing something wrong?

sankethgadadinni avatar Apr 11 '25 07:04 sankethgadadinni

modify .env file env PROJECT_ROOT to ./

ZhuPeng avatar Jun 10 '25 08:06 ZhuPeng