ai_co_discuss 0.3.64 → 0.3.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -260,20 +260,21 @@ function executable_stamp(profile) {
|
|
|
260
260
|
* The model and effort a software runs with when the card leaves them empty. One read from its own settings is
|
|
261
261
|
* cheap and always fresh; one that must run the CLI (agy) is kept for a day, because each run may refresh the
|
|
262
262
|
* software's login and, when that refresh fails, it opens a browser sign-in. `refresh` reads it again.
|
|
263
|
+
* agy updates itself often, so the key leaves out the executable stamp; a failed run is recorded too and keeps the
|
|
264
|
+
* last good answer, so a run that cannot sign in is not repeated on every room read.
|
|
263
265
|
*/
|
|
264
266
|
export async function cached_software_defaults(home, profile, { refresh = false, query = software_defaults } = {}) {
|
|
265
267
|
if (!adapter_profile(profile.adapter)?.defaults_by_query) return query(profile);
|
|
266
268
|
const path = join(home, 'model-catalogs.json');
|
|
267
|
-
const key = JSON.stringify([profile.adapter, profile.executable || ''
|
|
269
|
+
const key = JSON.stringify(['defaults', profile.adapter, profile.executable || '']);
|
|
268
270
|
let cache = {};
|
|
269
271
|
try { cache = JSON.parse(readFileSync(path, 'utf8')); } catch {}
|
|
270
272
|
const entry = cache[key];
|
|
271
273
|
if (!refresh && entry && Date.now() - entry.at < MODEL_CACHE_MS) return entry.result;
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
274
|
+
const answer = await query(profile);
|
|
275
|
+
const result = answer?.model ? answer : entry?.result || answer;
|
|
276
|
+
try { cache = JSON.parse(readFileSync(path, 'utf8')); } catch {}
|
|
277
|
+
atomic_json(path, { ...cache, [key]: { at: Date.now(), result } });
|
|
277
278
|
return result;
|
|
278
279
|
}
|
|
279
280
|
|