feat: Add Tools with the objetive to create schedules
This commit is contained in:
@@ -24,7 +24,10 @@ class NaliiaTools:
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
self.get_current_datetime,
|
self.get_current_datetime,
|
||||||
self.schedule_appointment
|
self.get_tomorrow_date,
|
||||||
|
self.schedule_appointment,
|
||||||
|
self.find_service_centers,
|
||||||
|
self.find_products_and_services
|
||||||
]
|
]
|
||||||
|
|
||||||
@tool
|
@tool
|
||||||
@@ -35,9 +38,9 @@ class NaliiaTools:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
td = timedelta(days=1)
|
td = timedelta(days=1)
|
||||||
tomorrow = datetime.now().date + td
|
tomorrow = datetime.now().date() + td
|
||||||
|
|
||||||
return tomorrow
|
return tomorrow.isoformat()
|
||||||
|
|
||||||
@tool
|
@tool
|
||||||
def get_current_datetime() -> str:
|
def get_current_datetime() -> str:
|
||||||
@@ -50,6 +53,63 @@ class NaliiaTools:
|
|||||||
|
|
||||||
return datetime.now(tz=ZoneInfo(TIMEZONE)).isoformat()
|
return datetime.now(tz=ZoneInfo(TIMEZONE)).isoformat()
|
||||||
|
|
||||||
|
@tool
|
||||||
|
def find_service_centers():
|
||||||
|
"""
|
||||||
|
Obtiene los centros de servicios disponibles.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
response=[{
|
||||||
|
'id': 1,
|
||||||
|
'name': Campo Amor
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 2,
|
||||||
|
'name': Belen
|
||||||
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
async def call_tool():
|
||||||
|
async with _MCP_CLIENT:
|
||||||
|
result = await _MCP_CLIENT.call_tool(
|
||||||
|
"find_service_centers", None)
|
||||||
|
logger.info(result.content[0].text)
|
||||||
|
|
||||||
|
return result
|
||||||
|
result = asyncio.run(call_tool())
|
||||||
|
return result.content[0].text
|
||||||
|
|
||||||
|
|
||||||
|
@tool
|
||||||
|
def find_products_and_services():
|
||||||
|
"""
|
||||||
|
Obtiene los productos disponibles.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
response=[{
|
||||||
|
'id': 1,
|
||||||
|
'name': Manicure,
|
||||||
|
'price': 20000.00,
|
||||||
|
'description': None
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 2,
|
||||||
|
'name': Corte de Cabello,
|
||||||
|
'price': 30000.00,
|
||||||
|
'description': "Corte frances, aleman"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
async def call_tool():
|
||||||
|
async with _MCP_CLIENT:
|
||||||
|
result = await _MCP_CLIENT.call_tool(
|
||||||
|
"find_products_and_services", None)
|
||||||
|
logger.info(result.content[0].text)
|
||||||
|
|
||||||
|
return result
|
||||||
|
result = asyncio.run(call_tool())
|
||||||
|
return result.content[0].text
|
||||||
|
|
||||||
@tool(args_schema=ScheduleSchema)
|
@tool(args_schema=ScheduleSchema)
|
||||||
def schedule_appointment(
|
def schedule_appointment(
|
||||||
schedule_date, schedule_time,
|
schedule_date, schedule_time,
|
||||||
|
|||||||
Reference in New Issue
Block a user