diff --git a/app/src/utils/render_audiocast_utils.py b/app/src/utils/render_audiocast_utils.py index a0188a8..0f9ea67 100644 --- a/app/src/utils/render_audiocast_utils.py +++ b/app/src/utils/render_audiocast_utils.py @@ -1,36 +1,16 @@ import re from pathlib import Path -from typing import TypedDict, cast +from typing import cast import httpx import streamlit as st -from pydantic import BaseModel from src.utils.render_waveform import render_waveform from env_var import APP_URL, SERVER_URL +from utils_pkg.audiocast_utils import GenerateAudiocastDict, GenerateAudioCastRequest from utils_pkg.chat_utils import ContentCategory -class GenerateAudioCastRequest(BaseModel): - sessionId: str - summary: str - category: str - - -class GenerateAudioCastResponse(BaseModel): - url: str - script: str - source_content: str - created_at: str | None - - -class GenerateAudiocastDict(TypedDict): - url: str - script: str - source_content: str - created_at: str | None - - def navigate_to_home(): main_script = str(Path(__file__).parent.parent / "app.py") st.switch_page(main_script) diff --git a/server/src/utils/generate_audiocast.py b/server/src/utils/generate_audiocast.py index b7f2cdf..5777e52 100644 --- a/server/src/utils/generate_audiocast.py +++ b/server/src/utils/generate_audiocast.py @@ -1,30 +1,18 @@ from datetime import datetime -from typing import Optional from fastapi import BackgroundTasks, HTTPException -from pydantic import BaseModel from services.storage import StorageManager from utils_pkg.audio_manager import AudioManager, AudioManagerConfig from utils_pkg.audiocast_request import AudioScriptMaker, generate_source_content -from utils_pkg.chat_utils import ContentCategory +from utils_pkg.audiocast_utils import ( + GenerateAudioCastRequest, + GenerateAudioCastResponse, +) from utils_pkg.session_manager import SessionManager from utils_pkg.waveform_utils import WaveformUtils -class GenerateAudioCastRequest(BaseModel): - sessionId: str - summary: str - category: ContentCategory - - -class GenerateAudioCastResponse(BaseModel): - url: str - script: str - source_content: str - created_at: Optional[str] - - async def generate_audiocast( request: GenerateAudioCastRequest, background_tasks: BackgroundTasks ): diff --git a/utils_pkg/audiocast_utils.py b/utils_pkg/audiocast_utils.py new file mode 100644 index 0000000..d346915 --- /dev/null +++ b/utils_pkg/audiocast_utils.py @@ -0,0 +1,25 @@ +from typing import TypedDict + +from pydantic import BaseModel + +from utils_pkg.chat_utils import ContentCategory + + +class GenerateAudioCastRequest(BaseModel): + sessionId: str + summary: str + category: ContentCategory + + +class GenerateAudioCastResponse(BaseModel): + url: str + script: str + source_content: str + created_at: str | None + + +class GenerateAudiocastDict(TypedDict): + url: str + script: str + source_content: str + created_at: str | None