Class: Tep::Llm::OpenAI::Completion

Inherits:
Object
  • Object
show all
Defined in:
lib/tep/openai_server.rb

Overview

A backend’s generation result: the decoded text + token usage.

token_ids carries the GENERATED token IDs for an IDs-only backend (no detokenizer): when non-empty, CompletionsHandler emits them as choices.ids alongside text (which such a backend leaves “”), matching the “tokenize/detokenize client-side” serving contract. Text backends leave token_ids empty and the ids field is omitted. finish_reason defaults to “stop”; a fixed-length greedy backend sets “length”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompletion

Returns a new instance of Completion.



279
280
281
282
283
284
285
286
287
288
# File 'lib/tep/openai_server.rb', line 279

def initialize
  @text              = ""
  @prompt_tokens     = 0
  @completion_tokens = 0
  # Typed-empty Array[Integer] seed (the [0]; delete_at(0) landmine
  # pattern) so Spinel emits an IntArray slot, not poly.
  @token_ids         = [0]
  @token_ids.delete_at(0)
  @finish_reason     = "stop"
end

Instance Attribute Details

#completion_tokensObject

Returns the value of attribute completion_tokens.



276
277
278
# File 'lib/tep/openai_server.rb', line 276

def completion_tokens
  @completion_tokens
end

#finish_reasonObject

Returns the value of attribute finish_reason.



277
278
279
# File 'lib/tep/openai_server.rb', line 277

def finish_reason
  @finish_reason
end

#prompt_tokensObject

Returns the value of attribute prompt_tokens.



276
277
278
# File 'lib/tep/openai_server.rb', line 276

def prompt_tokens
  @prompt_tokens
end

#textObject

Returns the value of attribute text.



276
277
278
# File 'lib/tep/openai_server.rb', line 276

def text
  @text
end

#token_idsObject

Returns the value of attribute token_ids.



277
278
279
# File 'lib/tep/openai_server.rb', line 277

def token_ids
  @token_ids
end