Sam f6eedf3e0b
FEATURE: implement thinking token support (#1155)
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
2025-03-04 12:22:30 +11:00

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