mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 22:03:58 +00:00
Add comprehensive test suite for Provider module to ensure safe refactoring of provider internals. Tests cover: - Provider loading from env vars and config - Provider filtering (disabled_providers, enabled_providers) - Model whitelist/blacklist - Model aliasing and custom providers - getModel, getProvider, closest, defaultModel functions Also adds Env module for instance-scoped environment variable access, enabling isolated test environments without global state pollution.
27 lines
512 B
TypeScript
27 lines
512 B
TypeScript
import { Instance } from "../project/instance"
|
|
|
|
export namespace Env {
|
|
const state = Instance.state(() => {
|
|
return { ...process.env } as Record<string, string | undefined>
|
|
})
|
|
|
|
export function get(key: string) {
|
|
const env = state()
|
|
return env[key]
|
|
}
|
|
|
|
export function all() {
|
|
return state()
|
|
}
|
|
|
|
export function set(key: string, value: string) {
|
|
const env = state()
|
|
env[key] = value
|
|
}
|
|
|
|
export function remove(key: string) {
|
|
const env = state()
|
|
delete env[key]
|
|
}
|
|
}
|