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

29
lib/bds/ai/in_flight.ex Normal file
View File

@@ -0,0 +1,29 @@
defmodule BDS.AI.InFlight do
@moduledoc false
@table :bds_ai_in_flight
def register(conversation_id, pid) when is_binary(conversation_id) and is_pid(pid) do
:ets.insert(table(), {conversation_id, pid})
:ok
end
def unregister(conversation_id) when is_binary(conversation_id) do
:ets.delete(table(), conversation_id)
:ok
end
def lookup(conversation_id) when is_binary(conversation_id) do
case :ets.lookup(table(), conversation_id) do
[{^conversation_id, pid}] -> pid
_other -> nil
end
end
defp table do
case :ets.whereis(@table) do
:undefined -> :ets.new(@table, [:named_table, :public, :set, read_concurrency: true])
table -> table
end
end
end