59 lines
2.2 KiB
C
59 lines
2.2 KiB
C
|
#ifndef HUMANUS_TOOL_MEMORY_UPDATE_H
|
||
|
#define HUMANUS_TOOL_MEMORY_UPDATE_H
|
||
|
|
||
|
namespace humanus {
|
||
|
|
||
|
struct MemoryUpdate : BaseTool {
|
||
|
inline static const std::string name_ = "memory_update";
|
||
|
inline static const std::string description_ = "Compare newly retrieved facts with the existing memory. For each new fact, decide whether to:\n- ADD: Add it to the memory as a new element\n- UPDATE: Update an existing memory element\n- DELETE: Delete an existing memory element\n- NONE: Make no change (if the fact is already present or irrelevant)";
|
||
|
inline static const json parameters = json::parse(R"json({
|
||
|
"type": "object",
|
||
|
"properties": {
|
||
|
"memory": {
|
||
|
"description": "List of memory operations.",
|
||
|
"type": "array",
|
||
|
"items": {
|
||
|
"type": "object",
|
||
|
"properties": {
|
||
|
"id": {
|
||
|
"description": "Unique integer ID of the memory item, required by event UPDATE and DELETE",
|
||
|
"type": "number"
|
||
|
},
|
||
|
"text": {
|
||
|
"description": "Plain text fact to ADD, UPDATE or DELETE",
|
||
|
"type": "string"
|
||
|
},
|
||
|
"event": {
|
||
|
"description": "The type of the operation",
|
||
|
"type": "string",
|
||
|
"enum": [
|
||
|
"ADD",
|
||
|
"UPDATE",
|
||
|
"DELETE",
|
||
|
"NONE"
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
"required": [
|
||
|
"text",
|
||
|
"event"
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"required": [
|
||
|
"memory"
|
||
|
],
|
||
|
"additionalProperties": false
|
||
|
})json");
|
||
|
|
||
|
MemoryUpdate() : BaseTool(name_, description_, parameters) {}
|
||
|
|
||
|
ToolResult execute(const json& arguments) override {
|
||
|
return ToolResult(arguments["memory"]);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
} // namespace humanus
|
||
|
|
||
|
#endif // HUMANUS_TOOL_MEMORY_UPDATE_H
|