feat: start on AI integration

This commit is contained in:
2026-04-24 13:56:42 +02:00
parent 15584c72f7
commit 78609377be
16 changed files with 2410 additions and 8 deletions

View File

@@ -0,0 +1,41 @@
defmodule BDS.AI.ChatMessage do
@moduledoc false
use Ecto.Schema
import Ecto.Changeset
@foreign_key_type :string
@roles [:system, :user, :assistant, :tool]
schema "chat_messages" do
belongs_to :conversation, BDS.AI.ChatConversation, references: :id, type: :string
field :role, Ecto.Enum, values: @roles
field :content, :string
field :tool_call_id, :string
field :tool_calls, :string
field :token_usage_input, :integer
field :token_usage_output, :integer
field :cache_read_tokens, :integer
field :cache_write_tokens, :integer
field :created_at, :integer
end
def changeset(message, attrs) do
message
|> cast(attrs, [
:conversation_id,
:role,
:content,
:tool_call_id,
:tool_calls,
:token_usage_input,
:token_usage_output,
:cache_read_tokens,
:cache_write_tokens,
:created_at
], empty_values: [nil])
|> validate_required([:conversation_id, :role, :created_at])
|> assoc_constraint(:conversation)
end
end