Skip to content

Commit b5a231b

Browse files
authored
Merge pull request #143 from merefield/add_gpt5_support
FEATURE: add GPT-5 support
2 parents 65bb588 + 022ae19 commit b5a231b

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class ::Jobs::BackfillChatbotQuotas < ::Jobs::Onceoff
4+
def execute_onceoff(args)
5+
return unless SiteSetting.chatbot_enabled
6+
7+
# Initialize Chatbot Quotas for all users as required
8+
user_count = User.count
9+
queries_field_count = UserCustomField.where(name: ::DiscourseChatbot::CHATBOT_REMAINING_QUOTA_QUERIES_CUSTOM_FIELD).count
10+
token_field_count = UserCustomField.where(name: ::DiscourseChatbot::CHATBOT_REMAINING_QUOTA_TOKENS_CUSTOM_FIELD).count
11+
Rails.logger.warn "CHATBOT: Checked presence of Chatbot Custom Fields"
12+
if user_count > queries_field_count * 2 || user_count > token_field_count * 2
13+
::DiscourseChatbot::Bot.new.reset_all_quotas
14+
Rails.logger.warn "CHATBOT: Resetted Chatbot Quotas for all users as many users without required Chatbot Custom Fields"
15+
end
16+
end
17+
end

config/settings.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ plugins:
4747
- gpt-4o
4848
- gpt-4o-mini
4949
- gpt-4-turbo
50+
- gpt-5
51+
- gpt-5-mini
52+
- gpt-5-nano
5053
- o4-mini
5154
- o3
5255
- o3-mini
@@ -79,6 +82,9 @@ plugins:
7982
- gpt-4o
8083
- gpt-4o-mini
8184
- gpt-4-turbo
85+
- gpt-5
86+
- gpt-5-mini
87+
- gpt-5-nano
8288
- o4-mini
8389
- o3
8490
- o3-mini
@@ -111,6 +117,9 @@ plugins:
111117
- gpt-4o
112118
- gpt-4o-mini
113119
- gpt-4-turbo
120+
- gpt-5
121+
- gpt-5-mini
122+
- gpt-5-nano
114123
- o4-mini
115124
- o3
116125
- o3-mini
@@ -130,6 +139,7 @@ plugins:
130139
type: enum
131140
default: medium
132141
choices:
142+
- minimal
133143
- low
134144
- medium
135145
- high

plugin.rb

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# frozen_string_literal: true
22
# name: discourse-chatbot
3-
# about: a plugin that allows you to have a conversation with a configurable chatbot in Discourse Chat, Topics and Private Messages
4-
# version: 1.5.14
3+
# about: a plugin that allows you to have a conversation with a configurable chatbot in Chat, Topics and Private Messages
4+
# version: 1.5.15
55
# authors: merefield
66
# url: https://github.com/merefield/discourse-chatbot
77

8+
gem 'domain_name', '0.6.20240107', { require: false }
9+
gem 'http-cookie', '1.0.8', { require: false }
810
gem 'event_stream_parser', '1.0.0', { require: false }
911
gem "ruby-openai", '8.1.0', { require: false }
1012
# google search
@@ -39,7 +41,7 @@ module ::DiscourseChatbot
3941
POST_URL_REGEX = %r{\/t/[^/]+/(\d+)/(\d+)(?!\d|\/)}
4042
NON_POST_URL_REGEX = %r{\bhttps?:\/\/[^\s\/$.?#].[^\s)]*}
4143

42-
REASONING_MODELS = ["o1", "o1-mini", "o3", "o3-mini", "o4-mini"]
44+
REASONING_MODELS = ["o1", "o1-mini", "o3", "o3-mini", "o4-mini", "gpt-5", "gpt-5-mini", "gpt-5-nano"]
4345

4446
def progress_debug_message(message)
4547
puts "Chatbot: #{message}" if SiteSetting.chatbot_enable_verbose_console_logging
@@ -143,16 +145,6 @@ def progress_debug_message(message)
143145
register_user_custom_field_type(::DiscourseChatbot::CHATBOT_REMAINING_QUOTA_TOKENS_CUSTOM_FIELD, :integer)
144146
register_user_custom_field_type(::DiscourseChatbot::CHATBOT_QUERIES_QUOTA_REACH_ESCALATION_DATE_CUSTOM_FIELD, :date)
145147

146-
# Initialize Chatbot Quotas for all users as required
147-
user_count = User.count
148-
queries_field_count = UserCustomField.where(name: ::DiscourseChatbot::CHATBOT_REMAINING_QUOTA_QUERIES_CUSTOM_FIELD).count
149-
token_field_count = UserCustomField.where(name: ::DiscourseChatbot::CHATBOT_REMAINING_QUOTA_TOKENS_CUSTOM_FIELD).count
150-
pp "CHATBOT: Checking presence of Chatbot Custom Fields"
151-
if user_count > queries_field_count * 2 || user_count > token_field_count * 2
152-
pp "CHATBOT: Resetting Chatbot Quotas for all users as many users without required Chatbot Custom Fields"
153-
::DiscourseChatbot::Bot.new.reset_all_quotas
154-
end
155-
156148
add_to_serializer(:current_user, :chatbot_access) do
157149
!::DiscourseChatbot::EventEvaluation.new.trust_level(object.id).blank?
158150
end
@@ -273,4 +265,5 @@ class ::Chat::UpdateUserLastRead
273265
end
274266
end
275267
end
268+
Jobs.enqueue(:backfill_chatbot_quotas)
276269
end

0 commit comments

Comments
 (0)