File size: 1,943 Bytes
3f219b5
d77a9fd
 
 
 
 
4b67cec
d77a9fd
5aee375
 
d77a9fd
 
 
3f219b5
 
28c8908
3f219b5
0a57d6d
d77a9fd
3f219b5
4b67cec
 
 
dbe78d6
34b4725
3f219b5
7625517
 
 
3f219b5
7625517
34b4725
3f219b5
 
d77a9fd
3f219b5
d77a9fd
 
 
 
3f219b5
d77a9fd
 
 
 
 
 
 
3f219b5
d77a9fd
 
48a456d
59fddbd
3f219b5
4b67cec
 
59fddbd
3f219b5
4b67cec
 
59fddbd
3f219b5
48a456d
d77a9fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
defmodule Medicode.Application do
  # See https://hexdocs.pm/elixir/Application.html
  # for more information on OTP Applications
  @moduledoc false

  use Application
  alias AudioTagger.{KeywordFinder, Transcriber, Vectors}

  @model_name "openai/whisper-tiny"

  @impl true
  def start(_type, _args) do
    children = [
      MedicodeWeb.Telemetry,
      Medicode.Repo,
      {DNSCluster,
       query: Application.get_env(:medicode, :dns_cluster_query) || :ignore},
      {Phoenix.PubSub, name: :medicode_pubsub},
      # Start the Finch HTTP client for sending emails
      {Finch, name: Medicode.Finch},
      transcription_spec(),
      token_classification_spec(),
      text_embedding_spec(),
      {Registry, keys: :unique, name: :transcription_registry},
      {
        Medicode.TranscriptionSupervisor,
        strategy: :one_for_one, max_restarts: 1
      },
      {
        Medicode.ClassificationSupervisor,
        strategy: :one_for_one, max_restarts: 1
      },
      # Start a worker by calling: Medicode.Worker.start_link(arg)
      # {Medicode.Worker, arg},
      # Start to serve requests, typically the last entry
      MedicodeWeb.Endpoint
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: Medicode.Supervisor]
    Supervisor.start_link(children, opts)
  end

  # Tell Phoenix to update the endpoint configuration
  # whenever the application is updated.
  @impl true
  def config_change(changed, _new, removed) do
    MedicodeWeb.Endpoint.config_change(changed, removed)
    :ok
  end

  defp transcription_spec do
    Transcriber.child_spec(Medicode.TranscriptionServing, @model_name)
  end

  defp token_classification_spec do
    KeywordFinder.token_classification_child_spec(Medicode.TokenClassificationServing)
  end

  defp text_embedding_spec do
    Vectors.child_spec(Medicode.TextEmbeddingServing)
  end
end