ドキュメント
エージェントフロー
インテグレーション
テキスト埋め込み
トークン化
モデル情報
エージェントフロー
インテグレーション
テキスト埋め込み
トークン化
モデル情報
インテグレーション
例
プラグインサポートは現在プライベートベータ版です。こちらからベータ版に参加してください。
以下は、各ユーザーメッセージの前に現在の時刻を挿入するプリプロセッサの例です。
import { type PromptPreprocessorController, type ChatMessage } from "@lmstudio/sdk";
export async function preprocess(ctl: PromptPreprocessorController, userMessage: ChatMessage) {
const textContent = userMessage.getText();
const transformed = `Current time: ${new Date().toString()}\n\n${textContent}`;
return transformed;
}
単純なテキスト処理のみで実行できるもう1つの例は、特定のトリガーワードを置き換えることです。たとえば、@initトリガーを特別な初期化メッセージで置き換えることができます。
import { type PromptPreprocessorController, type ChatMessage, text } from "@lmstudio/sdk";
const mySpecialInstructions = text`
Here are some special instructions...
`;
export async function preprocess(ctl: PromptPreprocessorController, userMessage: ChatMessage) {
const textContent = userMessage.getText();
const transformed = textContent.replaceAll("@init", mySpecialInstructions);
return transformed;
}
このページのソースは GitHub で入手できます。