diff --git a/app/models/ai_api_audit_log.rb b/app/models/ai_api_audit_log.rb index 45752927..024ba44b 100644 --- a/app/models/ai_api_audit_log.rb +++ b/app/models/ai_api_audit_log.rb @@ -31,4 +31,5 @@ end # topic_id :integer # post_id :integer # feature_name :string(255) +# language_model :string(255) # diff --git a/db/migrate/20240527054218_add_language_model_to_ai_audit_logs.rb b/db/migrate/20240527054218_add_language_model_to_ai_audit_logs.rb new file mode 100644 index 00000000..5f639394 --- /dev/null +++ b/db/migrate/20240527054218_add_language_model_to_ai_audit_logs.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true +class AddLanguageModelToAiAuditLogs < ActiveRecord::Migration[7.0] + def change + add_column :ai_api_audit_logs, :language_model, :string, limit: 255 + end +end diff --git a/lib/completions/endpoints/base.rb b/lib/completions/endpoints/base.rb index 0df0ff0b..bd558c7d 100644 --- a/lib/completions/endpoints/base.rb +++ b/lib/completions/endpoints/base.rb @@ -120,6 +120,7 @@ module DiscourseAi topic_id: dialect.prompt.topic_id, post_id: dialect.prompt.post_id, feature_name: feature_name, + language_model: self.class.endpoint_name(@model), ) if !@streaming_mode diff --git a/spec/lib/completions/endpoints/cohere_spec.rb b/spec/lib/completions/endpoints/cohere_spec.rb index 52a73721..a6fa8d23 100644 --- a/spec/lib/completions/endpoints/cohere_spec.rb +++ b/spec/lib/completions/endpoints/cohere_spec.rb @@ -120,6 +120,8 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Cohere do # billing should be picked expect(audit.request_tokens).to eq(17) expect(audit.response_tokens).to eq(22) + + expect(audit.language_model).to eq("Cohere - command-r-plus") end it "is able to perform streaming completions" do