mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-07-18 11:49:33 +08:00
Previous to this change our results were ungrounded and simpler models like GPT 3.5 and claude had a real tough time figuring out how to run commands This splits responses into 2 phases: Phase 1: figure out if you need to run a command Phase 2: respond to user This seems to produce better results on both Claude and GPT 3.5 but still needs a fair bit of tuning.
38 lines
663 B
Ruby
38 lines
663 B
Ruby
#frozen_string_literal: true
|
|
|
|
module DiscourseAi::AiBot::Commands
|
|
class TimeCommand < Command
|
|
class << self
|
|
def name
|
|
"time"
|
|
end
|
|
|
|
def desc
|
|
"!time RUBY_COMPATIBLE_TIMEZONE - will generate the time in a timezone"
|
|
end
|
|
end
|
|
|
|
def result_name
|
|
"time"
|
|
end
|
|
|
|
def description_args
|
|
{ timezone: @last_timezone, time: @last_time }
|
|
end
|
|
|
|
def process
|
|
time =
|
|
begin
|
|
Time.now.in_time_zone(@args)
|
|
rescue StandardError
|
|
nil
|
|
end
|
|
time = Time.now if !time
|
|
|
|
@last_timezone = timezone
|
|
@last_time = time.to_s
|
|
|
|
time.to_s
|
|
end
|
|
end
|
|
end
|