| 2036 | returns: ARGUMENT_TYPE.LIST, | 2037 | returns: ARGUMENT_TYPE.LIST, |
| 2037 | })); | 2038 | })); |
| 2038 | | 2039 | |
| | 2040 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| | 2041 | name: 'vector-threshold', |
| | 2042 | helpString: 'Set the vector score threshold or return the current threshold if no argument is provided.', |
| | 2043 | returns: 'score threshold value', |
| | 2044 | unnamedArgumentList: [ |
| | 2045 | SlashCommandArgument.fromProps({ |
| | 2046 | description: 'Score threshold (number).', |
| | 2047 | typeList: [ARGUMENT_TYPE.NUMBER], |
| | 2048 | }), |
| | 2049 | ], |
| | 2050 | callback: async (_args, value) => { |
| | 2051 | const raw = String(value ?? '').trim(); |
| | 2052 | if (!raw) { |
| | 2053 | return String(settings.score_threshold); |
| | 2054 | } |
| | 2055 | |
| | 2056 | const parsed = Number(raw); |
| | 2057 | if (!Number.isFinite(parsed) || parsed < 0 || parsed > 1) { |
| | 2058 | toastr.warning('Score threshold must be a number between 0 and 1.'); |
| | 2059 | return ''; |
| | 2060 | } |
| | 2061 | |
| | 2062 | $('#vectors_score_threshold') |
| | 2063 | .val(parsed) |
| | 2064 | .trigger('input'); |
| | 2065 | |
| | 2066 | return String(settings.score_threshold); |
| | 2067 | }, |
| | 2068 | })); |
| | 2069 | |
| | 2070 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| | 2071 | name: 'vector-query', |
| | 2072 | helpString: 'Set the vector query messages or returns the current query messages count if no argument is provided', |
| | 2073 | returns: 'the query messages value', |
| | 2074 | unnamedArgumentList: [ |
| | 2075 | SlashCommandArgument.fromProps({ |
| | 2076 | description: 'Query messages (number >= 0).', |
| | 2077 | typeList: [ARGUMENT_TYPE.NUMBER], |
| | 2078 | }), |
| | 2079 | ], |
| | 2080 | callback: async (_args, value) => { |
| | 2081 | const raw = String(value ?? '').trim(); |
| | 2082 | if (!raw) { |
| | 2083 | return String(settings.query); |
| | 2084 | } |
| | 2085 | |
| | 2086 | const parsed = Number(raw); |
| | 2087 | if (!Number.isFinite(parsed) || parsed < 0) { |
| | 2088 | toastr.warning('Query messages must be a number greater than or equal to 0.'); |
| | 2089 | return ''; |
| | 2090 | } |
| | 2091 | |
| | 2092 | $('#vectors_query') |
| | 2093 | .val(parsed) |
| | 2094 | .trigger('input'); |
| | 2095 | |
| | 2096 | return String(settings.query); |
| | 2097 | }, |
| | 2098 | })); |
| | 2099 | |
| | 2100 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| | 2101 | name: 'vector-max-entries', |
| | 2102 | helpString: 'Set the vector world info max entries or returns the current max entries if no argument is provided', |
| | 2103 | returns: 'world info max entries', |
| | 2104 | unnamedArgumentList: [ |
| | 2105 | SlashCommandArgument.fromProps({ |
| | 2106 | description: 'Max entries (number >= 0).', |
| | 2107 | typeList: [ARGUMENT_TYPE.NUMBER], |
| | 2108 | }), |
| | 2109 | ], |
| | 2110 | callback: async (_args, value) => { |
| | 2111 | const raw = String(value ?? '').trim(); |
| | 2112 | if (!raw) { |
| | 2113 | return String(settings.max_entries); |
| | 2114 | } |
| | 2115 | |
| | 2116 | const parsed = Number(raw); |
| | 2117 | if (!Number.isFinite(parsed) || parsed <= 0) { |
| | 2118 | toastr.warning('Max entries must be a number greater than 0.'); |
| | 2119 | return ''; |
| | 2120 | } |
| | 2121 | |
| | 2122 | $('#vectors_max_entries') |
| | 2123 | .val(parsed) |
| | 2124 | .trigger('input'); |
| | 2125 | |
| | 2126 | return String(settings.max_entries); |
| | 2127 | }, |
| | 2128 | })); |
| | 2129 | |
| | 2130 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| | 2131 | name: 'vector-chats-state', |
| | 2132 | helpString: 'Set whether chat vectorization is enabled or return the current boolean if no argument is provided', |
| | 2133 | returns: 'boolean for if chat vectorization is enabled', |
| | 2134 | unnamedArgumentList: [ |
| | 2135 | SlashCommandArgument.fromProps({ |
| | 2136 | description: 'boolean to set whether chat vectorization is enabled', |
| | 2137 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| | 2138 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| | 2139 | }), |
| | 2140 | ], |
| | 2141 | callback: async (_args, value) => { |
| | 2142 | const raw = String(value ?? '').trim(); |
| | 2143 | if (!raw) { |
| | 2144 | return String(settings.enabled_chats); |
| | 2145 | } |
| | 2146 | |
| | 2147 | const parsed = isTrueBoolean(raw); |
| | 2148 | $('#vectors_enabled_chats') |
| | 2149 | .prop('checked', parsed) |
| | 2150 | .trigger('input'); |
| | 2151 | |
| | 2152 | return String(settings.enabled_chats); |
| | 2153 | }, |
| | 2154 | })); |
| | 2155 | |
| | 2156 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| | 2157 | name: 'vector-files-state', |
| | 2158 | helpString: 'Set whether file vectorization is enabled or return the current boolean if no argument is provided', |
| | 2159 | returns: 'boolean for if file vectorization is enabled', |
| | 2160 | unnamedArgumentList: [ |
| | 2161 | SlashCommandArgument.fromProps({ |
| | 2162 | description: 'boolean to set whether file vectorization is enabled', |
| | 2163 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| | 2164 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| | 2165 | }), |
| | 2166 | ], |
| | 2167 | callback: async (_args, value) => { |
| | 2168 | const raw = String(value ?? '').trim(); |
| | 2169 | if (!raw) { |
| | 2170 | return String(settings.enabled_files); |
| | 2171 | } |
| | 2172 | |
| | 2173 | const parsed = isTrueBoolean(raw) ; |
| | 2174 | $('#vectors_enabled_files') |
| | 2175 | .prop('checked', parsed) |
| | 2176 | .trigger('input'); |
| | 2177 | |
| | 2178 | return String(settings.enabled_files); |
| | 2179 | }, |
| | 2180 | })); |
| | 2181 | |
| | 2182 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| | 2183 | name: 'vector-worldinfo-state', |
| | 2184 | helpString: 'Set whether world info vectorization is enabled or return the current boolean if no argument is provided', |
| | 2185 | returns: 'boolean for if world info vectorization is enabled', |
| | 2186 | unnamedArgumentList: [ |
| | 2187 | SlashCommandArgument.fromProps({ |
| | 2188 | description: 'boolean to set whether world info vectorization is enabled', |
| | 2189 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| | 2190 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| | 2191 | }), |
| | 2192 | ], |
| | 2193 | callback: async (_args, value) => { |
| | 2194 | const raw = String(value ?? '').trim(); |
| | 2195 | if (!raw) { |
| | 2196 | return String(settings.enabled_world_info); |
| | 2197 | } |
| | 2198 | |
| | 2199 | const parsed = isTrueBoolean(raw); |
| | 2200 | $('#vectors_enabled_world_info') |
| | 2201 | .prop('checked', parsed) |
| | 2202 | .trigger('input'); |
| | 2203 | |
| | 2204 | return String(settings.enabled_world_info); |
| | 2205 | }, |
| | 2206 | })); |
| | 2207 | |
| 2039 | registerDebugFunction('purge-everything', 'Purge all vector indices', 'Obliterate all stored vectors for all sources. No mercy.', async () => { | 2208 | registerDebugFunction('purge-everything', 'Purge all vector indices', 'Obliterate all stored vectors for all sources. No mercy.', async () => { |
| 2040 | if (!confirm('Are you sure?')) { | 2209 | if (!confirm('Are you sure?')) { |
| 2041 | return; | 2210 | return; |