Skip to content

[BUG] Inconsistent return format for RubyLLM.embed with single vs multiple inputs #254

@finbarr

Description

@finbarr

Basic checks

  • I searched existing issues - this hasn't been reported
  • I can reproduce this consistently
  • This is a RubyLLM bug, not my application code

What's broken?

The RubyLLM.embed method returns different data structures depending on the number of inputs, making it difficult to handle dynamic use cases.

Current behavior:

  • RubyLLM.embed(["string1", "string2"]) returns an Embedding object with vectors as an array of arrays:
    [[vector1], [vector2]]
  • RubyLLM.embed(["string1"]) returns an Embedding object with vectors as a single array: [vector1]

How to reproduce

RubyLLM.embed(["foo", "bar"]) -> [[vector], [vector]]
RubyLLM.embed(["foo"]) -> [vector]

Expected behavior

The return format should be consistent regardless of input count. Single inputs should return [[vector]] to match the multi-input format.

What actually happened

It returns [vector].

Environment

RubyLLM 1.3.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions