LM StudioLM Studio

Accessing Configuration

You can access the configuration using the method ctl.getPluginConfig(configSchematics) and ctl.getGlobalConfig(globalConfigSchematics) respectively.

For example, here is how to access the config within the promptPreprocessor:

src/promptPreprocessor.ts
import { type PreprocessorController, type ChatMessage } from "@lmstudio/sdk";
import { configSchematics } from "./config";

export async function preprocess(ctl: PreprocessorController, userMessage: ChatMessage) {
  const pluginConfig = ctl.getPluginConfig(configSchematics);
  const myCustomField = pluginConfig.get("myCustomField");

  const globalPluginConfig = ctl.getGlobalPluginConfig(configSchematics);
  const globalMyCustomField = globalPluginConfig.get("myCustomField");

  return (
    `${userMessage.getText()},` +
    `myCustomField: ${myCustomField}, ` +
    `globalMyCustomField: ${globalMyCustomField}`
  );
}