forked from MODSetter/SurfSense
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpropose.py
More file actions
41 lines (35 loc) · 1.33 KB
/
Copy pathpropose.py
File metadata and controls
41 lines (35 loc) · 1.33 KB
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
"""Propose a podcast's initial brief spec."""
from __future__ import annotations
from sqlalchemy.ext.asyncio import AsyncSession
from app.podcasts.duration_limits import DEFAULT_MAX_SECONDS, DEFAULT_MIN_SECONDS
from app.podcasts.persistence import PodcastRepository
from app.podcasts.schemas import PodcastSpec
from app.podcasts.service import preferences_from
from .config import DEFAULT_SPEAKER_COUNT
from .graph import graph as brief_graph
from .state import BriefState
async def propose_brief(
session: AsyncSession,
*,
search_space_id: int,
speaker_count: int = DEFAULT_SPEAKER_COUNT,
min_seconds: int = DEFAULT_MIN_SECONDS,
max_seconds: int = DEFAULT_MAX_SECONDS,
focus: str | None = None,
) -> PodcastSpec:
"""Reuse the last-used language and voices, else English; return the spec."""
last_language, last_voices = preferences_from(
await PodcastRepository(session).latest_with_spec(search_space_id)
)
config = {
"configurable": {
"speaker_count": speaker_count,
"min_seconds": min_seconds,
"max_seconds": max_seconds,
"focus": focus,
"last_used_language": last_language,
"last_used_voices": last_voices,
}
}
result = await brief_graph.ainvoke(BriefState(), config=config)
return result["spec"]