2024-05-13 11:46:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class LlmModelSerializer < ApplicationSerializer
|
2024-09-30 03:15:11 -04:00
|
|
|
# TODO: we probably should rename the table LlmModel to AiLlm
|
|
|
|
# it is consistent with AiPersona and AiTool
|
|
|
|
# LLM model is a bit confusing given that large langauge model model is a confusing
|
|
|
|
# name
|
|
|
|
root "ai_llm"
|
2024-06-18 13:32:14 -04:00
|
|
|
attributes :id,
|
|
|
|
:display_name,
|
|
|
|
:name,
|
|
|
|
:provider,
|
|
|
|
:max_prompt_tokens,
|
|
|
|
:tokenizer,
|
|
|
|
:api_key,
|
|
|
|
:url,
|
|
|
|
:enabled_chat_bot,
|
2024-07-24 15:29:47 -04:00
|
|
|
:provider_params,
|
2024-08-06 13:35:35 -04:00
|
|
|
:vision_enabled,
|
|
|
|
:used_by
|
2024-06-18 13:32:14 -04:00
|
|
|
|
2024-06-19 10:21:21 -04:00
|
|
|
has_one :user, serializer: BasicUserSerializer, embed: :object
|
|
|
|
|
2024-08-06 13:35:35 -04:00
|
|
|
def used_by
|
2024-10-21 20:16:02 -04:00
|
|
|
llm_usage =
|
|
|
|
(
|
|
|
|
if (scope && scope[:llm_usage])
|
|
|
|
scope[:llm_usage]
|
|
|
|
else
|
|
|
|
DiscourseAi::Configuration::LlmEnumerator.global_usage
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
llm_usage[object.id]
|
2024-06-18 13:32:14 -04:00
|
|
|
end
|
2024-08-28 14:57:58 -04:00
|
|
|
|
|
|
|
def api_key
|
|
|
|
object.seeded? ? "********" : object.api_key
|
|
|
|
end
|
|
|
|
|
|
|
|
def url
|
|
|
|
object.seeded? ? "********" : object.url
|
|
|
|
end
|
|
|
|
|
|
|
|
def provider
|
|
|
|
object.seeded? ? "CDCK" : object.provider
|
|
|
|
end
|
2024-05-13 11:46:42 -04:00
|
|
|
end
|