mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-29 11:02:17 +00:00
adds support for "thinking tokens" - a feature that exposes the model's reasoning process before providing the final response. Key improvements include: - Add a new Thinking class to handle thinking content from LLMs - Modify endpoints (Claude, AWS Bedrock) to handle thinking output - Update AI bot to display thinking in collapsible details section - Fix SEARCH/REPLACE blocks to support empty replacement strings and general improvements to artifact editing - Allow configurable temperature in triage and report automations - Various bug fixes and improvements to diff parsing
39 lines
860 B
Ruby
39 lines
860 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module Completions
|
|
class Thinking
|
|
attr_accessor :message, :signature, :redacted, :partial
|
|
|
|
def initialize(message:, signature: nil, redacted: false, partial: false)
|
|
@message = message
|
|
@signature = signature
|
|
@redacted = redacted
|
|
@partial = partial
|
|
end
|
|
|
|
def partial?
|
|
!!@partial
|
|
end
|
|
|
|
def ==(other)
|
|
message == other.message && signature == other.signature && redacted == other.redacted &&
|
|
partial == other.partial
|
|
end
|
|
|
|
def dup
|
|
Thinking.new(
|
|
message: message.dup,
|
|
signature: signature.dup,
|
|
redacted: redacted,
|
|
partial: partial,
|
|
)
|
|
end
|
|
|
|
def to_s
|
|
"#{message} - #{signature} - #{redacted} - #{partial}"
|
|
end
|
|
end
|
|
end
|
|
end
|