|
7 | 7 | t.timestamps |
8 | 8 | end |
9 | 9 |
|
10 | | - # Currently supported models |
11 | | - { |
12 | | - 1, 'gpt-best': 'Best OpenAI Model', |
13 | | - 2, 'claude-best': 'Best Anthropic Model', |
14 | | - |
15 | | - 3, 'gpt-4': 'ChatGPT 4', |
16 | | - 4, 'gpt-4-turbo': 'ChatGPT 4 Turbo with Vision (may update in future)', |
17 | | - 5, 'gpt-4-turbo-2024-04-09': 'ChatGPT-4 Turbo with Vision (2024-04-09)', |
18 | | - 6, 'gpt-4-turbo-preview': 'ChatGPT 4 Turbo Preview', |
19 | | - 7, 'gpt-4-0125-preview': 'ChatGPT 4 Turbo Preview (2024-01-25)', |
20 | | - 8, 'gpt-4-1106-preview': 'ChatGPT 4 Turbo Preview (2023-11-06)', |
21 | | - 9, 'gpt-4-vision-preview': 'ChatGPT 4 Turbo Model preview with the ability to understand images (2023-11-06)', |
22 | | - 10, 'gpt-4-1106-vision-preview': 'ChatGPT 4 Turbo preview with the ability to understand images (2023-11-06)', |
23 | | - 11, 'gpt-4-0613': 'ChatGPT 4 Snapshot improved function calling (2023-06-13)', |
24 | | - |
25 | | - 12, 'gpt-3.5-turbo': 'ChatGPT 3.5 Turbo', |
26 | | - 13, 'gpt-3.5-turbo-16k-0613': 'ChatGPT 3.5 Turbo (2022-06-13)', |
27 | | - 14, 'gpt-3.5-turbo-0125': 'ChatGPT 3.5 Turbo (2022-01-25)', |
28 | | - 15, 'gpt-3.5-turbo-1106': 'ChatGPT 3.5 Turbo (2022-11-06)', |
29 | | - 16, 'gpt-3.5-turbo-instruct': 'ChatGPT 3.5 Turbo Instruct', |
30 | | - |
31 | | - 17, 'claude-3-opus-20240229': 'Claude 3 Opus (2024-02-29)', |
32 | | - 18, 'claude-3-sonnet-20240229': 'Claude 3 Sonnet (2024-02-29)', |
33 | | - 19, 'claude-3-haiku-20240307': 'Claude 3 Haiku (2024-03-07)', |
34 | | - 20, 'claude-2.1': 'Claude 2.1', |
35 | | - 21, 'claude-2.0': 'Claude 2.0', |
36 | | - 22, 'claude-instant-1.2': 'Claude Instant 1.2' |
37 | | - }.each do |name, description| |
38 | | - LanguageModel.create(name: name, description: description) |
| 10 | + # Initially supported models |
| 11 | + [ |
| 12 | + [1, 'gpt-best', 'Best OpenAI Model'], |
| 13 | + [2, 'claude-best', 'Best Anthropic Model'], |
| 14 | + |
| 15 | + [3, 'gpt-4', 'ChatGPT 4'], |
| 16 | + [4, 'gpt-4-turbo', 'ChatGPT 4 Turbo with Vision (may update in future)'], |
| 17 | + [5, 'gpt-4-turbo-2024-04-09', 'ChatGPT-4 Turbo with Vision (2024-04-09)'], |
| 18 | + [6, 'gpt-4-turbo-preview', 'ChatGPT 4 Turbo Preview'], |
| 19 | + [7, 'gpt-4-0125-preview', 'ChatGPT 4 Turbo Preview (2024-01-25)'], |
| 20 | + [8, 'gpt-4-1106-preview', 'ChatGPT 4 Turbo Preview (2023-11-06)'], |
| 21 | + [9, 'gpt-4-vision-preview', 'ChatGPT 4 Turbo Model preview with the ability to understand images (2023-11-06)'], |
| 22 | + [10, 'gpt-4-1106-vision-preview', 'ChatGPT 4 Turbo preview with the ability to understand images (2023-11-06)'], |
| 23 | + [11, 'gpt-4-0613', 'ChatGPT 4 Snapshot improved function calling (2023-06-13)'], |
| 24 | + |
| 25 | + [12, 'gpt-3.5-turbo', 'ChatGPT 3.5 Turbo'], |
| 26 | + [13, 'gpt-3.5-turbo-16k-0613', 'ChatGPT 3.5 Turbo (2022-06-13)'], |
| 27 | + [14, 'gpt-3.5-turbo-0125', 'ChatGPT 3.5 Turbo (2022-01-25)'], |
| 28 | + [15, 'gpt-3.5-turbo-1106', 'ChatGPT 3.5 Turbo (2022-11-06)'], |
| 29 | + [16, 'gpt-3.5-turbo-instruct', 'ChatGPT 3.5 Turbo Instruct'], |
| 30 | + |
| 31 | + [17, 'claude-3-opus-20240229', 'Claude 3 Opus (2024-02-29)'], |
| 32 | + [18, 'claude-3-sonnet-20240229', 'Claude 3 Sonnet (2024-02-29)'], |
| 33 | + [19, 'claude-3-haiku-20240307', 'Claude 3 Haiku (2024-03-07)'], |
| 34 | + [20, 'claude-2.1', 'Claude 2.1'], |
| 35 | + [21, 'claude-2.0', 'Claude 2.0'], |
| 36 | + [22, 'claude-instant-1.2', 'Claude Instant 1.2'] |
| 37 | + ].each do |db_id, name, description| |
| 38 | + record = LanguageModel.new(name: name, description: description) |
| 39 | + record.id = db_id |
| 40 | + record.save! |
39 | 41 | end |
40 | 42 |
|
| 43 | + ActiveRecord::Base.connection.execute "ALTER SEQUENCE language_models_id_seq RESTART WITH 30;" |
| 44 | + |
41 | 45 | # Respect some users who may have added their own model values in the assistants table |
42 | 46 | (Assistant.all.pluck(:model).uniq - LanguageModel.all.pluck(:name)).each do |model_name| |
43 | | - LanguageModel.create(name: model_name, description: '???') |
| 47 | + Rails.logger.info "Create language_models record from assistants column value: #{model_name.inspect}" |
| 48 | + LanguageModel.create!(name: model_name, description: model_name) |
44 | 49 | end |
45 | 50 |
|
46 | 51 | add_reference :assistants, :language_model, null: true, foreign_key: { to_table: :language_models} |
47 | 52 |
|
48 | | - ActiveRecord::Base.connection.execute 'update assistants a set language_model_id = (select id from language_models lm where lm.name = a.model)' |
| 53 | + Assistant.all.each do |a| |
| 54 | + Rails.logger.info "Have assistant #{a.id} with model #{a.model}" |
| 55 | + end |
| 56 | + ActiveRecord::Base.connection.execute "update assistants a set language_model_id = (select id from language_models lm where lm.name = a.model)" |
49 | 57 |
|
50 | 58 | remove_column :assistants, :model |
51 | 59 | end |
52 | 60 |
|
53 | 61 | def down |
54 | 62 | add_column :assistants, :model, :string |
55 | | - ActiveRecord::Base.connection.execute 'update assistants a set model = (select name from language_models lm where lm.id = a.language_model_id)' |
| 63 | + ActiveRecord::Base.connection.execute "update assistants a set model = (select name from language_models lm where lm.id=a.language_model_id)" |
56 | 64 |
|
57 | 65 | remove_column :assistants, :language_model_id |
58 | 66 | drop_table :language_models |
59 | | - |
60 | | - remove_column :runs, :model |
61 | 67 | end |
62 | 68 | end |
0 commit comments