Class: Llmclt::Syntax::Chat

Inherits:
Object
  • Object
show all
Defined in:
lib/llmclt/syntax/chat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prompts, config, histories: []) ⇒ Chat

Returns a new instance of Chat.



9
10
11
12
13
14
# File 'lib/llmclt/syntax/chat.rb', line 9

def initialize(prompts, config, histories: [])
  @prompts = Array(prompts)
  @config = config
  @histories = histories
  @params = build_params
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/llmclt/syntax/chat.rb', line 6

def config
  @config
end

#historiesObject (readonly)

Returns the value of attribute histories.



6
7
8
# File 'lib/llmclt/syntax/chat.rb', line 6

def histories
  @histories
end

#paramsObject (readonly)

Returns the value of attribute params.



7
8
9
# File 'lib/llmclt/syntax/chat.rb', line 7

def params
  @params
end

#promptsObject (readonly)

Returns the value of attribute prompts.



6
7
8
# File 'lib/llmclt/syntax/chat.rb', line 6

def prompts
  @prompts
end

Instance Method Details

#to_json(*_args) ⇒ Object



16
17
18
# File 'lib/llmclt/syntax/chat.rb', line 16

def to_json(*_args)
  params.size == 1 ? params.first.to_json : params.to_json
end

#to_jsonlObject



20
21
22
# File 'lib/llmclt/syntax/chat.rb', line 20

def to_jsonl
  params.map { |json| { request: json } }.map(&:to_json).join("\n")
end