repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
lmstudio.js | github_2023 | lmstudio-ai | typescript | EmbeddingNamespace.loadConfigToKVConfig | protected override loadConfigToKVConfig(config: EmbeddingLoadModelConfig): KVConfig {
return embeddingLlamaLoadConfigSchematics.buildPartialConfig({
"llama.acceleration.offloadRatio": config.gpu?.ratio,
"llama.load.mainGpu": config.gpu?.mainGpu,
"llama.load.splitStrategy": config.gpu?.splitStrateg... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/embedding/EmbeddingNamespace.ts#L31-L42 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | EmbeddingNamespace.createDomainSpecificModel | protected override createDomainSpecificModel(
port: EmbeddingPort,
instanceReference: string,
descriptor: ModelDescriptor,
validator: Validator,
logger: SimpleLogger,
): EmbeddingModel {
return new EmbeddingModel(port, instanceReference, descriptor, validator, logger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/embedding/EmbeddingNamespace.ts#L44-L52 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | EmbeddingNamespace.createDomainDynamicHandle | protected override createDomainDynamicHandle(
port: EmbeddingPort,
specifier: ModelSpecifier,
validator: Validator,
logger: SimpleLogger,
): EmbeddingDynamicHandle {
return new EmbeddingDynamicHandle(port, specifier, validator, logger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/embedding/EmbeddingNamespace.ts#L54-L61 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FileHandle.constructor | public constructor(
public readonly filesNamespace: FilesNamespace,
public readonly identifier: string,
public readonly type: FileType,
public readonly sizeBytes: number,
/**
* Original file name
*/
public readonly name: string,
) {
this.parsedIdentifier = parseFileIdentifier(ide... | /**
* @internal
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FileHandle.ts#L14-L25 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FileHandle.getFilePath | public async getFilePath() {
switch (this.parsedIdentifier.type) {
case "local": {
return (await this.filesNamespace.getLocalFileAbsolutePath(this.parsedIdentifier.fileName))
.path;
}
case "base64": {
throw new Error(
"Not implemented. Please open an issue on Gi... | /**
* Gets the absolute file path of this file.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FileHandle.ts#L31-L47 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FilesNamespace.constructor | public constructor(
/** @internal */
private readonly filesPort: FilesPort,
private readonly validator: Validator,
parentLogger: LoggerInterface,
) {
this.logger = new SimpleLogger("File", parentLogger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FilesNamespace.ts#L16-L23 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FilesNamespace.getLocalFileAbsolutePath | public async getLocalFileAbsolutePath(fileName: string, stack?: string) {
return await this.filesPort.callRpc("getLocalFileAbsolutePath", { fileName }, { stack });
} | /**
* Gets the absolute path to a local file.
*
* @internal
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FilesNamespace.ts#L30-L32 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FilesNamespace.createFileHandleFromChatMessagePartFileData | public createFileHandleFromChatMessagePartFileData(data: ChatMessagePartFileData) {
return new FileHandle(this, data.identifier, data.fileType, data.sizeBytes, data.name);
} | /**
* Creates a file handle from a chat message part file data. Used internally.
*
* @internal
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FilesNamespace.ts#L39-L41 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FilesNamespace.prepareImage | public async prepareImage(path: string): Promise<FileHandle> {
const result = await readFileAsBase64(path);
if (result.success === false) {
throw new Error(text`
Your current JavaScript environment does not support reading files. If you can read the file
using other methods, please use "pr... | /**
* Adds a temporary image to LM Studio, and returns a FileHandle that can be used to reference
* this image. This image will be deleted when the client disconnects.
*
* This method can only be used in environments that have file system access (such as Node.js).
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FilesNamespace.ts#L49-L63 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FilesNamespace.prepareImageBase64 | public async prepareImageBase64(fileName: string, contentBase64: string): Promise<FileHandle> {
const { identifier, fileType, sizeBytes } = await this.filesPort.callRpc("uploadFileBase64", {
name: fileName,
contentBase64,
});
return new FileHandle(this, identifier, fileType, sizeBytes, fileName)... | /**
* Adds a temporary image to LM Studio. The content of the file is specified using base64. If you
* are using Node.js and have a file laying around, consider using `prepareImage` instead.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FilesNamespace.ts#L69-L75 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FilesNamespace.prepareFile | public async prepareFile(path: string): Promise<FileHandle> {
// Currently, exactly the same as prepareImage.
const result = await readFileAsBase64(path);
if (result.success === false) {
throw new Error(text`
Your current JavaScript environment does not support reading files. If you can read t... | /**
* Adds a temporary file to LM Studio, and returns a FileHandle that can be used to reference this
* file. This file will be deleted when the client disconnects.
*
* This method can only be used in environments that have file system access (such as Node.js).
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FilesNamespace.ts#L83-L98 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FilesNamespace.prepareFileBase64 | public async prepareFileBase64(fileName: string, contentBase64: string): Promise<FileHandle> {
// Currently, exactly the same as prepareImageBase64.
const { identifier, fileType, sizeBytes } = await this.filesPort.callRpc("uploadFileBase64", {
name: fileName,
contentBase64,
});
return new Fi... | /**
* Adds a temporary file to LM Studio. The content of the file is specified using base64. If you
* are using Node.js and have a file laying around, consider using `prepareFile` instead.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/files/FilesNamespace.ts#L104-L111 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLM.constructor | public constructor(
llmPort: LLMPort,
instanceReference: string,
descriptor: ModelDescriptor,
validator: Validator,
logger: SimpleLogger = new SimpleLogger(`LLM`),
) {
const specifier: ModelSpecifier = {
type: "instanceReference",
instanceReference,
};
super(llmPort, specif... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLM.ts#L22-L36 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMDynamicHandle.constructor | public constructor(
/** @internal */
port: LLMPort,
/** @internal */
specifier: ModelSpecifier,
/** @internal */
private readonly validator: Validator,
/** @internal */
private readonly logger: SimpleLogger = new SimpleLogger(`LLMModel`),
) {
super(port, specifier);
} | /**
* Don't construct this on your own. Use {@link LLMNamespace#get} or {@link LLMNamespace#load}
* instead.
*
* @internal
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMDynamicHandle.ts#L107-L118 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMDynamicHandle.predictInternal | private predictInternal(
modelSpecifier: ModelSpecifier,
history: ChatHistoryData,
predictionConfigStack: KVConfigStack,
cancelEvent: BufferedEvent<void>,
extraOpts: LLMPredictionExtraOpts,
onFragment: (fragment: LLMPredictionFragment) => void,
onFinished: (
stats: LLMPredictionStats,
... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMDynamicHandle.ts#L127-L193 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMDynamicHandle.complete | public complete<TStructuredOutputType>(
prompt: string,
opts: LLMPredictionOpts<TStructuredOutputType> = {},
): OngoingPrediction<TStructuredOutputType> {
const stack = getCurrentStack(1);
[prompt, opts] = this.validator.validateMethodParamsOrThrow(
"model",
"complete",
["prompt", "o... | /**
* Use the loaded model to predict text.
*
* This method returns an {@link OngoingPrediction} object. An ongoing prediction can be used as a
* promise (if you only care about the final result) or as an async iterable (if you want to
* stream the results as they are being generated).
*
* Example ... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMDynamicHandle.ts#L267-L329 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMDynamicHandle.respond | public respond<TStructuredOutputType>(
history: ChatHistoryLike,
opts: LLMPredictionOpts<TStructuredOutputType> = {},
): OngoingPrediction<TStructuredOutputType> {
const stack = getCurrentStack(1);
[history, opts] = this.validator.validateMethodParamsOrThrow(
"model",
"respond",
["hi... | /**
* Use the loaded model to generate a response based on the given history.
*
* This method returns an {@link OngoingPrediction} object. An ongoing prediction can be used as a
* promise (if you only care about the final result) or as an async iterable (if you want to
* stream the results as they are be... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMDynamicHandle.ts#L391-L429 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMDynamicHandle.unstable_preloadDraftModel | public async unstable_preloadDraftModel(draftModelKey: string): Promise<void> {
const stack = getCurrentStack(1);
draftModelKey = this.validator.validateMethodParamOrThrow(
"model",
"unstable_preloadDraftModel",
"draftModelKey",
z.string(),
draftModelKey,
stack,
);
aw... | /**
* Starts to eagerly preload a draft model. This is useful when you want a draft model to be ready
* for speculative decoding.
*
* Preloading is done on a best-effort basis and may not always succeed. It is not guaranteed that
* the draft model is actually loaded when this method returns. Thus, this m... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMDynamicHandle.ts#L533-L548 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMNamespace.loadConfigToKVConfig | protected override loadConfigToKVConfig(config: LLMLoadModelConfig): KVConfig {
return llmLlamaMoeLoadConfigSchematics.buildPartialConfig({
"contextLength": config.contextLength,
"llama.evalBatchSize": config.evalBatchSize,
"llama.acceleration.offloadRatio": config.gpu?.ratio,
"llama.load.ma... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMNamespace.ts#L32-L56 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMNamespace.createDomainSpecificModel | protected override createDomainSpecificModel(
port: LLMPort,
instanceReference: string,
descriptor: ModelDescriptor,
validator: Validator,
logger: SimpleLogger,
): LLM {
return new LLM(port, instanceReference, descriptor, validator, logger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMNamespace.ts#L58-L66 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LLMNamespace.createDomainDynamicHandle | protected override createDomainDynamicHandle(
port: LLMPort,
specifier: ModelSpecifier,
validator: Validator,
logger: SimpleLogger,
): LLMDynamicHandle {
return new LLMDynamicHandle(port, specifier, validator, logger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/LLMNamespace.ts#L68-L75 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OngoingPrediction.create | public static create<TStructuredOutputType>(
onCancel: () => void,
parser: ((content: string) => TStructuredOutputType) | null,
) {
const ongoingPrediction = new OngoingPrediction<TStructuredOutputType>(onCancel, parser);
const finished = (
stats: LLMPredictionStats,
modelInfo: ModelDescri... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/OngoingPrediction.ts#L99-L119 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OngoingPrediction.result | public async result(): Promise<PredictionResult> {
return await this;
} | /**
* Get the final prediction results. If you have been streaming the results, awaiting on this
* method will take no extra effort, as the results are already available in the internal buffer.
*
* Example:
*
* ```typescript
* const prediction = model.complete("When will The Winds of Winter be rele... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/OngoingPrediction.ts#L146-L148 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OngoingPrediction.cancel | public async cancel() {
this.onCancel();
} | /**
* Cancels the prediction. This will stop the prediction with stop reason `userStopped`. See
* {@link LLMPredictionStopReason} for other reasons that a prediction might stop.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/llm/OngoingPrediction.ts#L154-L156 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | PluginsNamespace.constructor | public constructor(
/** @internal */
private readonly port: PluginsPort,
private readonly client: LMStudioClient,
private readonly validator: Validator,
parentLogger: LoggerInterface,
private readonly rootLogger: LoggerInterface,
) {
this.logger = new SimpleLogger("Plugins", parentLogger);... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/PluginsNamespace.ts#L59-L68 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | PluginsNamespace.reindexPlugins | public async reindexPlugins() {
const stack = getCurrentStack(1);
await this.port.callRpc("reindexPlugins", undefined, { stack });
} | /**
* Requests LM Studio to reindex all the plugins.
*
* CAVEAT: Currently, we do not wait for the reindex to complete before returning. In the future,
* we will change this behavior and only return after the reindex is completed.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/PluginsNamespace.ts#L121-L124 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | PluginsNamespace.setPreprocessor | public setPreprocessor(preprocessor: Preprocessor) {
const stack = getCurrentStack(1);
this.validator.validateMethodParamOrThrow(
"plugins",
"registerPreprocessor",
"preprocessor",
z.function(),
preprocessor,
stack,
);
const logger = new SimpleLogger(`Preprocessor`,... | /**
* Sets the preprocessor to be used by the plugin represented by this client.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/PluginsNamespace.ts#L129-L253 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | PluginsNamespace.setGenerator | public setGenerator(generator: Generator) {
const stack = getCurrentStack(1);
this.validator.validateMethodParamOrThrow(
"plugins",
"setGenerator",
"generator",
z.function(),
generator,
stack,
);
const logger = new SimpleLogger(` Generator`, this.rootLogger);
... | /**
* Sets the preprocessor to be used by the plugin represented by this client.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/PluginsNamespace.ts#L258-L360 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.constructor | public constructor(
public readonly client: LMStudioClient,
/** @internal */
private readonly connector: ProcessingConnector,
/** @internal */
private readonly config: KVConfig,
/** @internal */
private readonly pluginConfig: KVConfig,
/**
* When getting history, should the latest u... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L160-L182 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.pullHistory | public async pullHistory() {
return await this.connector.pullHistory(this.shouldIncludeCurrentInHistory);
} | /**
* Gets a mutable copy of the current history. The returned history is a copy, so mutating it will
* not affect the actual history. It is mutable for convenience reasons.
*
* - If you are a preprocessor, this will not include the user message you are currently
* preprocessing.
* - If you are a ge... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L208-L210 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.createDebugInfoBlock | public createDebugInfoBlock(debugInfo: string): PredictionProcessDebugInfoBlockController {
const id = createId();
this.sendUpdate({
type: "debugInfoBlock.create",
id,
debugInfo,
});
const debugInfoBlockController = new PredictionProcessDebugInfoBlockController(
this.processingCo... | /**
* @internal
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L268-L280 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.setSenderName | public async setSenderName(name: string) {
this.sendUpdate({
type: "setSenderName",
name,
});
} | /**
* Sets the sender name for this message. The sender name shown above the message in the chat.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L334-L339 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.guardAbort | public guardAbort() {
this.abortSignal.throwIfAborted();
} | /**
* Throws an error if the prediction process has been aborted. Sprinkle this throughout your code
* to ensure that the prediction process is aborted as soon as possible.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L345-L347 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.hasStatus | public async hasStatus() {
return await this.connector.hasStatus();
} | /**
* Whether this prediction process has had any status.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L352-L354 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.needsNaming | public async needsNaming() {
return await this.connector.needsNaming();
} | /**
* Returns whether this conversation needs a name.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L359-L361 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ProcessingController.suggestName | public async suggestName(name: string) {
await this.connector.suggestName(name);
} | /**
* Suggests a name for this conversation.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L366-L368 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | PredictionProcessStatusController.constructor | public constructor(
/** @internal */
private readonly handle: ProcessingControllerHandle,
initialState: StatusStepState,
private readonly id: string,
private readonly indentation: number = 0,
) {
this.lastState = initialState;
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L390-L398 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | PredictionProcessDebugInfoBlockController.constructor | public constructor(
/** @internal */
private readonly handle: ProcessingControllerHandle,
private readonly id: string,
) {} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/plugins/processing/ProcessingController.ts#L460-L464 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ModelSearchResultDownloadOption.constructor | public constructor(
/** @internal */
private readonly repositoryPort: RepositoryPort,
/** @internal */
private readonly validator: Validator,
private readonly logger: SimpleLogger,
private readonly data: ModelSearchResultDownloadOptionData,
) {
this.quantization = data.quantization;
th... | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/repository/ModelSearchResultDownloadOption.ts#L36-L49 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ModelSearchResultDownloadOption.download | public async download(opts: DownloadOpts = {}) {
const stack = getCurrentStack(1);
this.validator.validateMethodParamOrThrow(
"ModelSearchResultDownloadOption",
"download",
"opts",
downloadOptsSchema,
opts,
stack,
);
const { promise, resolve, reject } = makePromise<st... | /**
* Download the model. Returns a path that can be used to load the model.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/repository/ModelSearchResultDownloadOption.ts#L56-L110 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ModelSearchResultEntry.constructor | public constructor(
/** @internal */
private readonly repositoryPort: RepositoryPort,
/** @internal */
private readonly validator: Validator,
private readonly logger: SimpleLogger,
private readonly data: ModelSearchResultEntryData,
) {
this.name = data.name;
} | /**
* @internal
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/repository/ModelSearchResultEntry.ts#L13-L22 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | RepositoryNamespace.constructor | public constructor(
private readonly repositoryPort: RepositoryPort,
private readonly validator: Validator,
parentLogger: LoggerInterface,
) {
this.logger = new SimpleLogger("Repository", parentLogger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/repository/RepositoryNamespace.ts#L65-L71 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | RetrievalNamespace.constructor | public constructor(
private readonly retrievalPort: RetrievalPort,
private readonly validator: Validator,
private readonly embeddingNamespace: EmbeddingNamespace,
parentLogger: LoggerInterface,
) {
this.logger = new SimpleLogger("Retrieval", parentLogger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/retrieval/RetrievalNamespace.ts#L38-L45 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | SystemNamespace.constructor | public constructor(
private readonly systemPort: SystemPort,
private readonly validator: Validator,
parentLogger: LoggerInterface,
) {
this.logger = new SimpleLogger("System", parentLogger);
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/system/SystemNamespace.ts#L20-L26 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | SystemNamespace.listDownloadedModels | public async listDownloadedModels(): Promise<Array<DownloadedModel>> {
return this.systemPort.callRpc("listDownloadedModels", undefined, {
stack: getCurrentStack(1),
});
} | /**
* List all downloaded models.
* @public
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-client/src/system/SystemNamespace.ts#L31-L35 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | BufferedEvent.flow | public flow(): Event<TData> {
const [event, emit] = Event.create<TData>();
this.subscribe(emit);
return event;
} | /**
* Convert this buffered event to an event by stop buffering and triggering events on the new
* returned event.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/BufferedEvent.ts#L69-L73 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Event.constructor | protected constructor() {
super();
} | /**
* Internal state that tracks whether the event has any subscribers.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Event.ts#L27-L29 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LazySignal.isStale | public isStale() {
return this.dataIsStale;
} | /**
* Returns whether the value is currently stale.
*
* A value is stale whenever the upstream subscription is not active. This can happen in three
* cases:
*
* 1. When no subscriber is attached to this signal, the signal will not subscribe to the
* upstream. In this case, the value is always st... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/LazySignal.ts#L231-L233 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LazySignal.get | public get(): TData {
return this.signal.get();
} | /**
* Gets the current value of the signal. If the value is not available, it will return
* {@link LazySignal.NOT_AVAILABLE}. (A value will only be unavailable if the signal is created
* without an initial value and the upstream has not emitted a value yet.)
*
* In addition, the value returned by this me... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/LazySignal.ts#L291-L293 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LazySignal.pull | public async pull(): Promise<StripNotAvailable<TData>> {
const { promise, resolve } = makePromise<StripNotAvailable<TData>>();
if (!this.isStale()) {
// If not stale, definitely not "NOT_AVAILABLE"
resolve(this.get() as StripNotAvailable<TData>);
} else {
const unsubscribe = this.subscribe... | /**
* Pulls the current value of the signal. If the value is stale, it will subscribe and wait for
* the next value from the upstream and return it.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/LazySignal.ts#L299-L312 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LazySignal.runOnNextFreshData | public runOnNextFreshData(callback: (value: StripNotAvailable<TData>) => void) {
if (!this.isStale()) {
callback(this.get() as StripNotAvailable<TData>);
} else {
let unsubscribe: (() => void) | null = null;
const updateCallback = () => {
this.updateReceivedSynchronousCallbacks.delete(... | /**
* If the data is not stale, the callback will be called synchronously with the current value.
*
* If the data is stale, it will pull the current value and call the callback with the value.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/LazySignal.ts#L319-L332 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | LazySignal.passiveSubscribe | public passiveSubscribe(subscriber: Subscriber<TData>): () => void {
return this.signal.subscribe(subscriber);
} | /**
* Subscribes to the signal. Will not cause the signal to subscribe to the upstream.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/LazySignal.ts#L382-L384 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OWLSignal.ensureWriteLoop | private ensureWriteLoop() {
if (!this.isWriteLoopRunning) {
this.writeLoop(); // This is not expected to error, if it does, just default behavior
}
} | /**
* Starts the write loop if it is not already running.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/OWLSignal.ts#L186-L190 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OWLSignal.writeLoop | private async writeLoop() {
const unsubscribe = this.innerSignal.subscribe(() => {});
this.isWriteLoopRunning = true;
if (this.isStale()) {
await this.innerSignal.pull();
}
while (this.queuedUpdates.length > 0) {
const numQueuedUpdatesToHandle = this.queuedUpdates.length;
const upd... | /**
* The main write loop, it will keep running until there are no more updates to process.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/OWLSignal.ts#L194-L281 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OWLSignal.isStale | public isStale() {
return this.innerSignal.isStale();
} | /**
* Returns whether the value is currently stale.
*
* A value is stale whenever the upstream subscription is not active. This can happen in three
* cases:
*
* 1. When no subscriber is attached to this signal, the signal will not subscribe to the
* upstream. In this case, the value is always st... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/OWLSignal.ts#L299-L301 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OWLSignal.get | public get(): TData {
return this.outerSignal.get();
} | /**
* Gets the current value of the signal. If the value is not available, it will return
* {@link OWLSignal.NOT_AVAILABLE}. (A value will only be unavailable if the signal is created
* without an initial value and the upstream has not emitted a value yet.)
*
* In addition, the value returned by this met... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/OWLSignal.ts#L314-L316 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OWLSignal.getPessimistic | public getPessimistic(): TData {
return this.innerSignal.get();
} | /**
* Gets the current value of the signal pessimistically. If the value is not available, it will
* return {@link OWLSignal.NOT_AVAILABLE}. (A value will only be unavailable if the signal is
* created without an initial value and the upstream has not emitted a value yet.)
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/OWLSignal.ts#L323-L325 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | OWLSignal.pull | public async pull({ optimistic = true }: { optimistic?: boolean } = {}) {
if (optimistic) {
return this.applyOptimisticUpdates(await this.innerSignal.pull());
} else {
return this.innerSignal.pull();
}
} | /**
* Pulls the current value of the signal. If the value is stale, it will subscribe and wait for
* the next value from the upstream and return it.
*
* You must also provide an `optimistic` flag. If `optimistic` is true, the pending optimistic
* updates will be applied to the value before returning it.
... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/OWLSignal.ts#L334-L340 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Signal.create | public static create<TValue>(
value: TValue,
equalsPredicate: (a: TValue, b: TValue) => boolean = equals,
): readonly [Signal<TValue>, Setter<TValue>] {
const signal = new Signal(value, equalsPredicate);
const update = (updater: Updater<TValue>, tags?: Array<WriteTag>) => {
signal.update(updater... | /**
* Creates a signal.
*
* @param value - The initial value of the signal.
* @param equalsPredicate - A function to compare two values. The subscribers will only be called
* if the value changes according to the `equalsPredicate`. By default, it uses the `===`
* operator.
* @returns This method re... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Signal.ts#L47-L57 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Signal.get | public get() {
return this.value;
} | /**
* Returns the current value of the signal.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Signal.ts#L71-L73 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Signal.subscribe | public subscribe(callback: Subscriber<TValue>): () => void {
const subscriber: InternalSubscriber<TValue> = {
type: "regular",
callback,
};
this.subscribers.add(subscriber);
return () => {
this.subscribers.delete(subscriber);
};
} | /**
* Subscribes to the signal. The callback will be called whenever the value changes. All callbacks
* are called synchronously upon updating. It will NOT be immediately called with the current
* value. (Use `get()` to get the current value.) Returns a function to unsubscribe.
*
* Edge cases involving m... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Signal.ts#L165-L174 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Signal.subscribeAndNow | public subscribeAndNow(callback: Subscriber<TValue>): () => void {
const unsubscribe = this.subscribe(callback);
callback(this.value);
return unsubscribe;
} | /**
* Subscribes to the signal with the callback and trigger the callback immediately with the
* current value.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Signal.ts#L180-L184 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Signal.until | public async until(predicate: (data: TValue) => boolean): Promise<TValue> {
const current = this.get();
if (predicate(current)) {
return current;
}
const { promise, resolve } = makePromise<TValue>();
const unsubscribe = this.subscribe(data => {
if (predicate(data)) {
resolve(data... | /**
* Wait until the signal satisfies a predicate. If the predicate is already satisfied, it will
* return immediately. Otherwise, it will wait until the signal satisfies the predicate.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Signal.ts#L201-L214 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | drill | function drill(value: any, path: Array<PathSegment>, defaultUsed?: (index: number) => void) {
let current = value;
let index = 0;
for (const key of path) {
if (key.key === "__proto__") {
throw new Error("Cannot access __proto__");
}
switch (key.type) {
case "key":
current = current... | /**
* Given a value and a path, return the value at the path.
*
* At any point, if a default value is used, the defaultUsed callback is called with the index of
* the path segment where the default value was used.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/SlicedSignal.ts#L41-L69 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Validator.prettyPrintZod | public static prettyPrintZod(rootObjectName: string, error: ZodError) {
return error.errors
.map(e => {
if (e.path.length === 0) {
return `- ${chalk.redBright(rootObjectName)}: ${e.message}`;
}
const path = chalk.red(`.${e.path.join(".")}`);
return `- ${chalk.redBrigh... | /**
* Pretty-prints a Zod error.
*
* @param rootObjectName - The name of the object being validated (used for error messages)
* @param error - The Zod error to pretty-print
*
* @returns The pretty-printed error in a string
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Validator.ts#L22-L32 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Validator.validateOrThrow | public validateOrThrow<T>(
lead: string,
rootObjectName: string,
schema: z.Schema<T>,
value: unknown,
stack?: string,
): T {
const result = schema.safeParse(value);
if (result.success) {
return result.data;
} else {
throw makePrettyError(
`${lead}\n\n${Validator.pre... | /**
* Validates a value against a schema and throws an error if it's invalid.
*
* @param lead - The start of the error message (used for error messages)
* @param rootObjectName - The name of the object being validated (used for error messages)
* @param schema - The schema to validate against
* @param ... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Validator.ts#L45-L61 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Validator.validateMultipleOrThrow | public validateMultipleOrThrow<T extends Array<unknown>>(
leadProducer: (erroredValues: Set<number>) => string,
rootObjectNames: Array<string>,
schemas: Array<z.Schema<unknown>>,
values: T,
stack?: string,
): T {
const results = schemas.map((schema, index) => schema.safeParse(values[index]));
... | /**
* Validates multiple values against multiple schemas and throws an error if any of them are
* invalid. All values are validated before any errors are thrown. This is useful when you want to
* validate multiple values at once and want to see all the errors at once.
*
* @param leadProducer - The functi... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Validator.ts#L77-L105 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Validator.validateMethodParamOrThrow | public validateMethodParamOrThrow<T>(
className: string,
methodName: string,
paramName: string,
schema: z.Schema<T>,
value: unknown,
stack?: string,
): T {
const functionCall = chalk.yellowBright(text`
${className}.${methodName}(${chalk.redBright(paramName)})
`);
return this.vali... | /**
* Validates a value against a schema and throws an error if it's invalid. This is a convenience
* function for validating one single method parameter.
*
* @param className - The name of the class containing the method (used for error messages)
* @param methodName - The name of the method (used for er... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Validator.ts#L120-L138 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Validator.validateMethodParamsOrThrow | public validateMethodParamsOrThrow<T extends Array<unknown>>(
className: string,
methodName: string,
paramNames: Array<string>,
schemas: Array<z.Schema<unknown>>,
values: T,
stack?: string,
): T {
return this.validateMultipleOrThrow(
erroredValues => {
const coloredParamNames... | /**
* Validates multiple values against multiple schemas and throws an error if any of them are
* invalid. This is a convenience function for validating multiple method parameters.
*
* @param className - The name of the class containing the method (used for error messages)
* @param methodName - The name ... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Validator.ts#L153-L176 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Validator.validateConstructorParamOrThrow | public validateConstructorParamOrThrow<T>(
className: string,
paramName: string,
schema: z.Schema<T>,
value: unknown,
stack?: string,
): T {
const functionCall = chalk.yellowBright(text`
${className}(${chalk.redBright(paramName)})
`);
return this.validateOrThrow(
`Invalid param... | /**
* Validates a value against a schema and throws an error if it's invalid. This is a convenience
* function for validating one single constructor parameter.
*
* @param className - The name of the class (used for error messages)
* @param paramName - The name of the parameter being validated (used for e... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Validator.ts#L190-L207 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Validator.validateConstructorParamsOrThrow | public validateConstructorParamsOrThrow<T extends Array<unknown>>(
className: string,
paramNames: Array<string>,
schemas: Array<z.Schema<unknown>>,
values: T,
stack?: string,
): T {
return this.validateMultipleOrThrow(
erroredValues => {
const coloredParamNames = paramNames.map((... | /**
* Validates multiple values against multiple schemas and throws an error if any of them are
* invalid. This is a convenience function for validating multiple constructor parameters.
*
* @param className - The name of the class (used for error messages)
* @param paramNames - The names of the parameter... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/Validator.ts#L219-L241 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | WaitQueue.enterQueue | public enterQueue(priority = 0): Pager {
const pager = new Pager(this, priority);
this.pagers.push(pager);
this.pagers.sort((a, b) => (a.priority < b.priority ? -1 : a.priority > b.priority ? 1 : 0));
this.tryAdvancingQueue();
return pager;
} | /**
* Enters the queue and returns a pager that can be waited on.
*
* @param priority - The priority of the pager. Lower numbers are served first. Defaults to 0.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/WaitQueue.ts#L68-L74 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Pager.constructor | public constructor(
private readonly queue: WaitQueue,
public readonly priority: number,
) {
const { promise, resolve, reject } = makePromise<Holder>();
this.waitingPromise = promise;
this.resolveWaitingPromise = resolve;
this.rejectWaitingPromise = reject;
} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/WaitQueue.ts#L125-L133 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Holder.constructor | public constructor(private readonly queue: WaitQueue) {} | /** @internal */ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/WaitQueue.ts#L157-L157 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | cwt | function cwt(...allTags: Array<undefined | Array<WriteTag>>): Array<WriteTag> {
return allTags
.filter(tags => tags !== undefined)
.reduce((acc, tags) => (acc as any).concat(tags), []) as any;
} | /**
* Concatenate Writable Tags
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/makeSetter.ts#L17-L21 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | countStringIndentations | function countStringIndentations(string: string) {
let count = 0;
for (const char of string) {
if (char === " ") {
count++;
} else {
return count;
}
}
return Infinity;
} | /**
* Returns the number of spaces at the start of the string. If the string only contains spaces,
* returns infinity.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-common/src/text.ts#L90-L100 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | ClientPort.createSignal | public createSignal<TEndpointName extends keyof TSignalEndpoints & string>(
endpointName: TEndpointName,
param: TSignalEndpoints[TEndpointName]["creationParameter"],
{ stack }: { stack?: string } = {},
): LazySignal<TSignalEndpoints[TEndpointName]["signalData"] | NotAvailable> {
const signalEndpoint =... | /**
* Creates a readonly lazy signal will subscribe to the signal endpoint with the given name.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication-client/src/ClientPort.ts#L580-L621 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | WsClientTransport.onWsOpen | protected onWsOpen() {
this.ws!.addEventListener("message", this.onWsMessage.bind(this));
this.status = WsClientTransportStatus.Connected;
this.queuedMessages.forEach(message => this.sendViaTransport(message));
this.queuedMessages = [];
this.updateShouldRef(this.shouldRef);
// this.setupWebsocke... | // } | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication-client/src/WsClientTransport.ts#L65-L72 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | stopAuthentication | function stopAuthentication() {
if (authenticationStopped) {
return;
}
authenticationStopped = true;
ws.removeEventListener("message", onMessage);
ws.removeEventListener("error", onError);
ws.removeEventListener("close", onClose);
clearTimeout(timeoutTimeout);
} | /**
* Removes all the listeners and stops the timeout.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication-server/src/AuthenticatedWsServer.ts#L106-L115 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FcfsClient.create | public static create(
clientIdentifier: string,
clientPasskey: string,
releaseCallback: (client: FcfsClient) => void,
logger?: LoggerInterface,
): { client: FcfsClient; holder: ClientHolder } {
const client = new FcfsClient(clientIdentifier, clientPasskey, releaseCallback, logger);
return { cl... | /**
* Creates a new client. Returns the client and a holder for the client. The holder must be
* dropped when the connection holding this client is closed. More holders can be created by
* calling the hold method of the client.
*
* @param clientIdentifier - The identifier of the client
* @param client... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication-server/src/fcfsAuthenticator.ts#L69-L77 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | FcfsClient.hold | public hold(): ClientHolder {
if (this.references === 0) {
throw new Error("Client is already released!");
} else if (this.references === -1) {
this.references = 1;
} else {
this.references++;
}
const holder = new FcfsClientHolder(this);
this.clientHoldersFinalizationRegistry.r... | /**
* Creates a new holder for the client, which bumps the reference count of the client.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication-server/src/fcfsAuthenticator.ts#L105-L117 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | BackendInterface.addRpcEndpoint | public addRpcEndpoint<
TEndpointName extends string,
TParametersZod extends ZodType,
TReturnsZod extends ZodType,
>(
endpointName: TEndpointName,
{
parameter,
returns,
serialization = "raw",
}: {
parameter: TParametersZod;
returns: TReturnsZod;
serialization... | /**
* Register an Rpc endpoint.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication/src/BackendInterface.ts#L146-L183 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | BackendInterface.handleRpcEndpoint | public handleRpcEndpoint<TEndpointName extends keyof TRpcEndpoints & string>(
endpointName: TEndpointName,
handler: RpcEndpointHandler<
TContext,
TRpcEndpoints[TEndpointName]["parameter"],
TRpcEndpoints[TEndpointName]["returns"]
>,
) {
const endpoint = this.rpcEndpoints.get(endpointN... | /**
* Adds a handler for an Rpc endpoint.
*
* @param endpointName - The name of the endpoint.
* @param handler - The handler function. Will be called when the endpoint is invoked. When
* called, the first parameter is the context, and the second parameter is the "parameter" for the
* RPC call. Can ret... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication/src/BackendInterface.ts#L315-L332 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | BackendInterface.handleChannelEndpoint | public handleChannelEndpoint<TEndpointName extends keyof TChannelEndpoints & string>(
endpointName: TEndpointName,
handler: ChannelEndpointHandler<
TContext,
TChannelEndpoints[TEndpointName]["creationParameter"],
TChannelEndpoints[TEndpointName]["toServerPacket"],
TChannelEndpoints[TEndp... | /**
* Adds a handler for a channel endpoint.
*
* @param endpointName - The name of the endpoint.
* @param handler - The handler function. Will be called when the client creates a channel for
* this endpoint. When called, the first parameter is the context, the second parameter is the
* "creationParame... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication/src/BackendInterface.ts#L345-L363 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | BackendInterface.handleSignalEndpoint | public handleSignalEndpoint<TEndpointName extends keyof TSignalEndpoints & string>(
endpointName: TEndpointName,
handler: SignalEndpointHandler<
TContext,
TSignalEndpoints[TEndpointName]["creationParameter"],
TSignalEndpoints[TEndpointName]["signalData"]
>,
) {
const endpoint = this.... | /**
* Adds a handler for a signal endpoint.
*
* @param endpointName - The name of the endpoint.
* @param handler - The handler function. Will be called when the client creates a signal, and at
* least one subscriber is attached to that signal. When called, the first parameter is the
* context, and the... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication/src/BackendInterface.ts#L385-L402 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | BackendInterface.handleWritableSignalEndpoint | public handleWritableSignalEndpoint<
TEndpointName extends keyof TWritableSignalEndpoints & string,
>(
endpointName: TEndpointName,
handler: WritableSignalEndpointHandler<
TContext,
TWritableSignalEndpoints[TEndpointName]["creationParameter"],
TWritableSignalEndpoints[TEndpointName]["sig... | /**
* Adds a handler for a writable signal endpoint.
*
* @param endpointName - The name of the endpoint.
* @param handler - The handler function. Will be called when the client creates a writable
* signal, and at least one subscriber is attached to that signal. When called, the first
* parameter is th... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication/src/BackendInterface.ts#L425-L444 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | Channel.receivedMessage | private receivedACK = (ackId: number) => {
if (this.connectionStatus.get() !== ConnectionStatus.Connected) {
logger.warn("Received ACK while in status", this.connectionStatus.get());
return;
}
const waiting = this.waitingForAck.get(ackId);
if (waiting === undefined) {
logger.warn("Rece... | /**
* Returned as a part of create. It should be called by the controlling port.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-communication/src/Channel.ts | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | EsPluginInstaller.createEntryFile | private async createEntryFile(cacheFolderPath: string) {
await mkdir(cacheFolderPath, { recursive: true });
const entryFilePath = join(cacheFolderPath, "entry.ts");
const content = generateEntryFile({});
await writeFile(entryFilePath, content);
return entryFilePath;
} | /**
* Creates the entry.ts file in .lmstudio
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-es-plugin-runner/src/EsPluginInstaller.ts#L19-L26 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | EsPluginInstaller.createEsBuildArgs | private async createEsBuildArgs(cacheFolderPath: string, entryFilePath: string) {
const args = createEsBuildArgs({
entryPath: entryFilePath,
outPath: join(cacheFolderPath, "production.js"),
production: true,
});
return args;
} | /**
* Creates the esbuild args
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-es-plugin-runner/src/EsPluginInstaller.ts#L30-L37 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | EsPluginRunnerWatcher.createEntryFile | private async createEntryFile() {
await mkdir(this.lmstudioCacheFolderPath, { recursive: true });
const entryFilePath = join(this.lmstudioCacheFolderPath, "entry.ts");
const content = generateEntryFile({});
await writeFile(entryFilePath, content);
return entryFilePath;
} | /**
* Creates the entry.ts file in .lmstudio
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-es-plugin-runner/src/EsPluginRunnerWatcher.ts#L61-L68 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | EsPluginRunnerWatcher.createEsBuildArgs | private async createEsBuildArgs(entryFilePath: string) {
const args = createEsBuildArgs({
entryPath: entryFilePath,
outPath: join(this.lmstudioCacheFolderPath, "dev.js"),
watch: true,
production: false,
});
return args;
} | /**
* Creates the esbuild args
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-es-plugin-runner/src/EsPluginRunnerWatcher.ts#L72-L80 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | tput | const tput = () => {
try {
// `tput` requires the `TERM` environment variable to be set.
const columns = exec("tput", ["cols"], { env: { TERM: "dumb", ...process.env } });
const rows = exec("tput", ["lines"], { env: { TERM: "dumb", ...process.env } });
if (columns && rows) {
return createIfNotD... | // On macOS, this only returns correct values when stdout is not redirected. | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-isomorphic/src/index/terminalSize.ts#L90-L102 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | resize | const resize = () => {
// `resize` is preferred as it works even when all file descriptors are redirected
// https://linux.die.net/man/1/resize
try {
const size = exec("resize", ["-u"]).match(/\d+/g);
if (size!.length === 2) {
return createIfNotDefault(size![0], size![1]);
}
// eslint-disab... | // Only exists on Linux. | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-isomorphic/src/index/terminalSize.ts#L105-L116 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | KVFieldValueTypesLibraryBuilder.valueType | public valueType<TKey extends string, TValueTypeParams extends {}, TValue>(
key: TKey,
param: {
paramType: ExposedZodObject<TValueTypeParams>;
schemaMaker: (param: TValueTypeParams) => ZodSchema<TValue>;
effectiveEquals: (a: TValue, b: TValue, typeParam: TValueTypeParams) => boolean;
str... | /**
* Define a new field value type.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-kv-config/src/KVConfig.ts#L144-L178 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | KVFieldValueTypeLibrary.getSchema | public getSchema<TKey extends keyof TKVFieldValueTypeLibraryMap & string>(
key: TKey,
param: TKVFieldValueTypeLibraryMap[TKey]["param"],
): ZodSchema<TKVFieldValueTypeLibraryMap[TKey]["value"]> {
return this.valueTypes.get(key)!.schemaMaker(param);
} | /**
* Gets the schema for a specific field value type with the given key and parameters.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-kv-config/src/KVConfig.ts#L196-L201 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | KVConfigSchematicsBuilder.field | public field<
TKey extends string,
TValueTypeKey extends keyof TKVFieldValueTypeLibraryMap & string,
>(
key: TKey,
valueTypeKey: TValueTypeKey,
valueTypeParams: TKVFieldValueTypeLibraryMap[TValueTypeKey]["param"],
defaultValue: TKVFieldValueTypeLibraryMap[TValueTypeKey]["value"],
): KVConfig... | /**
* Adds a field
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-kv-config/src/KVConfig.ts#L278-L312 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | KVConfigSchematicsBuilder.scope | public scope<TScopeKey extends string, TInnerConfigSchema extends KVVirtualConfigSchema>(
scopeKey: TScopeKey,
fn: (
builder: KVConfigSchematicsBuilder<TKVFieldValueTypeLibraryMap, {}>,
) => KVConfigSchematicsBuilder<TKVFieldValueTypeLibraryMap, TInnerConfigSchema>,
): KVConfigSchematicsBuilder<
... | /**
* Convenience method for grouping a set of fields under a shared namespace.
*
* For example, if we want to create two fields: `some:namespace:a` and `some:namespace:b`.
* Instead of doing:
*
* ```ts
* builder
* .field("some:namespace:a", ...)
* .field("some:namespace:b", ...)
* ```... | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-kv-config/src/KVConfig.ts#L338-L365 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | KVConfigSchematics.access | public access<TKey extends keyof TKVConfigSchema & string>(
config: KVConfig,
key: TKey,
): TKVConfigSchema[TKey]["type"] {
const field = this.obtainField(key);
return this.parseField(field, config.fields.find(f => f.key === field.fullKey)?.value);
} | /**
* Parse and access a field in the config.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-kv-config/src/KVConfig.ts#L468-L474 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | KVConfigSchematics.accessPartial | public accessPartial<TKey extends keyof TKVConfigSchema & string>(
config: KVConfig,
key: TKey,
): TKVConfigSchema[TKey]["type"] | undefined {
const field = this.obtainField(key);
return this.parseFieldWithoutDefault(
field,
config.fields.find(f => f.key === field.fullKey)?.value,
);
... | /**
* Parse and access a field in the config. Returns undefined if the field is missing.
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-kv-config/src/KVConfig.ts#L484-L493 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
lmstudio.js | github_2023 | lmstudio-ai | typescript | KVConfigSchematics.sliced | public sliced<TKeyPattern extends (keyof TKVConfigSchema & string) | `${string}.*` | "*">(
...patterns: TKeyPattern[]
): KVConfigSchematics<
TKVFieldValueTypeLibraryMap,
{
[TKey in KeyPatternMatch<keyof TKVConfigSchema, TKeyPattern>]: TKVConfigSchema[TKey];
}
> {
type Pattern =
| {
... | /**
* Gets a slice of the config schema with the given key patterns. Support syntax:
*
* - `some.namespace.key`: Matches exactly `some.namespace.key`
* - `some.namespace.*`: Matches anything that starts with `some.namespace.`
*/ | https://github.com/lmstudio-ai/lmstudio.js/blob/22f2871aa123f65384f3b4ee2b9e3aae924f4e09/packages/lms-kv-config/src/KVConfig.ts#L501-L536 | 22f2871aa123f65384f3b4ee2b9e3aae924f4e09 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.