mirror of
https://github.com/KeygraphHQ/shannon.git
synced 2026-10-04 07:16:52 +02:00
feat: support custom pi model configs, with registry-resolvable model IDs and distinct model error codes (#450)
This commit is contained in:
1 parent
4b8131fdd5
commit
d41d52f17d
20 files changed
+441
-124
No files matched your search
+31
-2
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Path resolution for --repo and --config arguments.
|
||||
* Path resolution for --repo, --config and --models-config arguments.
|
||||
*
|
||||
* Both --repo and --config are filesystem paths, absolute or relative to CWD.
|
||||
* All three are filesystem paths, absolute or relative to CWD.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
@@ -108,3 +108,32 @@ export function resolveConfig(configArg: string): MountPair {
|
||||
containerPath: `/app/configs/${basename}`,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Container path for a mounted pi model config. Fixed, not derived from the host filename:
|
||||
* the worker detects the file here to decide whether models.json is enabled at all. Must
|
||||
* match MODELS_CONFIG_PATH in the worker package.
|
||||
*/
|
||||
export const MODELS_CONFIG_CONTAINER_PATH = '/app/models.json';
|
||||
|
||||
/**
|
||||
* Resolve --models-config to an absolute path and container mount. Content is left
|
||||
* unparsed: pi's models.json permits comments, so JSON.parse would reject valid input,
|
||||
* and pi's own loader reports schema faults far better — the worker surfaces those.
|
||||
*/
|
||||
export function resolveModelsConfig(modelsConfigArg: string): MountPair {
|
||||
const hostPath = path.resolve(expandHome(modelsConfigArg));
|
||||
|
||||
if (!fs.existsSync(hostPath)) {
|
||||
fail(`Model config file not found: ${hostPath}`);
|
||||
}
|
||||
|
||||
if (!fs.statSync(hostPath).isFile()) {
|
||||
fail(`Not a file: ${hostPath}`);
|
||||
}
|
||||
|
||||
return {
|
||||
hostPath,
|
||||
containerPath: MODELS_CONFIG_CONTAINER_PATH,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user