using providers
Some checks failed
CI/CD Pipeline / build (push) Failing after 4s

This commit is contained in:
2026-03-13 15:55:05 -06:00
parent 4de7db6f56
commit 179149b986
7 changed files with 80 additions and 37 deletions

View File

@@ -113,5 +113,23 @@ defmodule ElixirAi.Conversation do
end
end
def find_provider(name) do
sql = """
SELECT p.name, p.model_name, p.api_token, p.completions_url
FROM conversations c
JOIN ai_providers p ON c.ai_provider_id = p.id
WHERE c.name = $(name)
LIMIT 1
"""
params = %{"name" => name}
case DbHelpers.run_sql(sql, params, "conversations", Provider.schema()) do
{:error, _} -> {:error, :db_error}
[] -> {:error, :not_found}
[row | _] -> {:ok, struct(Provider, row)}
end
end
defp now, do: DateTime.truncate(DateTime.utc_now(), :second)
end