Class: Roast::Cogs::Chat::Output

Inherits:
Roast::Cog::Output show all
Includes:
Roast::Cog::Output::WithJson, Roast::Cog::Output::WithNumber, Roast::Cog::Output::WithText
Defined in:
lib/roast/cogs/chat/output.rb

Overview

Output from running the chat cog

Contains the LLM’s response text from a chat completion request. The output provides convenient access to the response as plain text, parsed JSON, or as an array of lines through the included ‘WithText` and `WithJson` modules.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Roast::Cog::Output::WithText

#lines, #text

Methods included from Roast::Cog::Output::WithNumber

#float, #float!, #integer, #integer!

Constructor Details

#initialize(session, response) ⇒ Output

Initialize a new chat output with the session and response text

: (Session, String) -> void



48
49
50
51
52
# File 'lib/roast/cogs/chat/output.rb', line 48

def initialize(session, response)
  super()
  @session = session
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

The LLM’s response text

This is the complete text response returned by the language model for the chat request. The response can be accessed directly, or through convenience methods like ‘text`, `lines`, `json`, or `json!` provided by the included modules.

#### See Also

  • ‘text` (from WithText module)

  • ‘lines` (from WithText module)

  • ‘json` (from WithJson module)

  • ‘json!` (from WithJson module)

: String



30
31
32
# File 'lib/roast/cogs/chat/output.rb', line 30

def response
  @response
end

#sessionObject (readonly)

The session object containing the conversation context

This holds a reference to the complete message history needed to resume or continue a conversation with the language model. The session can be passed to subsequent ‘chat` cog invocations to maintain conversational context.

Note: you do __not__ have to use the same model for the entire conversation. You can change models between prompts while maintaining the same session, allowing different models to participate in the same conversation.

: Session



43
44
45
# File 'lib/roast/cogs/chat/output.rb', line 43

def session
  @session
end