working on db logic
Some checks failed
CI/CD Pipeline / build (push) Failing after 3s

This commit is contained in:
2026-03-12 15:01:33 -06:00
parent 399eb9f93f
commit 4dc4814b2f
21 changed files with 573 additions and 256 deletions

View File

@@ -1,15 +1,21 @@
defmodule ElixirAi.Data.AiProviderSchema do
use Ecto.Schema
defstruct [:id, :name, :model_name, :api_token, :completions_url, :inserted_at, :updated_at]
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
def schema do
Zoi.object(%{
id: Zoi.string(),
name: Zoi.string(),
model_name: Zoi.string(),
api_token: Zoi.string(),
completions_url: Zoi.string()
})
end
schema "ai_providers" do
field(:name, :string)
field(:model_name, :string)
field(:api_token, :string)
field(:completions_url, :string)
timestamps(type: :utc_datetime)
def partial_schema do
Zoi.object(%{
id: Zoi.string(),
name: Zoi.string(),
model_name: Zoi.string()
})
end
end

View File

@@ -1,13 +1,11 @@
defmodule ElixirAi.Data.ConversationSchema do
use Ecto.Schema
defstruct [:id, :name, :ai_provider_id, :inserted_at, :updated_at]
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "conversations" do
field(:name, :string)
belongs_to(:ai_provider, ElixirAi.Data.AiProviderSchema, type: :binary_id)
timestamps(type: :utc_datetime)
def schema do
Zoi.object(%{
id: Zoi.string(),
name: Zoi.string(),
ai_provider_id: Zoi.string()
})
end
end

View File

@@ -1,16 +1,18 @@
defmodule ElixirAi.Data.MessageSchema do
use Ecto.Schema
defstruct [
:id,
:conversation_id,
:role,
:content,
:reasoning_content,
:tool_calls,
:tool_call_id,
:inserted_at
]
@primary_key {:id, :id, autogenerate: true}
schema "messages" do
belongs_to(:conversation, ElixirAi.Data.ConversationSchema, type: :binary_id)
field(:role, :string)
field(:content, :string)
field(:reasoning_content, :string)
field(:tool_calls, :map)
field(:tool_call_id, :string)
timestamps(inserted_at: :inserted_at, updated_at: false, type: :utc_datetime)
def schema do
Zoi.object(%{
role: Zoi.string()
})
end
end