fa-model-catalog 0.0.0-stage → 0.1.1
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/.agents/skills/deploy/config/config.example.yaml +27 -0
- package/LICENSE +21 -0
- package/README.md +62 -2
- package/catalog.example.yaml +2216 -0
- package/docs/catalog.md +27 -0
- package/docs/client.md +49 -0
- package/docs/development.md +32 -0
- package/docs/operations.md +58 -0
- package/package.json +62 -4
- package/src/catalog-schemas.js +165 -0
- package/src/catalog.js +108 -0
- package/src/cli/check.js +12 -0
- package/src/cli/server.js +49 -0
- package/src/client.js +317 -0
- package/src/pricing.js +104 -0
- package/src/schedule.js +59 -0
- package/src/server.js +124 -0
- package/src/types/client.d.ts +22 -0
- package/src/types/pricing.d.ts +15 -0
- package/src/types/server.d.ts +21 -0
- package/src/types/types.d.ts +64 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
remote:
|
|
2
|
+
host: server.example.com
|
|
3
|
+
keyPath: C:/Users/<user>/.ssh/id_rsa
|
|
4
|
+
port: 22
|
|
5
|
+
publicHost: catalog.example.com
|
|
6
|
+
repository: https://example.com/organization/model-catalog.git
|
|
7
|
+
user: root
|
|
8
|
+
access:
|
|
9
|
+
clients:
|
|
10
|
+
- id: shared
|
|
11
|
+
keys:
|
|
12
|
+
- id: primary
|
|
13
|
+
token: REPLACE_WITH_ACCESS_TOKEN
|
|
14
|
+
server:
|
|
15
|
+
accessFile: /etc/fa-model-catalog/access.yaml
|
|
16
|
+
catalogFile: /opt/model-catalog/catalog.yaml
|
|
17
|
+
host: 127.0.0.1
|
|
18
|
+
port: 3000
|
|
19
|
+
reloadIntervalMs: 5000
|
|
20
|
+
deployment:
|
|
21
|
+
appDirectory: /opt/model-catalog
|
|
22
|
+
serviceName: fa-model-catalog
|
|
23
|
+
publicPort: 443
|
|
24
|
+
branch: master
|
|
25
|
+
nginxSite: /etc/nginx/sites-enabled/catalog.example.com.conf
|
|
26
|
+
nginxSnippet: /etc/nginx/snippets/fa-model-catalog.conf
|
|
27
|
+
catalogSource: catalog.example.yaml
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bazilio-san
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Shared model and pricing catalog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The service stores model prices and capabilities in one validated file.
|
|
4
|
+
Applications retrieve entries through the package client and calculate costs directly in memory.
|
|
5
|
+
Catalog changes do not require applications to update the package.
|
|
6
|
+
|
|
7
|
+
Node.js is required; the version and dependencies are specified in the [package manifest](package.json).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-exact fa-model-catalog
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The client sends `POST /v1/models/resolve` to the configured service.
|
|
14
|
+
Set `MODEL_CATALOG_URL` to the HTTPS origin, such as `https://catalog.example.com`.
|
|
15
|
+
The client adds `/v1/models/resolve` automatically. Direct HTTP callers use the full endpoint URL.
|
|
16
|
+
|
|
17
|
+
Application connection example:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { createCatalogClient } from 'fa-model-catalog/client';
|
|
21
|
+
import { calculatePrice } from 'fa-model-catalog/pricing';
|
|
22
|
+
|
|
23
|
+
const client = createCatalogClient({
|
|
24
|
+
baseUrl: process.env.MODEL_CATALOG_URL,
|
|
25
|
+
token: process.env.MODEL_CATALOG_TOKEN,
|
|
26
|
+
models: ['gpt-6-sol'],
|
|
27
|
+
});
|
|
28
|
+
await client.start();
|
|
29
|
+
try {
|
|
30
|
+
const [record] = await client.get(['gpt-6-sol']);
|
|
31
|
+
const result = calculatePrice(record, {
|
|
32
|
+
unit: 'tokens',
|
|
33
|
+
inputTokens: 1000,
|
|
34
|
+
cachedInputTokens: 200,
|
|
35
|
+
cacheWriteInputTokens: 100,
|
|
36
|
+
outputTokens: 50,
|
|
37
|
+
});
|
|
38
|
+
console.dir(result, { depth: null });
|
|
39
|
+
} finally {
|
|
40
|
+
client.stop();
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
In a long-running application, create one client per process and stop it during shutdown.
|
|
45
|
+
Pass the key through private application settings; never include it in source files or logs.
|
|
46
|
+
|
|
47
|
+
- [Catalog structure and name lookup](docs/catalog.md).
|
|
48
|
+
- [Client, scheduling, and calculations](docs/client.md).
|
|
49
|
+
- [Startup and operations](docs/operations.md).
|
|
50
|
+
- [Development setup and project settings](docs/development.md).
|
|
51
|
+
|
|
52
|
+
The example catalog illustrates the data format; information not confirmed by the provider remains available
|
|
53
|
+
with an explanation of its limitations.
|
|
54
|
+
Publishing the package does not confirm that every rate matches the provider's current price.
|
|
55
|
+
|
|
56
|
+
Development uses the checks defined in the [package manifest](package.json):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm ci
|
|
60
|
+
npm run quality
|
|
61
|
+
npm run catalog:check
|
|
62
|
+
npm pack --dry-run
|
|
63
|
+
```
|