文档
lmstudio-js
(TypeScript SDK)
LM Studio 的 Typescript / JavaScript SDK 入门
SDK 为您提供了一套编程工具,用于与 LLM、嵌入模型和代理流程进行交互。
lmstudio-js
可作为 npm 包使用。您可以使用 npm、yarn 或 pnpm 安装它。
npm install @lmstudio/sdk --save
有关源代码和开源贡献,请访问 GitHub 上的 lmstudio.js。
import { LMStudioClient } from "@lmstudio/sdk";
const client = new LMStudioClient();
const model = await client.llm.model("llama-3.2-1b-instruct");
const result = await model.respond("What is the meaning of life?");
console.info(result.content);
上述代码需要 Llama 3.2 1B 模型。如果您没有该模型,请在终端中运行以下命令进行下载。
lms get llama-3.2-1b-instruct
阅读更多关于 LM Studio 的 CLI lms get
此处。
本页的源代码可在 GitHub 上找到