1
0
mirror of synced 2026-08-05 23:36:55 +00:00
Files

56 lines
1.4 KiB
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
class AiApiAuditLog < ActiveRecord::Base
belongs_to :post
belongs_to :topic
2024-11-29 06:26:48 +11:00
belongs_to :user
module Provider
OpenAI = 1
Anthropic = 2
2023-07-27 13:55:32 -03:00
HuggingFaceTextGeneration = 3
Gemini = 4
2023-12-26 14:49:55 -03:00
Vllm = 5
2024-04-11 07:24:17 +10:00
Cohere = 6
Ollama = 7
SambaNova = 8
Mistral = 9
OpenRouter = 10
end
2024-11-12 08:14:30 +11: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
end
# == 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
# topic_id :integer
# post_id :integer
# feature_name :string(255)
# language_model :string(255)
# feature_context :jsonb
2024-11-29 06:26:48 +11:00
# cached_tokens :integer
2025-01-23 11:32:12 +11:00
# duration_msecs :integer
2024-11-29 06:26:48 +11:00
#
# Indexes
#
# index_ai_api_audit_logs_on_created_at_and_feature_name (created_at,feature_name)
# index_ai_api_audit_logs_on_created_at_and_language_model (created_at,language_model)
#