ai-interview-assistant 2.3.2__tar.gz → 2.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/PKG-INFO +2 -2
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/pyproject.toml +2 -2
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/__init__.py +1 -1
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/audio/capture.py +19 -76
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/audio/transcriber.py +18 -33
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/config.py +16 -2
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/daemon.py +5 -33
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/screens/dashboard.py +3 -2
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/screens/settings.py +2 -2
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/llm_clients.py +43 -11
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview_assistant.egg-info/PKG-INFO +2 -2
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview_assistant.egg-info/SOURCES.txt +1 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview_assistant.egg-info/requires.txt +1 -1
- ai_interview_assistant-2.3.4/tests/test_config_transcriber.py +52 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/tests/test_llm_clients.py +63 -2
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/tests/test_transcription_phase.py +2 -41
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/README.md +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/setup.cfg +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/__main__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/ai_client.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/audio/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/buffer.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/cli.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/__main__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/app.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/screens/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/screens/hotkeys.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/screens/scripts.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/hotkey_config.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/hotkeys.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/i18n.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/menubar.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/metrics.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/ollama_utils.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/overlay.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/screenshot.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/app.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/routes.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/websocket.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/state.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/utils.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/watchdog.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview_assistant.egg-info/dependency_links.txt +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview_assistant.egg-info/entry_points.txt +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview_assistant.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ai-interview-assistant
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.4
|
|
4
4
|
Summary: Ghost background AI assistant for live code challenges
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: click>=8.0
|
|
@@ -28,7 +28,7 @@ Requires-Dist: datadog>=0.49.0
|
|
|
28
28
|
Requires-Dist: psutil>=5.9
|
|
29
29
|
Requires-Dist: httpx>=0.27.0
|
|
30
30
|
Requires-Dist: h2>=4.0
|
|
31
|
-
Requires-Dist: flet<0.84,>=0.25.0
|
|
31
|
+
Requires-Dist: flet[desktop]<0.84,>=0.25.0
|
|
32
32
|
Requires-Dist: PyPDF2>=3.0
|
|
33
33
|
Provides-Extra: dev
|
|
34
34
|
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ai-interview-assistant"
|
|
7
|
-
version = "2.3.
|
|
7
|
+
version = "2.3.4"
|
|
8
8
|
description = "Ghost background AI assistant for live code challenges"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
dependencies = [
|
|
@@ -33,7 +33,7 @@ dependencies = [
|
|
|
33
33
|
"psutil>=5.9",
|
|
34
34
|
"httpx>=0.27.0",
|
|
35
35
|
"h2>=4.0",
|
|
36
|
-
"flet>=0.25.0,<0.84",
|
|
36
|
+
"flet[desktop]>=0.25.0,<0.84",
|
|
37
37
|
"PyPDF2>=3.0",
|
|
38
38
|
]
|
|
39
39
|
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/audio/capture.py
RENAMED
|
@@ -285,33 +285,6 @@ class ScreenCaptureAudio:
|
|
|
285
285
|
# Combined capture: mic + system audio
|
|
286
286
|
# ---------------------------------------------------------------------------
|
|
287
287
|
|
|
288
|
-
class _QueueAudioSource:
|
|
289
|
-
"""Minimal capture-like adapter over a single Queue.
|
|
290
|
-
|
|
291
|
-
Exposes the same ``get_audio`` / ``flush`` surface a DeepgramTranscriber pulls
|
|
292
|
-
from, so a second transcriber can consume the candidate (mic) stream from its
|
|
293
|
-
own queue without knowing about CombinedAudioCapture internals.
|
|
294
|
-
"""
|
|
295
|
-
|
|
296
|
-
def __init__(self, queue: "Queue") -> None:
|
|
297
|
-
self._queue = queue
|
|
298
|
-
|
|
299
|
-
def get_audio(self, timeout: float = 0.1) -> Optional[np.ndarray]:
|
|
300
|
-
try:
|
|
301
|
-
return self._queue.get(timeout=timeout)
|
|
302
|
-
except Empty:
|
|
303
|
-
return None
|
|
304
|
-
|
|
305
|
-
def flush(self) -> int:
|
|
306
|
-
dropped = 0
|
|
307
|
-
while True:
|
|
308
|
-
try:
|
|
309
|
-
self._queue.get_nowait()
|
|
310
|
-
dropped += 1
|
|
311
|
-
except Empty:
|
|
312
|
-
return dropped
|
|
313
|
-
|
|
314
|
-
|
|
315
288
|
class CombinedAudioCapture:
|
|
316
289
|
"""Mixes microphone + system audio and feeds a Queue for the transcriber."""
|
|
317
290
|
|
|
@@ -324,11 +297,6 @@ class CombinedAudioCapture:
|
|
|
324
297
|
def __init__(self, sample_rate: int = SAMPLE_RATE) -> None:
|
|
325
298
|
self.sample_rate = sample_rate
|
|
326
299
|
self.audio_queue: Queue[np.ndarray] = Queue()
|
|
327
|
-
# Separate queue carrying the microphone (candidate) stream when system
|
|
328
|
-
# audio is the primary source. Only fed while a mic transcriber is active
|
|
329
|
-
# (see _mic_routing) so it never grows unbounded when unused.
|
|
330
|
-
self.mic_queue: Queue[np.ndarray] = Queue()
|
|
331
|
-
self._mic_routing = False
|
|
332
300
|
self._stop_event = Event()
|
|
333
301
|
self._mic: Optional[MicrophoneCapture] = None
|
|
334
302
|
self._sys: Optional[ScreenCaptureAudio] = None
|
|
@@ -383,12 +351,14 @@ class CombinedAudioCapture:
|
|
|
383
351
|
# transcriber is routing the candidate stream; otherwise drain-and-
|
|
384
352
|
# discard.
|
|
385
353
|
if self._mic:
|
|
386
|
-
keep_mic = (not self._has_system_audio) or self._mic_routing
|
|
387
354
|
while True:
|
|
388
355
|
mic_chunk = self._mic.get_audio(timeout=0)
|
|
389
356
|
if mic_chunk is None:
|
|
390
357
|
break
|
|
391
|
-
|
|
358
|
+
# Mic feeds the transcriber only as a fallback when there is no
|
|
359
|
+
# system audio; otherwise drain-and-discard so its queue can't
|
|
360
|
+
# back up. (Only the interviewer's voice is transcribed.)
|
|
361
|
+
if not self._has_system_audio:
|
|
392
362
|
mic_buf.extend(mic_chunk.flatten())
|
|
393
363
|
|
|
394
364
|
# Drain the system-audio queue fully (non-blocking).
|
|
@@ -402,12 +372,9 @@ class CombinedAudioCapture:
|
|
|
402
372
|
# Emit EVERY complete chunk this iteration (system audio decoupled from
|
|
403
373
|
# mic — it never waits on the mic having a chunk ready).
|
|
404
374
|
if self._has_system_audio:
|
|
405
|
-
produced = self._emit_all_chunks(sys_buf, chunk_size
|
|
406
|
-
# Candidate's own voice → separate queue for the mic transcriber.
|
|
407
|
-
if self._mic_routing:
|
|
408
|
-
produced += self._emit_all_chunks(mic_buf, chunk_size, self.mic_queue)
|
|
375
|
+
produced = self._emit_all_chunks(sys_buf, chunk_size)
|
|
409
376
|
else:
|
|
410
|
-
produced = self._emit_all_chunks(mic_buf, chunk_size
|
|
377
|
+
produced = self._emit_all_chunks(mic_buf, chunk_size)
|
|
411
378
|
|
|
412
379
|
# Stall-recovery: if the downstream consumer (Deepgram feed loop) has
|
|
413
380
|
# fallen behind real-time, trim oldest queued chunks so transcripts stay
|
|
@@ -417,11 +384,6 @@ class CombinedAudioCapture:
|
|
|
417
384
|
if trimmed:
|
|
418
385
|
_trim_events += 1
|
|
419
386
|
_trim_chunks += trimmed
|
|
420
|
-
# Bound the secondary (mic) queue too — if its transcriber dies (no
|
|
421
|
-
# Whisper fallback) routing stays on, so without this it would grow
|
|
422
|
-
# without limit. Same drop-oldest-to-stay-live policy as the primary.
|
|
423
|
-
if self._mic_routing:
|
|
424
|
-
self._trim_queue(self.mic_queue)
|
|
425
387
|
now = time.time()
|
|
426
388
|
if _trim_events and now - _last_drain_warn > 30:
|
|
427
389
|
import logging
|
|
@@ -442,9 +404,9 @@ class CombinedAudioCapture:
|
|
|
442
404
|
if not produced:
|
|
443
405
|
time.sleep(0.005)
|
|
444
406
|
|
|
445
|
-
def _emit_all_chunks(self, buf: "deque", chunk_size: int
|
|
407
|
+
def _emit_all_chunks(self, buf: "deque", chunk_size: int) -> int:
|
|
446
408
|
"""Pop every complete ``chunk_size`` window from ``buf`` and forward it to
|
|
447
|
-
|
|
409
|
+
the transcriber queue. Returns the number of chunks emitted.
|
|
448
410
|
|
|
449
411
|
Draining all complete chunks (not just one per call) is what keeps the
|
|
450
412
|
local buffer from accumulating a hidden backlog when the producer briefly
|
|
@@ -453,48 +415,29 @@ class CombinedAudioCapture:
|
|
|
453
415
|
produced = 0
|
|
454
416
|
while len(buf) >= chunk_size:
|
|
455
417
|
data = np.array([buf.popleft() for _ in range(chunk_size)], dtype=np.float32)
|
|
456
|
-
|
|
418
|
+
self.audio_queue.put(data)
|
|
457
419
|
produced += 1
|
|
458
420
|
return produced
|
|
459
421
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
self._mic_routing = True
|
|
468
|
-
|
|
469
|
-
def mic_source(self) -> "_QueueAudioSource":
|
|
470
|
-
"""A capture-like view over ``mic_queue`` (get_audio + flush) to hand to a
|
|
471
|
-
second DeepgramTranscriber for the candidate's own voice."""
|
|
472
|
-
return _QueueAudioSource(self.mic_queue)
|
|
473
|
-
|
|
474
|
-
def _trim_queue(self, queue: "Queue") -> int:
|
|
475
|
-
"""Drop oldest chunks from ``queue`` when it exceeds ~2s of backlog, down to
|
|
476
|
-
a ~0.5s tail. No-op at or below the threshold. Returns the count dropped.
|
|
477
|
-
|
|
478
|
-
A growing queue means its consumer (a transcriber feed loop) is behind
|
|
479
|
-
real-time — or, for the mic queue, has died (the secondary transcriber has
|
|
480
|
-
no Whisper fallback, so a dead Deepgram socket leaves no consumer). Either
|
|
481
|
-
way, bounding it keeps transcripts live and prevents unbounded growth.
|
|
422
|
+
def _trim_stale_backlog(self) -> int:
|
|
423
|
+
"""Drop oldest queued chunks when the backlog exceeds ~2s, down to a ~0.5s
|
|
424
|
+
tail. No-op at or below the trim threshold. Returns the count dropped.
|
|
425
|
+
|
|
426
|
+
Each item is one 10ms chunk; a growing queue means the Deepgram feed loop
|
|
427
|
+
is behind real-time, which would otherwise show as transcripts arriving
|
|
428
|
+
progressively later than live speech.
|
|
482
429
|
"""
|
|
483
|
-
if
|
|
430
|
+
if self.audio_queue.qsize() <= self._STALL_TRIM_CHUNKS:
|
|
484
431
|
return 0
|
|
485
432
|
trimmed = 0
|
|
486
|
-
while
|
|
433
|
+
while self.audio_queue.qsize() > self._STALL_TAIL_CHUNKS:
|
|
487
434
|
try:
|
|
488
|
-
|
|
435
|
+
self.audio_queue.get_nowait()
|
|
489
436
|
trimmed += 1
|
|
490
437
|
except Empty:
|
|
491
438
|
break
|
|
492
439
|
return trimmed
|
|
493
440
|
|
|
494
|
-
def _trim_stale_backlog(self) -> int:
|
|
495
|
-
"""Bound the primary transcriber queue (each item is one 10ms chunk)."""
|
|
496
|
-
return self._trim_queue(self.audio_queue)
|
|
497
|
-
|
|
498
441
|
def flush(self) -> int:
|
|
499
442
|
"""Drop every queued audio chunk; return how many were dropped.
|
|
500
443
|
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/audio/transcriber.py
RENAMED
|
@@ -37,20 +37,11 @@ class DeepgramTranscriber:
|
|
|
37
37
|
transcript_buffer: "RollingTranscriptBuffer",
|
|
38
38
|
api_key: str,
|
|
39
39
|
language: str = "en",
|
|
40
|
-
label: str = "",
|
|
41
|
-
whisper_fallback: bool = True,
|
|
42
40
|
) -> None:
|
|
43
41
|
self._capture = audio_capture
|
|
44
42
|
self._buffer = transcript_buffer
|
|
45
43
|
self._language = language
|
|
46
44
|
self._api_key = api_key
|
|
47
|
-
# Secondary streams (e.g. the candidate's mic) set a label so their text
|
|
48
|
-
# is prefixed in the AI context (so the model can tell who spoke) and so
|
|
49
|
-
# they don't fight the primary stream on the live transcript bar.
|
|
50
|
-
self._label = label
|
|
51
|
-
# Secondary streams skip the Whisper fallback — one local Whisper model is
|
|
52
|
-
# enough; a second would double CPU/memory for little gain.
|
|
53
|
-
self._whisper_fallback = whisper_fallback
|
|
54
45
|
self._stop_event = threading.Event()
|
|
55
46
|
self._thread: Optional[threading.Thread] = None
|
|
56
47
|
self._connection = None
|
|
@@ -59,11 +50,6 @@ class DeepgramTranscriber:
|
|
|
59
50
|
self._last_transcript_time: float = 0.0
|
|
60
51
|
self._last_interim = None
|
|
61
52
|
|
|
62
|
-
def _buffer_text(self, sentence: str) -> str:
|
|
63
|
-
"""Prefix a labeled (secondary) stream's text so the AI context shows who
|
|
64
|
-
spoke, e.g. ``[me] ...`` for the candidate's own voice."""
|
|
65
|
-
return f"[{self._label}] {sentence}" if self._label else sentence
|
|
66
|
-
|
|
67
53
|
def _on_message(self, sender, result=None, **kwargs):
|
|
68
54
|
try:
|
|
69
55
|
if result is None:
|
|
@@ -78,10 +64,9 @@ class DeepgramTranscriber:
|
|
|
78
64
|
|
|
79
65
|
if result.is_final:
|
|
80
66
|
# Final: add to AI buffer and broadcast; clear pending interim
|
|
81
|
-
logger.info("Deepgram final
|
|
82
|
-
f" [{self._label}]" if self._label else "", sentence[:120])
|
|
67
|
+
logger.info("Deepgram final: %s", sentence[:120])
|
|
83
68
|
self._last_interim = None
|
|
84
|
-
self._buffer.append(
|
|
69
|
+
self._buffer.append(sentence)
|
|
85
70
|
state.last_activity_at = time.time()
|
|
86
71
|
try:
|
|
87
72
|
from ai_interview.metrics import metrics
|
|
@@ -91,14 +76,12 @@ class DeepgramTranscriber:
|
|
|
91
76
|
if loop is not None:
|
|
92
77
|
import asyncio
|
|
93
78
|
asyncio.run_coroutine_threadsafe(
|
|
94
|
-
self._broadcast_transcript(sentence, interim=False
|
|
79
|
+
self._broadcast_transcript(sentence, interim=False), loop
|
|
95
80
|
)
|
|
96
81
|
else:
|
|
97
|
-
# Interim: track for utterance_end flush
|
|
98
|
-
# broadcasts interims — two streams replacing the same transcript
|
|
99
|
-
# bar in-place would flicker against each other.
|
|
82
|
+
# Interim: track for utterance_end flush; broadcast to transcript bar
|
|
100
83
|
self._last_interim = sentence
|
|
101
|
-
if loop is not None
|
|
84
|
+
if loop is not None:
|
|
102
85
|
import asyncio
|
|
103
86
|
asyncio.run_coroutine_threadsafe(
|
|
104
87
|
self._broadcast_transcript(sentence, interim=True), loop
|
|
@@ -107,10 +90,10 @@ class DeepgramTranscriber:
|
|
|
107
90
|
logger.warning("Deepgram message parse error: %s", exc)
|
|
108
91
|
|
|
109
92
|
@staticmethod
|
|
110
|
-
async def _broadcast_transcript(sentence: str, interim: bool = False
|
|
93
|
+
async def _broadcast_transcript(sentence: str, interim: bool = False) -> None:
|
|
111
94
|
try:
|
|
112
95
|
from ai_interview.server.websocket import broadcast
|
|
113
|
-
await broadcast({"type": "transcript", "text": sentence, "interim": interim
|
|
96
|
+
await broadcast({"type": "transcript", "text": sentence, "interim": interim})
|
|
114
97
|
except Exception:
|
|
115
98
|
pass
|
|
116
99
|
|
|
@@ -120,13 +103,13 @@ class DeepgramTranscriber:
|
|
|
120
103
|
last = getattr(self, '_last_interim', None)
|
|
121
104
|
if last:
|
|
122
105
|
logger.info("Deepgram utterance_end flush: %s", last[:80])
|
|
123
|
-
self._buffer.append(
|
|
106
|
+
self._buffer.append(last)
|
|
124
107
|
from ai_interview.state import state
|
|
125
108
|
loop = state.asyncio_loop
|
|
126
109
|
if loop is not None:
|
|
127
110
|
import asyncio
|
|
128
111
|
asyncio.run_coroutine_threadsafe(
|
|
129
|
-
self._broadcast_transcript(last, interim=False
|
|
112
|
+
self._broadcast_transcript(last, interim=False), loop
|
|
130
113
|
)
|
|
131
114
|
self._last_interim = None
|
|
132
115
|
except Exception as exc:
|
|
@@ -214,11 +197,8 @@ class DeepgramTranscriber:
|
|
|
214
197
|
except Exception:
|
|
215
198
|
pass
|
|
216
199
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
self._start_whisper_fallback()
|
|
220
|
-
else:
|
|
221
|
-
logger.error("Deepgram reconnect failed after 10 attempts (label=%s) — giving up, no Whisper fallback for secondary stream", self._label)
|
|
200
|
+
logger.error("Deepgram reconnect failed after 10 attempts — falling back to local Whisper")
|
|
201
|
+
self._start_whisper_fallback()
|
|
222
202
|
finally:
|
|
223
203
|
self._reconnect_lock.release()
|
|
224
204
|
|
|
@@ -237,7 +217,12 @@ class DeepgramTranscriber:
|
|
|
237
217
|
"""Read audio chunks and send to Deepgram connection."""
|
|
238
218
|
last_keepalive = time.time()
|
|
239
219
|
self._last_transcript_time = time.time()
|
|
240
|
-
|
|
220
|
+
# Reconnect if the interviewer is talking (audio being sent) but Deepgram
|
|
221
|
+
# returns no transcript for this long — i.e. a silent server-side stall.
|
|
222
|
+
# Kept low (vs the old 30s) so a stall doesn't leave the interviewer's
|
|
223
|
+
# question seconds behind; finals/interims normally arrive every 1-3s, so
|
|
224
|
+
# 12s with no message while sending audio is unambiguously a dead stream.
|
|
225
|
+
_WATCHDOG_TIMEOUT = 12
|
|
241
226
|
last_watchdog_check = time.time()
|
|
242
227
|
|
|
243
228
|
while not self._stop_event.is_set():
|
|
@@ -265,7 +250,7 @@ class DeepgramTranscriber:
|
|
|
265
250
|
|
|
266
251
|
# Watchdog: if we're sending audio but getting no transcripts, connection is dead
|
|
267
252
|
now = time.time()
|
|
268
|
-
if now - last_watchdog_check >
|
|
253
|
+
if now - last_watchdog_check > 3:
|
|
269
254
|
last_watchdog_check = now
|
|
270
255
|
silence_duration = now - self._last_transcript_time
|
|
271
256
|
if silence_duration > _WATCHDOG_TIMEOUT:
|
|
@@ -286,6 +286,20 @@ def save_config(data: dict) -> None:
|
|
|
286
286
|
CONFIG_FILE.write_text(json.dumps(data, indent=2))
|
|
287
287
|
|
|
288
288
|
|
|
289
|
+
def resolve_transcriber(saved: dict) -> str:
|
|
290
|
+
"""Effective transcriber for a saved config dict.
|
|
291
|
+
|
|
292
|
+
An explicit ``preferred_transcriber`` always wins. When none is set (fresh
|
|
293
|
+
installs: the setup wizard never writes one), prefer Deepgram if a key is
|
|
294
|
+
configured, otherwise Whisper. Defaulting to Whisper unconditionally made
|
|
295
|
+
new installs ignore the Deepgram key the user just entered.
|
|
296
|
+
"""
|
|
297
|
+
pref = (saved.get("preferred_transcriber") or "").strip().lower()
|
|
298
|
+
if pref in ("deepgram", "whisper"):
|
|
299
|
+
return pref
|
|
300
|
+
return "deepgram" if (saved.get("deepgram_api_key") or "").strip() else "whisper"
|
|
301
|
+
|
|
302
|
+
|
|
289
303
|
# ---------------------------------------------------------------------------
|
|
290
304
|
# Runtime config dataclass
|
|
291
305
|
# ---------------------------------------------------------------------------
|
|
@@ -318,7 +332,7 @@ class Config:
|
|
|
318
332
|
cv_path: str = "" # optional CV/resume PDF path
|
|
319
333
|
max_history_turns: int = 10
|
|
320
334
|
preferred_provider: str = "local" # "claude", "gemini", "local" (ollama)
|
|
321
|
-
preferred_transcriber: str = "whisper" # "deepgram", "whisper"
|
|
335
|
+
preferred_transcriber: str = "whisper" # "deepgram", "whisper"; from_saved() resolves via resolve_transcriber()
|
|
322
336
|
local_model: str = "qwen2.5-coder:3b" # Ollama model for local provider
|
|
323
337
|
ollama_host: str = "http://localhost:11434" # Ollama server URL (local or remote)
|
|
324
338
|
ollama_managed: bool = False # True if we installed/manage ollama lifecycle
|
|
@@ -411,7 +425,7 @@ class Config:
|
|
|
411
425
|
context_path=context_path,
|
|
412
426
|
cv_path=merged.get("_session_cv_path", merged.get("cv_path", "")),
|
|
413
427
|
preferred_provider=merged.get("preferred_provider", "local"),
|
|
414
|
-
preferred_transcriber=merged
|
|
428
|
+
preferred_transcriber=resolve_transcriber(merged),
|
|
415
429
|
local_model=merged.get("local_model", "qwen2.5-coder:3b"),
|
|
416
430
|
ollama_host=merged.get("ollama_host", "http://localhost:11434"),
|
|
417
431
|
ollama_managed=merged.get("ollama_managed", False),
|
|
@@ -229,6 +229,11 @@ def run_daemon(config: Config) -> None:
|
|
|
229
229
|
logger.error("Audio capture failed: %s — continuing without audio", exc)
|
|
230
230
|
|
|
231
231
|
# Start transcriber (Deepgram preferred, Whisper fallback)
|
|
232
|
+
logger.info(
|
|
233
|
+
"Transcriber preference: %s (deepgram key: %s)",
|
|
234
|
+
config.preferred_transcriber,
|
|
235
|
+
"set" if config.deepgram_api_key else "missing",
|
|
236
|
+
)
|
|
232
237
|
transcriber = create_transcriber(
|
|
233
238
|
audio_capture=audio_capture,
|
|
234
239
|
transcript_buffer=state.transcript_buffer,
|
|
@@ -249,37 +254,6 @@ def run_daemon(config: Config) -> None:
|
|
|
249
254
|
state.transcriber_name = transcriber_name
|
|
250
255
|
state.ai_model = config.model
|
|
251
256
|
|
|
252
|
-
# Secondary transcriber: the candidate's own microphone on a SEPARATE Deepgram
|
|
253
|
-
# connection (per-role, like meeting-helper). The primary stream above carries
|
|
254
|
-
# system audio (interviewer); this adds the user's voice to the AI context,
|
|
255
|
-
# prefixed "[me]" so the model can tell the two apart. Only when system audio
|
|
256
|
-
# is the primary source (otherwise the mic already IS the primary), a Deepgram
|
|
257
|
-
# key is present, and not disabled via config.
|
|
258
|
-
mic_transcriber = None
|
|
259
|
-
if (
|
|
260
|
-
getattr(config, "transcribe_mic", True)
|
|
261
|
-
and isinstance(transcriber, DeepgramTranscriber)
|
|
262
|
-
and audio_capture.has_system_audio
|
|
263
|
-
and config.deepgram_api_key
|
|
264
|
-
):
|
|
265
|
-
try:
|
|
266
|
-
mic_t = DeepgramTranscriber(
|
|
267
|
-
audio_capture.mic_source(),
|
|
268
|
-
state.transcript_buffer,
|
|
269
|
-
config.deepgram_api_key,
|
|
270
|
-
language=config.transcription_language,
|
|
271
|
-
label="me",
|
|
272
|
-
whisper_fallback=False,
|
|
273
|
-
)
|
|
274
|
-
if mic_t.start():
|
|
275
|
-
audio_capture.enable_mic_routing()
|
|
276
|
-
mic_transcriber = mic_t
|
|
277
|
-
logger.info("Mic (candidate) transcriber started on a separate Deepgram connection")
|
|
278
|
-
else:
|
|
279
|
-
logger.warning("Mic transcriber failed to start — continuing with interviewer audio only")
|
|
280
|
-
except Exception as exc:
|
|
281
|
-
logger.warning("Mic transcriber setup failed: %s — continuing without it", exc)
|
|
282
|
-
|
|
283
257
|
# -----------------------------------------------------------------------
|
|
284
258
|
# Start Datadog metrics + structured logging (no-op if dd_api_key absent)
|
|
285
259
|
# -----------------------------------------------------------------------
|
|
@@ -394,8 +368,6 @@ def run_daemon(config: Config) -> None:
|
|
|
394
368
|
finally:
|
|
395
369
|
if transcriber is not None:
|
|
396
370
|
transcriber.stop()
|
|
397
|
-
if mic_transcriber is not None:
|
|
398
|
-
mic_transcriber.stop()
|
|
399
371
|
audio_capture.stop()
|
|
400
372
|
# Clean up all screenshots captured during this session
|
|
401
373
|
try:
|
|
@@ -18,6 +18,7 @@ from ai_interview.config import (
|
|
|
18
18
|
GEMINI_MODELS,
|
|
19
19
|
DEFAULT_SCRIPTS,
|
|
20
20
|
load_saved_config,
|
|
21
|
+
resolve_transcriber,
|
|
21
22
|
save_config,
|
|
22
23
|
_build_system_prompt,
|
|
23
24
|
)
|
|
@@ -129,7 +130,7 @@ class DashboardScreen(ft.Column):
|
|
|
129
130
|
|
|
130
131
|
self._transcriber_dropdown = ft.Dropdown(
|
|
131
132
|
label=t("transcriber"),
|
|
132
|
-
value=saved_config
|
|
133
|
+
value=resolve_transcriber(saved_config),
|
|
133
134
|
options=transcriber_options,
|
|
134
135
|
border_radius=8, text_size=SZ, expand=True,
|
|
135
136
|
on_select=self._on_transcriber_change,
|
|
@@ -344,7 +345,7 @@ class DashboardScreen(ft.Column):
|
|
|
344
345
|
if fresh.get("deepgram_api_key"):
|
|
345
346
|
transcriber_options.append(ft.dropdown.Option("deepgram", "Deepgram"))
|
|
346
347
|
self._transcriber_dropdown.options = transcriber_options
|
|
347
|
-
self._transcriber_dropdown.value = fresh
|
|
348
|
+
self._transcriber_dropdown.value = resolve_transcriber(fresh)
|
|
348
349
|
self._update_trans_lang_options()
|
|
349
350
|
|
|
350
351
|
# Refresh CV checkbox
|
|
@@ -9,7 +9,7 @@ from pathlib import Path
|
|
|
9
9
|
import flet as ft
|
|
10
10
|
from ai_interview.i18n import t
|
|
11
11
|
|
|
12
|
-
from ai_interview.config import save_config
|
|
12
|
+
from ai_interview.config import resolve_transcriber, save_config
|
|
13
13
|
|
|
14
14
|
TEAL = "#4ec9b0"
|
|
15
15
|
MUTED = "#8b949e"
|
|
@@ -211,7 +211,7 @@ class SettingsScreen(ft.Column):
|
|
|
211
211
|
self._all_trans_langs = ["en", "es", "pt", "fr", "de", "it", "ja", "ko", "zh", "auto"]
|
|
212
212
|
self._transcriber_dropdown = ft.Dropdown(
|
|
213
213
|
label=t("default_transcriber"),
|
|
214
|
-
value=saved_config
|
|
214
|
+
value=resolve_transcriber(saved_config),
|
|
215
215
|
options=[
|
|
216
216
|
ft.dropdown.Option("whisper", t("whisper_free")),
|
|
217
217
|
ft.dropdown.Option("deepgram", "Deepgram"),
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/llm_clients.py
RENAMED
|
@@ -38,33 +38,65 @@ _h2_unavailable_logged = False
|
|
|
38
38
|
_h2_enabled_logged = False
|
|
39
39
|
|
|
40
40
|
|
|
41
|
+
def _sdk_http_stack():
|
|
42
|
+
"""Return ``(http_module, client_cls)`` matching the installed anthropic SDK.
|
|
43
|
+
|
|
44
|
+
anthropic 0.x is built on ``httpx``; anthropic 2.x moved to ``httpx2`` and
|
|
45
|
+
rejects an ``httpx.AsyncClient`` passed as ``http_client``. The SDK's public
|
|
46
|
+
``DefaultAsyncHttpxClient`` always subclasses the right ``AsyncClient`` (and
|
|
47
|
+
carries the SDK's own timeout/keepalive defaults), so we use it and take
|
|
48
|
+
``Limits`` from the module its base class lives in.
|
|
49
|
+
"""
|
|
50
|
+
import importlib
|
|
51
|
+
|
|
52
|
+
import anthropic
|
|
53
|
+
|
|
54
|
+
client_cls = getattr(anthropic, "DefaultAsyncHttpxClient", None)
|
|
55
|
+
if client_cls is not None:
|
|
56
|
+
for base in client_cls.__mro__:
|
|
57
|
+
root = base.__module__.split(".")[0]
|
|
58
|
+
if base.__name__ == "AsyncClient" and root in ("httpx", "httpx2"):
|
|
59
|
+
return importlib.import_module(root), client_cls
|
|
60
|
+
|
|
61
|
+
import httpx
|
|
62
|
+
|
|
63
|
+
return httpx, httpx.AsyncClient
|
|
64
|
+
|
|
65
|
+
|
|
41
66
|
def _httpx_client():
|
|
42
|
-
"""A connection-pooled async
|
|
67
|
+
"""A connection-pooled async HTTP client tuned to stay warm across the gaps
|
|
43
68
|
between queries. HTTP/2 multiplexes and keeps the connection open;
|
|
44
69
|
``keepalive_expiry`` outlives a typical idle gap.
|
|
45
70
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
71
|
+
The client class comes from ``_sdk_http_stack`` so it always matches the
|
|
72
|
+
installed anthropic SDK (httpx for 0.x, httpx2 for 2.x).
|
|
73
|
+
|
|
74
|
+
HTTP/2 needs the optional ``h2`` package. If it is not installed, the client
|
|
75
|
+
raises ``ImportError`` when ``http2=True``; we degrade to HTTP/1.1 (still
|
|
76
|
+
pooled + keep-alive) instead of breaking queries.
|
|
49
77
|
"""
|
|
50
78
|
global _h2_unavailable_logged, _h2_enabled_logged
|
|
51
|
-
|
|
79
|
+
http_mod, client_cls = _sdk_http_stack()
|
|
52
80
|
|
|
53
|
-
limits =
|
|
81
|
+
limits = http_mod.Limits(max_keepalive_connections=10, keepalive_expiry=300.0)
|
|
54
82
|
try:
|
|
55
|
-
client =
|
|
83
|
+
client = client_cls(http2=True, limits=limits)
|
|
56
84
|
if not _h2_enabled_logged:
|
|
57
85
|
_h2_enabled_logged = True
|
|
58
|
-
logger.info(
|
|
86
|
+
logger.info(
|
|
87
|
+
"LLM transport: HTTP/2 enabled with connection reuse (%s)",
|
|
88
|
+
http_mod.__name__,
|
|
89
|
+
)
|
|
59
90
|
return client
|
|
60
91
|
except ImportError:
|
|
61
92
|
if not _h2_unavailable_logged:
|
|
62
93
|
_h2_unavailable_logged = True
|
|
63
94
|
logger.info(
|
|
64
|
-
"HTTP/2 unavailable (install 'h2'
|
|
65
|
-
"using HTTP/1.1 with connection reuse"
|
|
95
|
+
"HTTP/2 unavailable (install 'h2'), "
|
|
96
|
+
"using HTTP/1.1 with connection reuse (%s)",
|
|
97
|
+
http_mod.__name__,
|
|
66
98
|
)
|
|
67
|
-
return
|
|
99
|
+
return client_cls(http2=False, limits=limits)
|
|
68
100
|
|
|
69
101
|
|
|
70
102
|
def _build_anthropic(api_key: str):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ai-interview-assistant
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.4
|
|
4
4
|
Summary: Ghost background AI assistant for live code challenges
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: click>=8.0
|
|
@@ -28,7 +28,7 @@ Requires-Dist: datadog>=0.49.0
|
|
|
28
28
|
Requires-Dist: psutil>=5.9
|
|
29
29
|
Requires-Dist: httpx>=0.27.0
|
|
30
30
|
Requires-Dist: h2>=4.0
|
|
31
|
-
Requires-Dist: flet<0.84,>=0.25.0
|
|
31
|
+
Requires-Dist: flet[desktop]<0.84,>=0.25.0
|
|
32
32
|
Requires-Dist: PyPDF2>=3.0
|
|
33
33
|
Provides-Extra: dev
|
|
34
34
|
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
@@ -40,5 +40,6 @@ src/ai_interview_assistant.egg-info/dependency_links.txt
|
|
|
40
40
|
src/ai_interview_assistant.egg-info/entry_points.txt
|
|
41
41
|
src/ai_interview_assistant.egg-info/requires.txt
|
|
42
42
|
src/ai_interview_assistant.egg-info/top_level.txt
|
|
43
|
+
tests/test_config_transcriber.py
|
|
43
44
|
tests/test_llm_clients.py
|
|
44
45
|
tests/test_transcription_phase.py
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""resolve_transcriber: fresh installs must use Deepgram when a key is set."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from ai_interview import config as cfg
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.mark.parametrize(
|
|
9
|
+
"saved, expected",
|
|
10
|
+
[
|
|
11
|
+
({}, "whisper"),
|
|
12
|
+
({"deepgram_api_key": ""}, "whisper"),
|
|
13
|
+
({"deepgram_api_key": " "}, "whisper"),
|
|
14
|
+
({"deepgram_api_key": "dg-key"}, "deepgram"),
|
|
15
|
+
({"deepgram_api_key": "dg-key", "preferred_transcriber": ""}, "deepgram"),
|
|
16
|
+
({"deepgram_api_key": "dg-key", "preferred_transcriber": None}, "deepgram"),
|
|
17
|
+
({"deepgram_api_key": "dg-key", "preferred_transcriber": "whisper"}, "whisper"),
|
|
18
|
+
({"deepgram_api_key": "dg-key", "preferred_transcriber": "Deepgram"}, "deepgram"),
|
|
19
|
+
({"preferred_transcriber": "deepgram"}, "deepgram"),
|
|
20
|
+
({"deepgram_api_key": "dg-key", "preferred_transcriber": "bogus"}, "deepgram"),
|
|
21
|
+
],
|
|
22
|
+
)
|
|
23
|
+
def test_resolve_transcriber(saved, expected):
|
|
24
|
+
assert cfg.resolve_transcriber(saved) == expected
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_from_saved_fresh_install_with_deepgram_key_uses_deepgram(monkeypatch):
|
|
28
|
+
# Mirrors what the setup wizard writes: no preferred_transcriber field.
|
|
29
|
+
fresh = {
|
|
30
|
+
"anthropic_api_key": "sk-ant-api03-x",
|
|
31
|
+
"deepgram_api_key": "dg-key",
|
|
32
|
+
"preferred_provider": "claude",
|
|
33
|
+
"interview_language": "Kotlin",
|
|
34
|
+
}
|
|
35
|
+
monkeypatch.setattr(cfg, "load_saved_config", lambda: dict(fresh))
|
|
36
|
+
|
|
37
|
+
assert cfg.Config.from_saved().preferred_transcriber == "deepgram"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_from_saved_respects_explicit_whisper(monkeypatch):
|
|
41
|
+
saved = {"deepgram_api_key": "dg-key", "preferred_transcriber": "whisper"}
|
|
42
|
+
monkeypatch.setattr(cfg, "load_saved_config", lambda: dict(saved))
|
|
43
|
+
|
|
44
|
+
assert cfg.Config.from_saved().preferred_transcriber == "whisper"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_from_saved_cli_deepgram_override_switches_to_deepgram(monkeypatch):
|
|
48
|
+
monkeypatch.setattr(cfg, "load_saved_config", lambda: {})
|
|
49
|
+
|
|
50
|
+
c = cfg.Config.from_saved({"deepgram_api_key": "dg-key"})
|
|
51
|
+
|
|
52
|
+
assert c.preferred_transcriber == "deepgram"
|
|
@@ -135,7 +135,7 @@ def test_httpx_client_requests_http2(monkeypatch):
|
|
|
135
135
|
def __init__(self, **kwargs):
|
|
136
136
|
calls.append(kwargs)
|
|
137
137
|
|
|
138
|
-
monkeypatch.setattr(
|
|
138
|
+
monkeypatch.setattr(llm_clients, "_sdk_http_stack", lambda: (httpx, FakeAsyncClient))
|
|
139
139
|
|
|
140
140
|
llm_clients._httpx_client()
|
|
141
141
|
|
|
@@ -154,7 +154,7 @@ def test_httpx_client_falls_back_to_http1_when_h2_missing(monkeypatch):
|
|
|
154
154
|
raise ImportError("Using http2=True, but the 'h2' package is not installed")
|
|
155
155
|
calls.append(kwargs)
|
|
156
156
|
|
|
157
|
-
monkeypatch.setattr(
|
|
157
|
+
monkeypatch.setattr(llm_clients, "_sdk_http_stack", lambda: (httpx, FakeAsyncClient))
|
|
158
158
|
|
|
159
159
|
llm_clients._httpx_client() # must not raise
|
|
160
160
|
|
|
@@ -162,6 +162,67 @@ def test_httpx_client_falls_back_to_http1_when_h2_missing(monkeypatch):
|
|
|
162
162
|
assert llm_clients._h2_unavailable_logged is True
|
|
163
163
|
|
|
164
164
|
|
|
165
|
+
# --------------------------------------------------------------------------
|
|
166
|
+
# SDK HTTP stack detection (anthropic 0.x uses httpx, 2.x uses httpx2)
|
|
167
|
+
# --------------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
def test_sdk_http_stack_matches_installed_sdk():
|
|
170
|
+
"""The client class must be the one the installed anthropic SDK accepts."""
|
|
171
|
+
import anthropic
|
|
172
|
+
|
|
173
|
+
http_mod, client_cls = llm_clients._sdk_http_stack()
|
|
174
|
+
|
|
175
|
+
assert client_cls is anthropic.DefaultAsyncHttpxClient
|
|
176
|
+
assert http_mod.__name__ in ("httpx", "httpx2")
|
|
177
|
+
assert any(
|
|
178
|
+
b.__name__ == "AsyncClient" and b.__module__.split(".")[0] == http_mod.__name__
|
|
179
|
+
for b in client_cls.__mro__
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def test_real_anthropic_client_accepts_pooled_http_client():
|
|
184
|
+
"""Regression: anthropic 2.x raised 'Invalid http_client argument' for httpx."""
|
|
185
|
+
assert llm_clients._build_anthropic("sk-ant-api03-test") is not None
|
|
186
|
+
assert llm_clients._build_anthropic("sk-ant-oat-test") is not None
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def test_sdk_http_stack_follows_sdk_base_module(monkeypatch):
|
|
190
|
+
import sys
|
|
191
|
+
import types
|
|
192
|
+
|
|
193
|
+
import anthropic
|
|
194
|
+
|
|
195
|
+
fake_mod = types.ModuleType("httpx2")
|
|
196
|
+
|
|
197
|
+
class AsyncClient: # stands in for httpx2.AsyncClient
|
|
198
|
+
pass
|
|
199
|
+
|
|
200
|
+
AsyncClient.__module__ = "httpx2._client"
|
|
201
|
+
|
|
202
|
+
class SdkClient(AsyncClient):
|
|
203
|
+
pass
|
|
204
|
+
|
|
205
|
+
monkeypatch.setattr(anthropic, "DefaultAsyncHttpxClient", SdkClient)
|
|
206
|
+
monkeypatch.setitem(sys.modules, "httpx2", fake_mod)
|
|
207
|
+
|
|
208
|
+
http_mod, client_cls = llm_clients._sdk_http_stack()
|
|
209
|
+
|
|
210
|
+
assert http_mod is fake_mod
|
|
211
|
+
assert client_cls is SdkClient
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def test_sdk_http_stack_falls_back_to_httpx_without_default_client(monkeypatch):
|
|
215
|
+
import anthropic
|
|
216
|
+
import httpx
|
|
217
|
+
|
|
218
|
+
monkeypatch.delattr(anthropic, "DefaultAsyncHttpxClient")
|
|
219
|
+
|
|
220
|
+
http_mod, client_cls = llm_clients._sdk_http_stack()
|
|
221
|
+
|
|
222
|
+
assert http_mod is httpx
|
|
223
|
+
assert client_cls is httpx.AsyncClient
|
|
224
|
+
|
|
225
|
+
|
|
165
226
|
# --------------------------------------------------------------------------
|
|
166
227
|
# Keepalive — best-effort
|
|
167
228
|
# --------------------------------------------------------------------------
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/tests/test_transcription_phase.py
RENAMED
|
@@ -96,7 +96,7 @@ def test_stall_constants_are_sane():
|
|
|
96
96
|
def test_emit_all_chunks_drains_every_complete_chunk(cap):
|
|
97
97
|
from collections import deque
|
|
98
98
|
buf = deque([0.0] * (160 * 3 + 30)) # 3 full 10ms chunks + 30 leftover samples
|
|
99
|
-
produced = cap._emit_all_chunks(buf, 160
|
|
99
|
+
produced = cap._emit_all_chunks(buf, 160)
|
|
100
100
|
assert produced == 3, "must emit ALL complete chunks in one call, not just one"
|
|
101
101
|
assert cap.audio_queue.qsize() == 3
|
|
102
102
|
assert len(buf) == 30, "sub-chunk remainder stays buffered for next time"
|
|
@@ -105,45 +105,6 @@ def test_emit_all_chunks_drains_every_complete_chunk(cap):
|
|
|
105
105
|
def test_emit_all_chunks_noop_below_chunk_size(cap):
|
|
106
106
|
from collections import deque
|
|
107
107
|
buf = deque([0.0] * 159)
|
|
108
|
-
assert cap._emit_all_chunks(buf, 160
|
|
108
|
+
assert cap._emit_all_chunks(buf, 160) == 0
|
|
109
109
|
assert cap.audio_queue.qsize() == 0
|
|
110
110
|
assert len(buf) == 159
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def test_emit_all_chunks_targets_the_given_queue(cap):
|
|
114
|
-
from collections import deque
|
|
115
|
-
buf = deque([0.0] * 320)
|
|
116
|
-
cap._emit_all_chunks(buf, 160, cap.mic_queue)
|
|
117
|
-
assert cap.mic_queue.qsize() == 2
|
|
118
|
-
assert cap.audio_queue.qsize() == 0, "must write to the queue it was handed"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
# --------------------------------------------------------------------------
|
|
122
|
-
# Separate mic stream: routing flag + queue adapter
|
|
123
|
-
# --------------------------------------------------------------------------
|
|
124
|
-
|
|
125
|
-
def test_enable_mic_routing_flag(cap):
|
|
126
|
-
assert cap._mic_routing is False
|
|
127
|
-
cap.enable_mic_routing()
|
|
128
|
-
assert cap._mic_routing is True
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def test_mic_source_get_and_flush(cap):
|
|
132
|
-
src = cap.mic_source()
|
|
133
|
-
assert src.get_audio(timeout=0.001) is None # empty queue
|
|
134
|
-
cap.mic_queue.put(_chunk())
|
|
135
|
-
cap.mic_queue.put(_chunk())
|
|
136
|
-
assert src.get_audio(timeout=0.001) is not None
|
|
137
|
-
assert src.flush() == 1 # the one remaining chunk dropped
|
|
138
|
-
assert cap.mic_queue.qsize() == 0
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def test_trim_queue_bounds_mic_queue(cap):
|
|
142
|
-
# If the mic transcriber dies, routing stays on and mic_queue would grow
|
|
143
|
-
# unbounded — _trim_queue must cap it to the live tail like the primary.
|
|
144
|
-
over = cap._STALL_TRIM_CHUNKS + 100
|
|
145
|
-
for _ in range(over):
|
|
146
|
-
cap.mic_queue.put(_chunk())
|
|
147
|
-
trimmed = cap._trim_queue(cap.mic_queue)
|
|
148
|
-
assert cap.mic_queue.qsize() == cap._STALL_TAIL_CHUNKS
|
|
149
|
-
assert trimmed == over - cap._STALL_TAIL_CHUNKS
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/audio/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/__init__.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/__main__.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/flet_gui/app.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/hotkey_config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/ollama_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/screenshot.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/__init__.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/app.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/routes.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.4}/src/ai_interview/server/websocket.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|