Skip to content

@codesoul-co/hypha-inference / manager ​

Using this module ​

Use the Manager module for using the public contracts and operations for this capability boundary. It exports 4 classes, 2 interfaces.

Import from the package entrypoint ​

ts
import {
  InferenceCacheCapacityError,
  InferenceManager,
  InMemoryKvCacheProvider,
  InMemoryPrefixCacheProvider,
} from '@codesoul-co/hypha-inference';

import type {
  InMemoryKvCacheProviderOptions,
  InMemoryPrefixCacheProviderOptions,
} from '@codesoul-co/hypha-inference';

Usage patterns ​

  • Use the 2 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 4 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports ​

SymbolKindSignatureDescription
InferenceCacheCapacityErrorclassnew InferenceCacheCapacityError(message: string): InferenceCacheCapacityErrorInference Cache Capacity Error class with 9 public constructor or member entries; its exact declarations are listed below.
InferenceManagerclassnew InferenceManager(options?: InferenceManagerOptions): InferenceManagerInference Manager class with 5 public constructor or member entries; its exact declarations are listed below.
InMemoryKvCacheProviderclassnew InMemoryKvCacheProvider(options?: InMemoryKvCacheProviderOptions): InMemoryKvCacheProviderIn Memory Kv Cache Provider class with 6 public constructor or member entries; its exact declarations are listed below.
InMemoryPrefixCacheProviderclassnew InMemoryPrefixCacheProvider(options?: InMemoryPrefixCacheProviderOptions): InMemoryPrefixCacheProviderIn Memory Prefix Cache Provider class with 5 public constructor or member entries; its exact declarations are listed below.
InMemoryKvCacheProviderOptionsinterfaceinterface InMemoryKvCacheProviderOptionsIn Memory Kv Cache Provider Options interface with 3 public fields or methods.
InMemoryPrefixCacheProviderOptionsinterfaceinterface InMemoryPrefixCacheProviderOptionsIn Memory Prefix Cache Provider Options interface with 3 public fields or methods.

InferenceCacheCapacityError ​

Inference Cache Capacity Error class with 9 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InferenceCacheCapacityError } from '@codesoul-co/hypha-inference';
  • Source module: manager

Declaration ​

text
export declare class InferenceCacheCapacityError extends Error {
    readonly code = "INFERENCE_CACHE_CAPACITY_EXCEEDED";
    constructor(message: string);
}

Public members ​

MemberKindSignatureDescription
causepropertycause?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
codepropertyreadonly code: "INFERENCE_CACHE_CAPACITY_EXCEEDED"Public property; its type, readonly modifier and optionality are shown in the signature.
constructorconstructor(message: string): InferenceCacheCapacityErrorCreates an instance of this class.
messagepropertymessage: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
namepropertyname: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stackpropertystack?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
static captureStackTracemethodstatic captureStackTrace(targetObject: object, constructorOpt?: Function): voidCreates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a();
static prepareStackTracemethodstatic prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): anyPublic method; parameters and return type are shown in the signature.
static stackTraceLimitpropertystatic stackTraceLimit: numberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

InferenceManager ​

Inference Manager class with 5 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InferenceManager } from '@codesoul-co/hypha-inference';
  • Source module: manager

Declaration ​

text
export declare class InferenceManager {
    constructor(options?: InferenceManagerOptions);
    register(provider: InferenceProvider): void;
    get(providerId: string): InferenceProvider | null;
    infer(providerId: string, request: InferenceRequest): Promise<InferenceResponse>;
    stream(providerId: string, request: InferenceRequest): AsyncIterable<InferenceResponse>;
}

Public members ​

MemberKindSignatureDescription
constructorconstructor(options?: InferenceManagerOptions): InferenceManagerCreates an instance of this class.
getmethodget(providerId: string): InferenceProvider | nullPublic method; parameters and return type are shown in the signature.
infermethodinfer(providerId: string, request: InferenceRequest): Promise<InferenceResponse>Public method; parameters and return type are shown in the signature.
registermethodregister(provider: InferenceProvider): voidPublic method; parameters and return type are shown in the signature.
streammethodstream(providerId: string, request: InferenceRequest): AsyncIterable<InferenceResponse>Public method; parameters and return type are shown in the signature.

