2023-04-25 21:44:29 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AiApiAuditLog < ActiveRecord::Base
|
2024-04-15 09:22:06 -04:00
|
|
|
belongs_to :post
|
|
|
|
belongs_to :topic
|
|
|
|
|
2023-04-25 21:44:29 -04:00
|
|
|
module Provider
|
|
|
|
OpenAI = 1
|
2023-05-11 09:03:03 -04:00
|
|
|
Anthropic = 2
|
2023-07-27 12:55:32 -04:00
|
|
|
HuggingFaceTextGeneration = 3
|
2023-12-15 12:32:01 -05:00
|
|
|
Gemini = 4
|
2023-12-26 12:49:55 -05:00
|
|
|
Vllm = 5
|
2024-04-10 17:24:17 -04:00
|
|
|
Cohere = 6
|
2024-05-07 09:02:16 -04:00
|
|
|
Ollama = 7
|
2024-09-11 21:28:08 -04:00
|
|
|
SambaNova = 8
|
2024-11-19 01:28:09 -05:00
|
|
|
Mistral = 9
|
2023-04-25 21:44:29 -04:00
|
|
|
end
|
2024-11-11 16:14:30 -05:00
|
|
|
|
|
|
|
def next_log_id
|
|
|
|
self.class.where("id > ?", id).where(topic_id: topic_id).order(id: :asc).pluck(:id).first
|
|
|
|
end
|
|
|
|
|
|
|
|
def prev_log_id
|
|
|
|
self.class.where("id < ?", id).where(topic_id: topic_id).order(id: :desc).pluck(:id).first
|
|
|
|
end
|
2023-04-25 21:44:29 -04:00
|
|
|
end
|
2023-05-11 09:03:03 -04:00
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: ai_api_audit_logs
|
|
|
|
#
|
|
|
|
# id :bigint not null, primary key
|
|
|
|
# provider_id :integer not null
|
|
|
|
# user_id :integer
|
|
|
|
# request_tokens :integer
|
|
|
|
# response_tokens :integer
|
|
|
|
# raw_request_payload :string
|
|
|
|
# raw_response_payload :string
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
2024-05-13 23:28:46 -04:00
|
|
|
# topic_id :integer
|
|
|
|
# post_id :integer
|
|
|
|
# feature_name :string(255)
|
2024-05-27 02:46:01 -04:00
|
|
|
# language_model :string(255)
|
2024-10-23 01:49:56 -04:00
|
|
|
# feature_context :jsonb
|