Skip to content

Commit

Permalink
Update list of language models, Assistant model belongs_to LanguageMo…
Browse files Browse the repository at this point in the history
…del, implement the "best" naming
  • Loading branch information
stephan-buckmaster committed May 13, 2024
1 parent 77dcefb commit de6c887
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions app/models/assistant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Assistant < ApplicationRecord
has_many :steps, dependent: :destroy
has_many :messages # TODO: What should happen if an assistant is deleted?

belongs_to :language_model, primary_key: :name, foreign_key: :model

validates :tools, presence: true, allow_blank: true

MAX_LIST_DISPLAY = 5
Expand Down
6 changes: 6 additions & 0 deletions app/models/language_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
class LanguageModel < ApplicationRecord
def readonly?() = !new_record?
def before_destroy() = raise ActiveRecord::ReadOnlyRecord

PROVIDER_ID_MAP = {'gpt-best': 'gpt-4-turbo',
'claude-best': 'claude-3-opus-20240229'}
def provider_id
PROVIDER_ID_MAP[self.name.to_sym] || self.name unless self.name =~ /^best/
end
end
2 changes: 1 addition & 1 deletion app/services/ai_backends/anthropic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_next_chat_message(&chunk_received_handler)

begin
response = @client.messages(
model: @assistant.model,
model: @assistant.model.provider_id,
system: @assistant.instructions,
messages: preceding_messages,
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion app/services/ai_backends/open_ai.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_next_chat_message(&chunk_received_handler)

begin
response = @client.chat(parameters: {
model: @assistant.model,
model: @assistant.language_model.provider_id,
messages: system_message + preceding_messages,
stream: response_handler,
max_tokens: 2000, # we should really set this dynamically, based on the model, to the max
Expand Down
15 changes: 8 additions & 7 deletions db/migrate/20240512163300_create_language_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ def change
# Current models
up_only do
{
'open_ai_best': 'Best OpenAI Model',
'claude_best': 'Best Anthropic Model',
'gpt-best': 'Best OpenAI Model',
'claude-best': 'Best Anthropic Model',

'gpt-4': 'ChatGPT 4',
'gpt-4-turbo': 'ChatGPT 4 Turbo with Vision (may update)',
'gpt-4-turbo': 'ChatGPT 4 Turbo with Vision (may update in future)',
'gpt-4-turbo-2024-04-09': 'ChatGPT-4 Turbo with Vision (2024-04-09)',
'gpt-4-turbo-preview': 'ChatGPT 4 Turbo Preview',
'gpt-4-0125-preview': 'ChatGPT 4 Turbo Preview (2024-01-25)',
'gpt-4-1106-preview': 'ChatGPT 4 Turbo Preview (2023-11-06)',
'gpt-4-vision-preview': 'ChatGPT 4 Turbo Model preview with the ability to understand images',
'gpt-4-1106-vision-preview': 'ChatGPT 4 Turbo Model preview with the ability to understand images (2023-11-06)',
'gpt-4-vision-preview': 'ChatGPT 4 Turbo Model preview with the ability to understand images (2023-11-06)',
'gpt-4-1106-vision-preview': 'ChatGPT 4 Turbo preview with the ability to understand images (2023-11-06)',
'gpt-4-0613': 'ChatGPT 4 Snapshot improved function calling (2023-06-13)',

'gpt-3.5-turbo': 'ChatGPT 3.5 Turbo',
'gpt-3.5-turbo-16k-0613': 'ChatGPT 3.5 Turbo (2023-06-13)',
'gpt-3.5-turbo-0125': 'ChatGPT 3.5 Turbo (2023-01-25)',
'gpt-3.5-turbo-16k-0613': 'ChatGPT 3.5 Turbo (2022-06-13)',
'gpt-3.5-turbo-0125': 'ChatGPT 3.5 Turbo (2022-01-25)',
'gpt-3.5-turbo-1106': 'ChatGPT 3.5 Turbo (2022-11-06)',
'gpt-3.5-turbo-instruct': 'ChatGPT 3.5 Turbo Instruct',

'claude-3-opus-20240229': 'Claude 3 Opus (2024-02-29)',
Expand Down

0 comments on commit de6c887

Please sign in to comment.