MemoriesSchemas.sys.mjs (3345B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ 4 5 import { CATEGORIES_LIST, INTENTS_LIST } from "./MemoriesConstants.sys.mjs"; 6 7 /** 8 * JSON Schema for initial memories generation 9 */ 10 export const INITIAL_MEMORIES_SCHEMA = { 11 type: "array", 12 minItems: 1, 13 items: { 14 type: "object", 15 additionalProperties: false, 16 required: [ 17 "category", 18 "intent", 19 "memory_summary", 20 "score", 21 "why", 22 "evidence", 23 ], 24 properties: { 25 category: { 26 type: ["string", "null"], 27 enum: [...CATEGORIES_LIST, null], 28 }, 29 intent: { 30 type: ["string", "null"], 31 enum: [...INTENTS_LIST, null], 32 }, 33 memory_summary: { type: ["string", "null"] }, 34 score: { type: "integer" }, 35 36 why: { type: "string", minLength: 12, maxLength: 200 }, 37 38 evidence: { 39 type: "array", 40 minItems: 1, 41 maxItems: 4, 42 items: { 43 type: "object", 44 required: ["type", "value"], 45 additionalProperties: false, 46 properties: { 47 type: { 48 type: "string", 49 enum: ["domain", "title", "search", "chat", "user"], 50 }, 51 value: { type: "string" }, 52 weight: { type: "number", minimum: 0, maximum: 1 }, 53 session_ids: { 54 type: "array", 55 items: { type: ["integer", "string"] }, 56 }, 57 }, 58 }, 59 }, 60 }, 61 }, 62 }; 63 64 /** 65 * JSON Schema for memories deduplication 66 */ 67 export const MEMORIES_DEDUPLICATION_SCHEMA = { 68 type: "array", 69 minItems: 1, 70 items: { 71 type: "object", 72 additionalProperties: false, 73 required: ["unique_memories"], 74 properties: { 75 unique_memories: { 76 type: "array", 77 minItems: 1, 78 items: { 79 type: "object", 80 additionalProperties: false, 81 required: ["main_memory", "duplicates"], 82 properties: { 83 main_memory: { type: "string" }, 84 duplicates: { 85 type: "array", 86 minItems: 1, 87 items: { type: "string" }, 88 }, 89 }, 90 }, 91 }, 92 }, 93 }, 94 }; 95 96 /** 97 * JSON schema for filtering sensitive memories 98 */ 99 export const MEMORIES_NON_SENSITIVE_SCHEMA = { 100 type: "array", 101 minItems: 1, 102 items: { 103 type: "object", 104 additionalProperties: false, 105 required: ["non_sensitive_memories"], 106 properties: { 107 non_sensitive_memories: { 108 type: "array", 109 minItems: 1, 110 items: { type: "string" }, 111 }, 112 }, 113 }, 114 }; 115 116 /** 117 * JSON schema for classifying message category and intent 118 */ 119 export const MEMORIES_MESSAGE_CLASSIFY_SCHEMA = { 120 name: "ClassifyMessage", 121 schema: { 122 type: "object", 123 additionalProperties: false, 124 required: ["categories", "intents"], 125 properties: { 126 category: { 127 type: "array", 128 minItems: 1, 129 items: { 130 type: ["string", "null"], 131 enum: [...CATEGORIES_LIST, null], 132 }, 133 }, 134 intent: { 135 type: "array", 136 minItems: 1, 137 items: { 138 type: ["string", "null"], 139 enum: [...INTENTS_LIST, null], 140 }, 141 }, 142 }, 143 }, 144 };