Skip to content

feat(embeddings): add LM Studio embeddings node#5877

Open
stablegenius49 wants to merge 2 commits intoFlowiseAI:mainfrom
stablegenius49:feature/lmstudio-embeddings
Open

feat(embeddings): add LM Studio embeddings node#5877
stablegenius49 wants to merge 2 commits intoFlowiseAI:mainfrom
stablegenius49:feature/lmstudio-embeddings

Conversation

@stablegenius49
Copy link

Summary

Adds first-class LM Studio embedding support via a dedicated node in Flowise.

What changed

  • Added new credential: lmStudioApi
    • File: packages/components/credentials/LMStudioApi.credential.ts
    • Supports optional lmStudioApiKey
  • Added new embeddings node: LM Studio Embeddings
    • File: packages/components/nodes/embeddings/LMStudioEmbedding/LMStudioEmbedding.ts
    • Uses OpenAIEmbeddings from @langchain/openai
    • Defaults to LM Studio local endpoint: http://localhost:1234/v1
    • Supports model name, strip new lines, batch size, timeout, dimensions
    • Works with no key by default (openAIApiKey: 'sk-') and accepts key when provided
  • Added node icon:
    • File: packages/components/nodes/embeddings/LMStudioEmbedding/lmstudio.svg

Why

Issue #1277 requests native LM Studio embeddings support. LM Studio exposes an OpenAI-compatible API and is commonly used for local/private embedding workflows.

Verification

Commands run locally:

corepack pnpm exec eslint \
  packages/components/credentials/LMStudioApi.credential.ts \
  packages/components/nodes/embeddings/LMStudioEmbedding/LMStudioEmbedding.ts

corepack pnpm --filter flowise-components build

Build completed successfully.

Fixes #1277

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances Flowise's capabilities by integrating native support for LM Studio embeddings. It provides users with a dedicated node to generate embeddings using LM Studio's OpenAI-compatible API, facilitating local and private embedding workflows. This addition addresses a community request and expands the range of available embedding providers within the platform.

Highlights

  • New Credential Added: A new credential, lmStudioApi, has been introduced to support LM Studio API keys, which are optional.
  • LM Studio Embeddings Node: A dedicated 'LM Studio Embeddings' node has been added, utilizing OpenAIEmbeddings from @langchain/openai and defaulting to LM Studio's local endpoint. It supports various parameters like model name, batch size, and dimensions.
  • Node Icon Included: An SVG icon (lmstudio.svg) has been added for the new LM Studio Embeddings node to enhance UI representation.
Changelog
  • packages/components/credentials/LMStudioApi.credential.ts
    • Added a new credential class LMStudioApi to manage LM Studio API keys.
  • packages/components/nodes/embeddings/LMStudioEmbedding/LMStudioEmbedding.ts
    • Implemented the LMStudioEmbedding_Embeddings node, providing an interface for LM Studio's OpenAI-compatible embedding API.
    • Configured default base URL to http://localhost:1234/v1 and a default model name.
    • Added support for optional parameters including strip new lines, batch size, timeout, and dimensions.
    • Integrated credential handling for lmStudioApiKey.
  • packages/components/nodes/embeddings/LMStudioEmbedding/lmstudio.svg
    • Added an SVG icon for the LM Studio Embeddings node.
Activity
  • The author executed eslint checks on the new credential and embeddings node files.
  • The author performed a build using corepack pnpm --filter flowise-components build, which completed successfully.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for LM Studio embeddings by adding a new credential and a new embeddings node. The implementation correctly leverages the existing OpenAIEmbeddings class, which is suitable for LM Studio's OpenAI-compatible API. The code is well-structured and follows the patterns of existing nodes. I have one suggestion to improve the robustness of handling numeric input parameters to prevent potential issues with certain values like 0 or non-numeric inputs, aligning with repository guidelines for nullish checks.

Comment on lines +99 to +101
if (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (timeout) obj.timeout = parseInt(timeout, 10)
if (dimensions) obj.dimensions = parseInt(dimensions, 10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for handling numeric inputs (along with their declarations on lines 81-83) can be made more robust. The if (variable) check evaluates to false for a numeric value of 0, which might be a valid input for timeout. Also, the as string type assertion is unsafe, and parseInt can result in NaN for invalid inputs.

Consider this more robust approach that validates the input before parsing and assigning it. This also makes the separate variable declarations on lines 81-83 unnecessary. This suggestion aligns with the repository's guideline to use loose equality (== null) for nullish checks in TypeScript, covering both null and undefined.

Suggested change
if (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (timeout) obj.timeout = parseInt(timeout, 10)
if (dimensions) obj.dimensions = parseInt(dimensions, 10)
if (nodeData.inputs?.batchSize != null && nodeData.inputs?.batchSize !== '') {
const batchSize = parseInt(String(nodeData.inputs.batchSize), 10)
if (!isNaN(batchSize)) obj.batchSize = batchSize
}
if (nodeData.inputs?.timeout != null && nodeData.inputs?.timeout !== '') {
const timeout = parseInt(String(nodeData.inputs.timeout), 10)
if (!isNaN(timeout)) obj.timeout = timeout
}
if (nodeData.inputs?.dimensions != null && nodeData.inputs?.dimensions !== '') {
const dimensions = parseInt(String(nodeData.inputs.dimensions), 10)
if (!isNaN(dimensions)) obj.dimensions = dimensions
}
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

@stablegenius49
Copy link
Author

stablegenius49 commented Mar 3, 2026

Addressed the robustness suggestion in a follow-up commit (b4e6b1d).

  • Added safe optional integer parsing for batchSize, timeout, and dimensions
  • Preserves valid 0 values (no longer skipped by truthy checks)
  • Ignores invalid numeric inputs rather than passing NaN

Local checks passed:

  • npx eslint packages/components/nodes/embeddings/LMStudioEmbedding/LMStudioEmbedding.ts
  • corepack pnpm --filter flowise-components build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] support lm studio embeddings

1 participant