refactor: drop redundant credentials cache and unused deps
- stream: passively rebuild stale/missing models cache on request - oauth: read identity from pi's auth.json instead of self-managed cache - deps: remove unused js-tiktoken; move esbuild to devDependencies
This commit is contained in:
+8
-1
@@ -9,7 +9,7 @@ import type {
|
||||
} from "@earendil-works/pi-ai";
|
||||
import * as PiAi from "@earendil-works/pi-ai";
|
||||
import { buildAuthHeaders, getMachineId } from "./cosy.js";
|
||||
import { getCachedModelConfig } from "./models.js";
|
||||
import { getCachedModelConfig, isCacheStale, updateQoderModelsCache } from "./models.js";
|
||||
import { getCachedCredentials } from "./oauth.js";
|
||||
import { qoderEncodeBody } from "./qoder-encoding.js";
|
||||
import { ThinkingTagParser } from "./thinking-parser.js";
|
||||
@@ -90,6 +90,13 @@ export function streamQoder(
|
||||
const email = cachedCreds?.email || "user@qoder.com";
|
||||
const machineID = cachedCreds?.machineID || getMachineId();
|
||||
|
||||
// Passively rebuild the models cache if it's missing or stale.
|
||||
// Login/refresh are the only other rebuild triggers, so without this a
|
||||
// deleted cache file never gets recreated while the token stays valid.
|
||||
if (isCacheStale()) {
|
||||
updateQoderModelsCache(accessToken, userID, name, email).catch(() => {});
|
||||
}
|
||||
|
||||
const qoderModel = model.id;
|
||||
const modelConfig = getCachedModelConfig(qoderModel) || {
|
||||
key: qoderModel,
|
||||
|
||||
Reference in New Issue
Block a user