from HeGFlow.graph.tool_node import Tool_node
from typing import Union
from typing import Any
from local_datasets.TravelPlanner.tools.cities.apis import Cities

class Cities_tool(Tool_node):
    def __init__(self):
        super().__init__(
            name="Cities",
            
        )

    async def _execute_tool(self, task:str) -> str:

        cities_api = Cities(path="")

        if cities_api.data is not None:
            state_name = "California"
            results = cities_api.run(state_name)

            if isinstance(results, str) and "ValueError" in results:
                print(results)  # Print the error message
            else:
                print(f"Cities in {state_name}:")
                print(results)

            invalid_state = "InvalidState"
            results = cities_api.run(invalid_state)
            print(f"\nTrying to get cities for invalid state '{invalid_state}':")
            print(results)

    