FEATURE: improve logging by including llm name (#640)

Log the language model name when logging api requests
This commit is contained in:
Sam 2024-05-27 16:46:01 +10:00 committed by GitHub
parent d8a0f44fed
commit baf88e7cfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 0 deletions

View File

@ -31,4 +31,5 @@ end
# topic_id :integer
# post_id :integer
# feature_name :string(255)
# language_model :string(255)
#

View File

@ -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

View File

@ -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

View File

@ -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