freddie 0.0.108 → 0.0.110
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
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { createRequire } from 'module'
|
|
2
1
|
import { getConfigValue } from '../config.js'
|
|
3
2
|
import { MATRIX_FILE } from './model-matrix.js'
|
|
4
3
|
import { callLLM as bridgeCall, isReachable as bridgeReachable } from './acptoapi-bridge.js'
|
|
4
|
+
import * as sdkNs from 'acptoapi'
|
|
5
5
|
export { matrixUsable } from './model-matrix.js'
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const _require = createRequire(import.meta.url)
|
|
14
|
-
sdk = _require('acptoapi') || {}
|
|
15
|
-
} catch {
|
|
16
|
-
sdk = {}
|
|
17
|
-
}
|
|
7
|
+
// `acptoapi` is externalized by vite (browser) so the host environment
|
|
8
|
+
// supplies it (thebird ships docs/lib/acptoapi-browser.js via importmap).
|
|
9
|
+
// Node CLI gets the real CJS package. Defensive `|| {}` keeps the bundle
|
|
10
|
+
// boot-safe if either env hands back an empty namespace.
|
|
11
|
+
const sdk = (sdkNs && (sdkNs.default || sdkNs)) || {}
|
|
18
12
|
|
|
19
13
|
export const PROVIDER_KEYS = sdk.PROVIDER_KEYS || {}
|
|
20
14
|
export const DEFAULTS = sdk.PROVIDER_DEFAULTS || {}
|
|
@@ -38,7 +32,7 @@ function adapt(result) {
|
|
|
38
32
|
// Mirror lib/named-chains.js BUILTIN — acptoapi resolves unknown names.
|
|
39
33
|
const NAMED_CHAIN_NAMES = new Set(['fast', 'cheap', 'smart', 'reasoning', 'free', 'local', 'auto'])
|
|
40
34
|
|
|
41
|
-
function buildModel({ provider, model, inputModel }) {
|
|
35
|
+
async function buildModel({ provider, model, inputModel }) {
|
|
42
36
|
if (provider) return `${provider}/${model || DEFAULTS[provider] || ''}`.replace(/\/$/, '')
|
|
43
37
|
if (model) return model
|
|
44
38
|
if (inputModel) {
|
|
@@ -57,12 +51,14 @@ function buildModel({ provider, model, inputModel }) {
|
|
|
57
51
|
const auto = typeof sdk.buildAutoChain === 'function' ? sdk.buildAutoChain(undefined) : []
|
|
58
52
|
const keyed = Array.isArray(auto) ? auto.filter(l => { const p = l.model.split('/')[0]; const env = PROVIDER_KEYS[p]; return env && process.env[env] }) : []
|
|
59
53
|
if (keyed.length) return keyed.map(l => l.model).join(', ')
|
|
54
|
+
// No local provider keys — delegate to acptoapi if reachable.
|
|
55
|
+
if (await bridgeReachable()) return process.env.FREDDIE_LLM_MODEL || 'auto'
|
|
60
56
|
return null
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
export function resolveCallLLM({ provider, model } = {}) {
|
|
64
60
|
return async (input) => {
|
|
65
|
-
const m = buildModel({ provider, model, inputModel: input.model })
|
|
61
|
+
const m = await buildModel({ provider, model, inputModel: input.model })
|
|
66
62
|
if (!m) {
|
|
67
63
|
const status = typeof sdk.getStatus === 'function' ? sdk.getStatus().map(s => `${s.provider}(ok=${s.ok},fails=${s.failCount})`).join(', ') : ''
|
|
68
64
|
throw new Error('no LLM backend reachable: set a provider API key or start acptoapi (http://127.0.0.1:4800/v1)' + (status ? ' | sampler: ' + status : ''))
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// Upstream model enumeration lives in acptoapi. This module is a thin shim
|
|
2
2
|
// over GET /v1/models so freddie has zero direct vendor connectivity.
|
|
3
|
-
import { createRequire } from 'module'
|
|
4
3
|
import { getAcptoapiUrl } from './acptoapi-bridge.js'
|
|
5
4
|
import { saveConfigValue, getConfigValue } from '../config.js'
|
|
6
5
|
import { logger } from '../observability/log.js'
|
|
6
|
+
import * as _sdkNs from 'acptoapi'
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const _sdk = _require('acptoapi')
|
|
8
|
+
const _sdk = (_sdkNs && (_sdkNs.default || _sdkNs)) || {}
|
|
10
9
|
const log = logger('model-discovery')
|
|
11
10
|
|
|
12
11
|
const NON_KEY_PROVIDERS = ['claude-cli', 'kilo', 'opencode', 'ollama']
|