noahsettersten commited on
Commit
4b67cec
1 Parent(s): a227b91

chore: Move child specs to functions in AudioTagger

Browse files
lib/medical_transcription/application.ex CHANGED
@@ -4,19 +4,12 @@ defmodule MedicalTranscription.Application do
4
  @moduledoc false
5
 
6
  use Application
 
7
 
8
  @model_name "openai/whisper-tiny"
9
 
10
  @impl true
11
  def start(_type, _args) do
12
- transcription_serving =
13
- AudioTagger.Transcriber.prepare_serving(@model_name)
14
-
15
- token_classification_serving =
16
- AudioTagger.KeywordFinder.prepare_token_classification_serving()
17
-
18
- text_embedding_serving = AudioTagger.Vectors.prepare_serving()
19
-
20
  children = [
21
  MedicalTranscriptionWeb.Telemetry,
22
  MedicalTranscription.Repo,
@@ -25,9 +18,9 @@ defmodule MedicalTranscription.Application do
25
  {Phoenix.PubSub, name: MedicalTranscription.PubSub},
26
  # Start the Finch HTTP client for sending emails
27
  {Finch, name: MedicalTranscription.Finch},
28
- serving_child_spec(MedicalTranscription.TranscriptionServing, transcription_serving, 4),
29
- serving_child_spec(MedicalTranscription.TokenClassificationServing, token_classification_serving, 1),
30
- {Nx.Serving, serving: text_embedding_serving, name: MedicalTranscription.TextEmbeddingServing},
31
  # Start a worker by calling: MedicalTranscription.Worker.start_link(arg)
32
  # {MedicalTranscription.Worker, arg},
33
  # Start to serve requests, typically the last entry
@@ -48,10 +41,15 @@ defmodule MedicalTranscription.Application do
48
  :ok
49
  end
50
 
51
- defp serving_child_spec(name, serving, batch_size) do
52
- {
53
- Nx.Serving,
54
- serving: serving, name: name, batch_size: batch_size, batch_timeout: 100
55
- }
 
 
 
 
 
56
  end
57
  end
 
4
  @moduledoc false
5
 
6
  use Application
7
+ alias AudioTagger.{KeywordFinder, Transcriber, Vectors}
8
 
9
  @model_name "openai/whisper-tiny"
10
 
11
  @impl true
12
  def start(_type, _args) do
 
 
 
 
 
 
 
 
13
  children = [
14
  MedicalTranscriptionWeb.Telemetry,
15
  MedicalTranscription.Repo,
 
18
  {Phoenix.PubSub, name: MedicalTranscription.PubSub},
19
  # Start the Finch HTTP client for sending emails
20
  {Finch, name: MedicalTranscription.Finch},
21
+ transcription_spec(),
22
+ token_classification_spec(),
23
+ text_embedding_spec(),
24
  # Start a worker by calling: MedicalTranscription.Worker.start_link(arg)
25
  # {MedicalTranscription.Worker, arg},
26
  # Start to serve requests, typically the last entry
 
41
  :ok
42
  end
43
 
44
+ defp transcription_spec() do
45
+ Transcriber.child_spec(MedicalTranscription.TranscriptionServing, @model_name)
46
+ end
47
+
48
+ defp token_classification_spec() do
49
+ KeywordFinder.token_classification_child_spec(MedicalTranscription.TokenClassificationServing)
50
+ end
51
+
52
+ defp text_embedding_spec() do
53
+ Vectors.child_spec(MedicalTranscription.TextEmbeddingServing)
54
  end
55
  end
mix.lock CHANGED
@@ -1,5 +1,5 @@
1
  %{
2
- "audio_tagger": {:git, "https://github.com/headwayio/audio_tagger.git", "a136a02a668d9db49aa505966e6e02497ce4370a", []},
3
  "aws_signature": {:hex, :aws_signature, "0.3.1", "67f369094cbd55ffa2bbd8cc713ede14b195fcfb45c86665cd7c5ad010276148", [:rebar3], [], "hexpm", "50fc4dc1d1f7c2d0a8c63f455b3c66ecd74c1cf4c915c768a636f9227704a674"},
4
  "axon": {:hex, :axon, "0.6.0", "fd7560079581e4cedebaf0cd5f741d6ac3516d06f204ebaf1283b1093bf66ff6", [:mix], [{:kino, "~> 0.7", [hex: :kino, repo: "hexpm", optional: true]}, {:kino_vega_lite, "~> 0.1.7", [hex: :kino_vega_lite, repo: "hexpm", optional: true]}, {:nx, "~> 0.6.0", [hex: :nx, repo: "hexpm", optional: false]}, {:polaris, "~> 0.1", [hex: :polaris, repo: "hexpm", optional: false]}, {:table_rex, "~> 3.1.1", [hex: :table_rex, repo: "hexpm", optional: true]}], "hexpm", "204e7aeb50d231a30b25456adf17bfbaae33fe7c085e03793357ac3bf62fd853"},
5
  "bimap": {:hex, :bimap, "1.3.0", "3ea4832e58dc83a9b5b407c6731e7bae87458aa618e6d11d8e12114a17afa4b3", [:mix], [], "hexpm", "bf5a2b078528465aa705f405a5c638becd63e41d280ada41e0f77e6d255a10b4"},
 
1
  %{
2
+ "audio_tagger": {:git, "https://github.com/headwayio/audio_tagger.git", "1d10f299cd2aa6e40608a16b6cfc80b80ef81b8f", []},
3
  "aws_signature": {:hex, :aws_signature, "0.3.1", "67f369094cbd55ffa2bbd8cc713ede14b195fcfb45c86665cd7c5ad010276148", [:rebar3], [], "hexpm", "50fc4dc1d1f7c2d0a8c63f455b3c66ecd74c1cf4c915c768a636f9227704a674"},
4
  "axon": {:hex, :axon, "0.6.0", "fd7560079581e4cedebaf0cd5f741d6ac3516d06f204ebaf1283b1093bf66ff6", [:mix], [{:kino, "~> 0.7", [hex: :kino, repo: "hexpm", optional: true]}, {:kino_vega_lite, "~> 0.1.7", [hex: :kino_vega_lite, repo: "hexpm", optional: true]}, {:nx, "~> 0.6.0", [hex: :nx, repo: "hexpm", optional: false]}, {:polaris, "~> 0.1", [hex: :polaris, repo: "hexpm", optional: false]}, {:table_rex, "~> 3.1.1", [hex: :table_rex, repo: "hexpm", optional: true]}], "hexpm", "204e7aeb50d231a30b25456adf17bfbaae33fe7c085e03793357ac3bf62fd853"},
5
  "bimap": {:hex, :bimap, "1.3.0", "3ea4832e58dc83a9b5b407c6731e7bae87458aa618e6d11d8e12114a17afa4b3", [:mix], [], "hexpm", "bf5a2b078528465aa705f405a5c638becd63e41d280ada41e0f77e6d255a10b4"},