@codesoul-co/hypha-inference / drivers
- 包索引:
@codesoul-co/hypha-inference - 源码:
packages/inference/src/drivers.ts - 导出数: 14
模块用法
用于使用该功能边界的公共契约与操作。Drivers 模块公开 3 类、7 接口、4 类型。
从包入口导入
import {
HttpLocalInferenceDriver,
LocalInferenceDriverRegistry,
NodeLocalInferenceProcessSupervisor,
} from '@codesoul-co/hypha-inference';
import type {
LocalInferenceDriver,
LocalInferenceDriverConfig,
LocalInferenceDriverStatus,
LocalInferenceHealthProbeRequest,
LocalInferenceProcessHandle,
LocalInferenceProcessSpec,
LocalInferenceProcessSupervisor,
LocalInferenceDriverMode,
} from '@codesoul-co/hypha-inference';
// 完整导出列表见下方。使用要点
- 11 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用
import type,运行时不应依赖它们。 - 3 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
HttpLocalInferenceDriver | 类 | new HttpLocalInferenceDriver(config: LocalInferenceDriverConfig, supervisor?: LocalInferenceProcessSupervisor, healthProbe?: LocalInferenceHealthProbe): HttpLocalInferenceDriver | Http Local Inference Driver 类,共公开 10 个构造函数或成员;精确签名见本条目的声明与成员表。 |
LocalInferenceDriverRegistry | 类 | new LocalInferenceDriverRegistry(): LocalInferenceDriverRegistry | Local Inference Driver Registry 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。 |
NodeLocalInferenceProcessSupervisor | 类 | new NodeLocalInferenceProcessSupervisor(): NodeLocalInferenceProcessSupervisor | Node Local Inference Process Supervisor 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。 |
LocalInferenceDriver | 接口 | interface LocalInferenceDriver | Local Inference Driver 接口,共包含 9 个公开字段或方法。 |
LocalInferenceDriverConfig | 接口 | interface LocalInferenceDriverConfig | Local Inference Driver Config 接口,共包含 17 个公开字段或方法。 |
LocalInferenceDriverStatus | 接口 | interface LocalInferenceDriverStatus | Local Inference Driver Status 接口,共包含 9 个公开字段或方法。 |
LocalInferenceHealthProbeRequest | 接口 | interface LocalInferenceHealthProbeRequest | Local Inference Health Probe Request 接口,共包含 3 个公开字段或方法。 |
LocalInferenceProcessHandle | 接口 | interface LocalInferenceProcessHandle | Local Inference Process Handle 接口,共包含 3 个公开字段或方法。 |
LocalInferenceProcessSpec | 接口 | interface LocalInferenceProcessSpec | Local Inference Process Spec 接口,共包含 4 个公开字段或方法。 |
LocalInferenceProcessSupervisor | 接口 | interface LocalInferenceProcessSupervisor | Local Inference Process Supervisor 接口,共包含 1 个公开字段或方法。 |
LocalInferenceDriverMode | 类型 | type LocalInferenceDriverMode = 'connect' | 'managed' | Local Inference Driver Mode 公共类型别名;完整类型表达式见声明。 |
LocalInferenceDriverState | 类型 | type LocalInferenceDriverState = 'idle' | 'starting' | 'ready' | 'stopping' | 'stopped' | 'failed' | Local Inference Driver State 公共类型别名;完整类型表达式见声明。 |
LocalInferenceEngineKind | 类型 | type LocalInferenceEngineKind = 'ollama' | 'sglang' | 'vllm' | Local Inference Engine Kind 公共类型别名;完整类型表达式见声明。 |
LocalInferenceHealthProbe | 类型 | type LocalInferenceHealthProbe = (request: LocalInferenceHealthProbeRequest) => Promise<boolean> | Local Inference Health Probe 公共类型别名;完整类型表达式见声明。 |
HttpLocalInferenceDriver
Http Local Inference Driver 类,共公开 10 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { HttpLocalInferenceDriver } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export declare class HttpLocalInferenceDriver implements LocalInferenceDriver {
readonly id: string;
readonly kind: LocalInferenceEngineKind;
constructor(config: LocalInferenceDriverConfig, supervisor?: LocalInferenceProcessSupervisor, healthProbe?: LocalInferenceHealthProbe);
start(model?: string | undefined): Promise<LocalInferenceDriverStatus>;
load(model: string): Promise<LocalInferenceDriverStatus>;
unload(model?: string | undefined): Promise<LocalInferenceDriverStatus>;
stop(): Promise<LocalInferenceDriverStatus>;
health(): Promise<boolean>;
status(): LocalInferenceDriverStatus;
backend(): InferenceBackend;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
backend | 方法 | backend(): InferenceBackend | 公开方法;参数与返回类型以签名列为准。 |
constructor | 构造函数 | (config: LocalInferenceDriverConfig, supervisor?: LocalInferenceProcessSupervisor, healthProbe?: LocalInferenceHealthProbe): HttpLocalInferenceDriver | 创建该类的实例。 |
health | 方法 | health(): Promise<boolean> | 公开方法;参数与返回类型以签名列为准。 |
id | 属性 | readonly id: string | 公开属性;类型、只读和可选状态以签名列为准。 |
kind | 属性 | readonly kind: LocalInferenceEngineKind | 公开属性;类型、只读和可选状态以签名列为准。 |
load | 方法 | load(model: string): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
start | 方法 | start(model?: string | undefined): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
status | 方法 | status(): LocalInferenceDriverStatus | 公开方法;参数与返回类型以签名列为准。 |
stop | 方法 | stop(): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
unload | 方法 | unload(model?: string | undefined): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
LocalInferenceDriverRegistry
Local Inference Driver Registry 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { LocalInferenceDriverRegistry } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export declare class LocalInferenceDriverRegistry {
register(driver: LocalInferenceDriver): void;
get(id: string): LocalInferenceDriver | null;
require(id: string): LocalInferenceDriver;
list(): LocalInferenceDriver[];
stopAll(): Promise<void>;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
constructor | 构造函数 | (): LocalInferenceDriverRegistry | 创建该类的实例。 |
get | 方法 | get(id: string): LocalInferenceDriver | null | 公开方法;参数与返回类型以签名列为准。 |
list | 方法 | list(): LocalInferenceDriver[] | 公开方法;参数与返回类型以签名列为准。 |
register | 方法 | register(driver: LocalInferenceDriver): void | 公开方法;参数与返回类型以签名列为准。 |
require | 方法 | require(id: string): LocalInferenceDriver | 公开方法;参数与返回类型以签名列为准。 |
stopAll | 方法 | stopAll(): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
NodeLocalInferenceProcessSupervisor
Node Local Inference Process Supervisor 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { NodeLocalInferenceProcessSupervisor } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export declare class NodeLocalInferenceProcessSupervisor implements LocalInferenceProcessSupervisor {
start(spec: LocalInferenceProcessSpec): Promise<LocalInferenceProcessHandle>;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
constructor | 构造函数 | (): NodeLocalInferenceProcessSupervisor | 创建该类的实例。 |
start | 方法 | start(spec: LocalInferenceProcessSpec): Promise<LocalInferenceProcessHandle> | 公开方法;参数与返回类型以签名列为准。 |
LocalInferenceDriver
Local Inference Driver 接口,共包含 9 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LocalInferenceDriver } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export interface LocalInferenceDriver {
readonly id: string;
readonly kind: LocalInferenceEngineKind;
start(model?: string): Promise<LocalInferenceDriverStatus>;
load(model: string): Promise<LocalInferenceDriverStatus>;
unload(model?: string): Promise<LocalInferenceDriverStatus>;
stop(): Promise<LocalInferenceDriverStatus>;
health(): Promise<boolean>;
status(): LocalInferenceDriverStatus;
backend(): InferenceBackend;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
backend | 方法 | backend(): InferenceBackend | 公开方法;参数与返回类型以签名列为准。 |
health | 方法 | health(): Promise<boolean> | 公开方法;参数与返回类型以签名列为准。 |
id | 属性 | readonly id: string | 公开属性;类型、只读和可选状态以签名列为准。 |
kind | 属性 | readonly kind: LocalInferenceEngineKind | 公开属性;类型、只读和可选状态以签名列为准。 |
load | 方法 | load(model: string): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
start | 方法 | start(model?: string): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
status | 方法 | status(): LocalInferenceDriverStatus | 公开方法;参数与返回类型以签名列为准。 |
stop | 方法 | stop(): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
unload | 方法 | unload(model?: string): Promise<LocalInferenceDriverStatus> | 公开方法;参数与返回类型以签名列为准。 |
LocalInferenceDriverConfig
Local Inference Driver Config 接口,共包含 17 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LocalInferenceDriverConfig } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export interface LocalInferenceDriverConfig {
id?: string;
kind: LocalInferenceEngineKind;
mode?: LocalInferenceDriverMode;
baseUrl?: string;
endpoint?: string;
model?: string;
host?: string;
port?: number;
command?: string;
args?: string[];
cwd?: string;
env?: Record<string, string>;
startupTimeoutMs?: number;
healthPollMs?: number;
requestTimeoutMs?: number;
apiKey?: string;
apiKeyEnv?: string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
apiKey | 属性 | apiKey?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
apiKeyEnv | 属性 | apiKeyEnv?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
args | 属性 | args?: string[] | 公开属性;类型、只读和可选状态以签名列为准。 |
baseUrl | 属性 | baseUrl?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
command | 属性 | command?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
cwd | 属性 | cwd?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
endpoint | 属性 | endpoint?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
env | 属性 | env?: Record<string, string> | 公开属性;类型、只读和可选状态以签名列为准。 |
healthPollMs | 属性 | healthPollMs?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
host | 属性 | host?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
id | 属性 | id?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
kind | 属性 | kind: LocalInferenceEngineKind | 公开属性;类型、只读和可选状态以签名列为准。 |
mode | 属性 | mode?: LocalInferenceDriverMode | 公开属性;类型、只读和可选状态以签名列为准。 |
model | 属性 | model?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
port | 属性 | port?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
requestTimeoutMs | 属性 | requestTimeoutMs?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
startupTimeoutMs | 属性 | startupTimeoutMs?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
LocalInferenceDriverStatus
Local Inference Driver Status 接口,共包含 9 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LocalInferenceDriverStatus } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export interface LocalInferenceDriverStatus {
id: string;
kind: LocalInferenceEngineKind;
mode: LocalInferenceDriverMode;
state: LocalInferenceDriverState;
baseUrl: string;
model?: string;
pid?: number;
healthy: boolean;
error?: string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
baseUrl | 属性 | baseUrl: string | 公开属性;类型、只读和可选状态以签名列为准。 |
error | 属性 | error?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
healthy | 属性 | healthy: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
id | 属性 | id: string | 公开属性;类型、只读和可选状态以签名列为准。 |
kind | 属性 | kind: LocalInferenceEngineKind | 公开属性;类型、只读和可选状态以签名列为准。 |
mode | 属性 | mode: LocalInferenceDriverMode | 公开属性;类型、只读和可选状态以签名列为准。 |
model | 属性 | model?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
pid | 属性 | pid?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
state | 属性 | state: LocalInferenceDriverState | 公开属性;类型、只读和可选状态以签名列为准。 |
LocalInferenceHealthProbeRequest
Local Inference Health Probe Request 接口,共包含 3 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LocalInferenceHealthProbeRequest } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export interface LocalInferenceHealthProbeRequest {
url: string;
headers: Record<string, string>;
timeoutMs: number;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
headers | 属性 | headers: Record<string, string> | 公开属性;类型、只读和可选状态以签名列为准。 |
timeoutMs | 属性 | timeoutMs: number | 公开属性;类型、只读和可选状态以签名列为准。 |
url | 属性 | url: string | 公开属性;类型、只读和可选状态以签名列为准。 |
LocalInferenceProcessHandle
Local Inference Process Handle 接口,共包含 3 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LocalInferenceProcessHandle } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export interface LocalInferenceProcessHandle {
readonly pid?: number;
readonly exited: Promise<{
code: number | null;
signal: NodeJS.Signals | null;
}>;
stop(graceMs?: number): Promise<void>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
exited | 属性 | readonly exited: Promise<{ code: number | null; signal: NodeJS.Signals | null; }> | 公开属性;类型、只读和可选状态以签名列为准。 |
pid | 属性 | readonly pid?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
stop | 方法 | stop(graceMs?: number): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
LocalInferenceProcessSpec
Local Inference Process Spec 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LocalInferenceProcessSpec } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export interface LocalInferenceProcessSpec {
command: string;
args: string[];
cwd?: string;
env?: Record<string, string>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
args | 属性 | args: string[] | 公开属性;类型、只读和可选状态以签名列为准。 |
command | 属性 | command: string | 公开属性;类型、只读和可选状态以签名列为准。 |
cwd | 属性 | cwd?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
env | 属性 | env?: Record<string, string> | 公开属性;类型、只读和可选状态以签名列为准。 |
LocalInferenceProcessSupervisor
Local Inference Process Supervisor 接口,共包含 1 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LocalInferenceProcessSupervisor } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export interface LocalInferenceProcessSupervisor {
start(spec: LocalInferenceProcessSpec): Promise<LocalInferenceProcessHandle>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
start | 方法 | start(spec: LocalInferenceProcessSpec): Promise<LocalInferenceProcessHandle> | 公开方法;参数与返回类型以签名列为准。 |
LocalInferenceDriverMode
Local Inference Driver Mode 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { LocalInferenceDriverMode } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export type LocalInferenceDriverMode = 'connect' | 'managed';LocalInferenceDriverState
Local Inference Driver State 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { LocalInferenceDriverState } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export type LocalInferenceDriverState = 'idle' | 'starting' | 'ready' | 'stopping' | 'stopped' | 'failed';LocalInferenceEngineKind
Local Inference Engine Kind 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { LocalInferenceEngineKind } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export type LocalInferenceEngineKind = 'ollama' | 'sglang' | 'vllm';LocalInferenceHealthProbe
Local Inference Health Probe 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { LocalInferenceHealthProbe } from '@codesoul-co/hypha-inference'; - 源码模块:
drivers
声明
export type LocalInferenceHealthProbe = (request: LocalInferenceHealthProbeRequest) => Promise<boolean>;