InMemoryKvCacheProvider ​

In Memory Kv Cache Provider class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryKvCacheProvider } from '@codesoul-co/hypha-inference';
  • Source module: manager

Declaration ​

text
export declare class InMemoryKvCacheProvider implements KvCacheProvider {
    constructor(options?: InMemoryKvCacheProviderOptions);
    get(ref: KvCacheRef): Promise<unknown | null>;
    put(ref: KvCacheRef, value: unknown): Promise<void>;
    invalidate(ref: KvCacheRef): Promise<void>;
    size(): number;
    stats(): {
            entries: number;
            totalBytes: number;
        };
}

Public members ​

MemberKindSignatureDescription
constructorconstructor(options?: InMemoryKvCacheProviderOptions): InMemoryKvCacheProviderCreates an instance of this class.
getmethodget(ref: KvCacheRef): Promise<unknown | null>Public method; parameters and return type are shown in the signature.
invalidatemethodinvalidate(ref: KvCacheRef): Promise<void>Public method; parameters and return type are shown in the signature.
putmethodput(ref: KvCacheRef, value: unknown): Promise<void>Public method; parameters and return type are shown in the signature.
sizemethodsize(): numberPublic method; parameters and return type are shown in the signature.
statsmethodstats(): { entries: number; totalBytes: number; }Public method; parameters and return type are shown in the signature.

InMemoryPrefixCacheProvider ​

In Memory Prefix Cache Provider class with 5 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryPrefixCacheProvider } from '@codesoul-co/hypha-inference';
  • Source module: manager

Declaration ​

text
export declare class InMemoryPrefixCacheProvider implements PrefixCacheProvider {
    constructor(options?: InMemoryPrefixCacheProviderOptions);
    get(ref: PrefixCacheRef): Promise<string | null>;
    put(ref: PrefixCacheRef, content: string): Promise<void>;
    invalidate(ref: PrefixCacheRef): Promise<void>;
    stats(): {
            entries: number;
            totalBytes: number;
        };
}

Public members ​

MemberKindSignatureDescription
constructorconstructor(options?: InMemoryPrefixCacheProviderOptions): InMemoryPrefixCacheProviderCreates an instance of this class.
getmethodget(ref: PrefixCacheRef): Promise<string | null>Public method; parameters and return type are shown in the signature.
invalidatemethodinvalidate(ref: PrefixCacheRef): Promise<void>Public method; parameters and return type are shown in the signature.
putmethodput(ref: PrefixCacheRef, content: string): Promise<void>Public method; parameters and return type are shown in the signature.
statsmethodstats(): { entries: number; totalBytes: number; }Public method; parameters and return type are shown in the signature.

InMemoryKvCacheProviderOptions ​

In Memory Kv Cache Provider Options interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { InMemoryKvCacheProviderOptions } from '@codesoul-co/hypha-inference';
  • Source module: manager

Declaration ​

text
export interface InMemoryKvCacheProviderOptions {
    maxEntries?: number;
    maxEntryBytes?: number;
    maxTotalBytes?: number;
}

Contract members ​

MemberKindSignatureDescription
maxEntriespropertymaxEntries?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxEntryBytespropertymaxEntryBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxTotalBytespropertymaxTotalBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

InMemoryPrefixCacheProviderOptions ​

In Memory Prefix Cache Provider Options interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { InMemoryPrefixCacheProviderOptions } from '@codesoul-co/hypha-inference';
  • Source module: manager

Declaration ​

text
export interface InMemoryPrefixCacheProviderOptions {
    maxEntries?: number;
    maxEntryBytes?: number;
    maxTotalBytes?: number;
}

Contract members ​

MemberKindSignatureDescription
maxEntriespropertymaxEntries?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxEntryBytespropertymaxEntryBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxTotalBytespropertymaxTotalBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.