feat(event-agent): update events function
This commit is contained in:
@ -17,40 +17,32 @@ const eventPrompt = `
|
|||||||
|
|
||||||
**Primary Goal:** To analyze images, identify potential events (like meetings, appointments, conferences, invitations), extract key details (name, date/time, location description), check against existing events, retrieve location identifiers if applicable, create new event entries when necessary, and signal completion using the 'finish' tool.
|
**Primary Goal:** To analyze images, identify potential events (like meetings, appointments, conferences, invitations), extract key details (name, date/time, location description), check against existing events, retrieve location identifiers if applicable, create new event entries when necessary, and signal completion using the 'finish' tool.
|
||||||
|
|
||||||
**Input:** You will be given an image that may contain information about an event, including details like name, date, time, and location.
|
|
||||||
|
|
||||||
**Core Workflow:**
|
**Core Workflow:**
|
||||||
|
|
||||||
1. **Image Analysis & Detail Extraction:**
|
**Duplicate Check (Mandatory if Event Found):**
|
||||||
* Carefully scan the image to identify potential event information.
|
* If potential event details were found, you **must** call the listEvents tool first to check for duplicates. **Generate only the listEvents tool call structure.**
|
||||||
* Extract key details: Event Name/Title, Start Date/Time, End Date/Time (if specified), and any Location Description mentioned.
|
|
||||||
* **If NO identifiable event information (Name and/or Date/Time) is found, proceed directly to Step 6 (call finish).** A location alone is not sufficient to trigger event creation.
|
|
||||||
|
|
||||||
2. **Duplicate Check (Mandatory if Event Found):**
|
|
||||||
* If potential event details were found, you **must** call the listEvents tool first to check for duplicates. **Generate only the listEvents tool call structure.**
|
|
||||||
* Once you receive the list, compare the extracted event details (Name, Start Date/Time primarily) against the existing events.
|
* Once you receive the list, compare the extracted event details (Name, Start Date/Time primarily) against the existing events.
|
||||||
* **If a matching event already exists, proceed directly to Step 6 (call finish).**
|
* **If a matching event already exists, proceed directly to Step 6 (call finish).**
|
||||||
|
|
||||||
3. **Location ID Retrieval (Conditional):**
|
**Location ID Retrieval (Conditional):**
|
||||||
* If the event is identified as *new* (Step 2) AND a *location description* was extracted (Step 1):
|
* If the event is identified as *new* AND a *location description* was extracted.
|
||||||
* Call the getEventLocationId tool, providing the extracted location description. **Generate only the getEventLocationId tool call structure.**
|
* Call the getEventLocationId tool, providing the extracted location description. **Generate only the getEventLocationId tool call structure.**
|
||||||
* Await the result containing the locationId. If the tool fails or doesn't return a locationId, proceed to Step 4 but omit the locationId.
|
|
||||||
|
|
||||||
4. **Create New Event (Conditional):**
|
**Create Event:**
|
||||||
* If the event was identified as *new* (Step 2):
|
* If the event was identified as *new*:
|
||||||
* Prepare the parameters for the createEvent tool using the extracted details (Name, Start Date/Time, End Date/Time).
|
* Prepare the parameters for the createEvent tool using the extracted details (Name, Start Date/Time, End Date/Time).
|
||||||
* If a locationId was successfully retrieved in Step 3, include it.
|
* If you identify the event as *duplicate*, meaning you think an event in listEvents is the same as the event on this image.
|
||||||
* Call the createEvent tool. **Generate only the createEvent tool call structure.**
|
* Call the updateEvent tool so this image is also linked to that event. If you find any new information you can update it using this tool too.
|
||||||
|
|
||||||
5. **Handling Multiple Events:**
|
**Handling Multiple Events:**
|
||||||
* If the image contains multiple distinct events, ideally process them one by one following steps 1-4 (or 1-2 then 6) for each before finishing. (Current structure implies one event per image interaction leading to finish).
|
* If the image contains multiple distinct events, ideally process them one by one.
|
||||||
|
* Do this until there are no more events on this image
|
||||||
|
|
||||||
6. **Task Completion / No Action Needed:**
|
**Task Completion / No Action Needed:**
|
||||||
* Call the finish tool **only** when one of the following conditions is met:
|
* Call the finish tool **only** when one of the following conditions is met:
|
||||||
* No identifiable event information was found in the initial image analysis (Step 1).
|
* No identifiable event information was found in the initial image analysis.
|
||||||
* The listEvents check confirmed the identified event already exists (Step 2).
|
* The listEvents check confirmed the identified event already exists.
|
||||||
* You have successfully called createEvent for a new event (Step 4).
|
* You have successfully called createEvent for a new event.
|
||||||
* **Generate only the finish tool call structure.**
|
|
||||||
|
|
||||||
**Available Tools:**
|
**Available Tools:**
|
||||||
|
|
||||||
@ -103,6 +95,24 @@ const eventTools = `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
|
"name": "updateEvent",
|
||||||
|
"description": "Updates an existing event record identified by its eventId. Use this tool when listEvents indicates a match for the event details found in the current input.",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"eventId": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The UUID of the existing event"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["eventId"]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
@ -142,7 +152,7 @@ type createEventArguments struct {
|
|||||||
OrganizerName *string `json:"organizerName"`
|
OrganizerName *string `json:"organizerName"`
|
||||||
LocationID *string `json:"locationId"`
|
LocationID *string `json:"locationId"`
|
||||||
}
|
}
|
||||||
type linkEventArguments struct {
|
type updateEventArguments struct {
|
||||||
EventID string `json:"eventId"`
|
EventID string `json:"eventId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +217,8 @@ func NewEventAgent(log *log.Logger, eventsModel models.EventModel, locationModel
|
|||||||
return events, nil
|
return events, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
agentClient.ToolHandler.AddTool("linkEvent", func(info client.ToolHandlerInfo, _args string, call client.ToolCall) (any, error) {
|
agentClient.ToolHandler.AddTool("updateEvent", func(info client.ToolHandlerInfo, _args string, call client.ToolCall) (any, error) {
|
||||||
args := linkEventArguments{}
|
args := updateEventArguments{}
|
||||||
err := json.Unmarshal([]byte(_args), &args)
|
err := json.Unmarshal([]byte(_args), &args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
Reference in New Issue
Block a user