Class: LLM::DeepSeek::Images

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/providers/deepseek/images.rb

Overview

The LLM::DeepSeek::Images class provides image generation capabilities through DeepSeek.

DeepSeek does not provide an image generation model however its text-to-text models can generate vector graphics (SVGS) and that's the approach that this class takes. It is somewhat experimental.

An SVG document can be converted to PNG or another format with tools like rsvg-convert.

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ LLM::DeepSeek::Images

Parameters:



19
20
21
# File 'lib/llm/providers/deepseek/images.rb', line 19

def initialize(provider)
  @provider = provider
end

Instance Method Details

#create(prompt:, model: @provider.default_model, agent: nil, size: nil, n: nil, response_format: nil, quality: nil, style: nil) ⇒ LLM::Response<LLM::DeepSeek::ResponseAdapter::Image>

Returns a response

Parameters:

  • prompt (String)

    A prompt

  • model (String) (defaults to: @provider.default_model)

    A text-to-image model.

  • size (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • n (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • response_format (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • quality (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • style (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

Returns:



45
46
47
48
49
50
51
# File 'lib/llm/providers/deepseek/images.rb', line 45

def create(prompt:, model: @provider.default_model, agent: nil, size: nil, n: nil, response_format: nil, quality: nil, style: nil)
  agent ||= LLM::Agent.new(@provider, model:, instructions: create_instructions, response_format: {type: "json_object"})
  res = agent.talk(prompt)
  res = LLM::DeepSeek::ResponseAdapter.adapt(res, type: :image)
  res.define_singleton_method(:agent) { agent }
  res
end

#edit(prompt:, image:, model: @provider.default_model, agent: nil, size: nil, n: nil, response_format: nil, quality: nil, style: nil) ⇒ LLM::Response<LLM::DeepSeek::ResponseAdapter::Image>

Returns a response

Parameters:

  • prompt (String)

    A prompt

  • model (String) (defaults to: @provider.default_model)

    A text-to-image model.

  • image (String, LLM::File)

    The path to an SVG file

  • size (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • n (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • response_format (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • quality (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

  • style (void) (defaults to: nil)

    This parameter is a noop. Exists for compatibility with other providers.

Returns:



77
78
79
80
81
82
83
84
# File 'lib/llm/providers/deepseek/images.rb', line 77

def edit(prompt:, image:, model: @provider.default_model, agent: nil, size: nil, n: nil, response_format: nil, quality: nil, style: nil)
  file = LLM.File(image)
  agent ||= LLM::Agent.new(@provider, model:, instructions: edit_instructions(file), response_format: {type: "json_object"})
  res = agent.talk(prompt)
  res = LLM::DeepSeek::ResponseAdapter.adapt(res, type: :image)
  res.define_singleton_method(:agent) { agent }
  res
end