diff --git a/api/src/main.py b/api/src/main.py index c201e71..610bd5d 100644 --- a/api/src/main.py +++ b/api/src/main.py @@ -12,11 +12,11 @@ generate_audiocast, ) from src.utils.get_audiocast import get_audiocast -from utils_pkg.chat_utils import ( +from shared_utils_pkg.chat_utils import ( SessionChatMessage, SessionChatRequest, ) -from utils_pkg.session_manager import SessionManager +from shared_utils_pkg.session_manager import SessionManager app = FastAPI(title="Audiora", version="1.0.0") diff --git a/api/src/utils/audiocast_request.py b/api/src/utils/audiocast_request.py index 0fd52a9..9ad52c9 100644 --- a/api/src/utils/audiocast_request.py +++ b/api/src/utils/audiocast_request.py @@ -7,7 +7,7 @@ from src.utils.prompt_templates.source_content_prompt import get_content_source_prompt from src.utils.prompt_templates.streamline_audio import streamline_audio_script_prompt from src.utils.prompt_templates.tts_prompt import Metadata, TTSPromptMaker -from utils_pkg.chat_utils import ContentCategory +from shared_utils_pkg.chat_utils import ContentCategory def generate_source_content(category: ContentCategory, summary: str): diff --git a/api/src/utils/chat_request.py b/api/src/utils/chat_request.py index e770d9a..5aea5cf 100644 --- a/api/src/utils/chat_request.py +++ b/api/src/utils/chat_request.py @@ -1,7 +1,7 @@ from typing import Any, Callable, List, Optional from services.openai_client import get_openai -from utils_pkg.chat_utils import ContentCategory, SessionChatMessage +from shared_utils_pkg.chat_utils import ContentCategory, SessionChatMessage def get_system_message(content_category: ContentCategory): diff --git a/api/src/utils/generate_audiocast.py b/api/src/utils/generate_audiocast.py index 502a308..98ba363 100644 --- a/api/src/utils/generate_audiocast.py +++ b/api/src/utils/generate_audiocast.py @@ -3,19 +3,17 @@ from fastapi import BackgroundTasks, HTTPException from services.storage import StorageManager -from src.utils.audiocast_request import AudioScriptMaker, generate_source_content -from utils_pkg.audio_manager import AudioManager, AudioManagerConfig -from utils_pkg.audiocast_utils import ( +from shared_utils_pkg.audiocast_utils import ( GenerateAudioCastRequest, GenerateAudioCastResponse, ) -from utils_pkg.session_manager import SessionManager -from utils_pkg.waveform_utils import WaveformUtils +from shared_utils_pkg.session_manager import SessionManager +from shared_utils_pkg.waveform_utils import WaveformUtils +from src.utils.audio_manager import AudioManager, AudioManagerConfig +from src.utils.audiocast_request import AudioScriptMaker, generate_source_content -async def generate_audiocast( - request: GenerateAudioCastRequest, background_tasks: BackgroundTasks -): +async def generate_audiocast(request: GenerateAudioCastRequest, background_tasks: BackgroundTasks): """## Generate audiocast based on a summary of user's request ### Steps: @@ -50,9 +48,9 @@ def update_session_info(info: str): # Generate audio update_session_info("Generating audio...") - audio_path = await AudioManager( - custom_config=AudioManagerConfig(tts_provider="elevenlabs") - ).generate_speech(audio_script) + audio_path = await AudioManager(custom_config=AudioManagerConfig(tts_provider="elevenlabs")).generate_speech( + audio_script + ) def _run_on_background(): try: diff --git a/api/src/utils/generate_speech_utils.py b/api/src/utils/generate_speech_utils.py index 218c4ed..430ac05 100644 --- a/api/src/utils/generate_speech_utils.py +++ b/api/src/utils/generate_speech_utils.py @@ -4,7 +4,7 @@ from services.elevenlabs_client import get_elevenlabs_client from services.openai_client import get_openai -from utils_pkg.decorators import process_time +from shared_utils_pkg.decorators import process_time TTSProvider = Literal["openai", "elevenlabs"] diff --git a/api/src/utils/get_audiocast.py b/api/src/utils/get_audiocast.py index 054e717..246827e 100644 --- a/api/src/utils/get_audiocast.py +++ b/api/src/utils/get_audiocast.py @@ -6,7 +6,7 @@ from src.utils.generate_audiocast import ( GenerateAudioCastResponse, ) -from utils_pkg.session_manager import SessionManager +from shared_utils_pkg.session_manager import SessionManager def get_audiocast(session_id: str): diff --git a/api/src/utils/prompt_templates/source_content_prompt.py b/api/src/utils/prompt_templates/source_content_prompt.py index 3727dde..6c431aa 100644 --- a/api/src/utils/prompt_templates/source_content_prompt.py +++ b/api/src/utils/prompt_templates/source_content_prompt.py @@ -1,4 +1,4 @@ -from utils_pkg.chat_utils import ContentCategory, category_qualifiers +from shared_utils_pkg.chat_utils import ContentCategory, category_qualifiers def get_content_source_prompt(category: ContentCategory, summary: str): diff --git a/api/src/utils/prompt_templates/tts_prompt.py b/api/src/utils/prompt_templates/tts_prompt.py index 882535d..161aa40 100644 --- a/api/src/utils/prompt_templates/tts_prompt.py +++ b/api/src/utils/prompt_templates/tts_prompt.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from utils_pkg.chat_utils import ContentCategory, category_qualifiers +from shared_utils_pkg.chat_utils import ContentCategory, category_qualifiers @dataclass diff --git a/tests/__init__.py b/api/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to api/tests/__init__.py diff --git a/tests/test_speech_gen.py b/api/tests/test_speech_gen.py similarity index 96% rename from tests/test_speech_gen.py rename to api/tests/test_speech_gen.py index d8612ef..426e813 100644 --- a/tests/test_speech_gen.py +++ b/api/tests/test_speech_gen.py @@ -3,8 +3,8 @@ import uuid from pathlib import Path -from utils_pkg.audio_manager import AudioManager -from utils_pkg.audio_synthesizer import AudioSynthesizer +from src.utils.audio_manager import AudioManager +from src.utils.audio_synthesizer import AudioSynthesizer content = """ Hello there! Today, we're diving into a personal reflection on justice as explored in Plato's Republic, and how it relates to today's political systems. Exciting, right? diff --git a/app/src/utils/chat_thread.py b/app/src/utils/chat_thread.py index 3de0492..3ce5b73 100644 --- a/app/src/utils/chat_thread.py +++ b/app/src/utils/chat_thread.py @@ -7,7 +7,7 @@ from src.utils.session_state import reset_session from env_var import API_URL -from utils_pkg.chat_utils import ( +from shared_utils_pkg.chat_utils import ( ContentCategory, SessionChatMessage, SessionChatRequest, diff --git a/app/src/utils/display_example_cards.py b/app/src/utils/display_example_cards.py index 05cb120..3021423 100644 --- a/app/src/utils/display_example_cards.py +++ b/app/src/utils/display_example_cards.py @@ -1,6 +1,6 @@ import streamlit as st -from utils_pkg.chat_utils import content_examples +from shared_utils_pkg.chat_utils import content_examples def display_example_cards(): diff --git a/app/src/utils/metadata_subscription.py b/app/src/utils/metadata_subscription.py index e1ea0b3..458d3c9 100644 --- a/app/src/utils/metadata_subscription.py +++ b/app/src/utils/metadata_subscription.py @@ -2,7 +2,7 @@ import streamlit as st -from utils_pkg.session_manager import SessionManager +from shared_utils_pkg.session_manager import SessionManager async def subscribe_to_audio_generation(session_id: str): diff --git a/app/src/utils/render_audiocast_utils.py b/app/src/utils/render_audiocast_utils.py index cc5ab5d..bce3c36 100644 --- a/app/src/utils/render_audiocast_utils.py +++ b/app/src/utils/render_audiocast_utils.py @@ -7,8 +7,8 @@ from env_var import APP_URL, API_URL from src.utils.render_waveform import render_waveform -from utils_pkg.audiocast_utils import GenerateAudioCastRequest, GenerateAudiocastDict -from utils_pkg.chat_utils import ContentCategory +from shared_utils_pkg.audiocast_utils import GenerateAudioCastRequest, GenerateAudiocastDict +from shared_utils_pkg.chat_utils import ContentCategory def navigate_to_home(): diff --git a/app/src/utils/render_chat.py b/app/src/utils/render_chat.py index 6c7739a..d02b634 100644 --- a/app/src/utils/render_chat.py +++ b/app/src/utils/render_chat.py @@ -1,5 +1,5 @@ import streamlit as st -from utils_pkg.chat_utils import content_categories +from shared_utils_pkg.chat_utils import content_categories def set_content_category(): diff --git a/app/src/utils/render_waveform.py b/app/src/utils/render_waveform.py index 15c5ed3..0e23f79 100644 --- a/app/src/utils/render_waveform.py +++ b/app/src/utils/render_waveform.py @@ -4,7 +4,7 @@ from pydub import AudioSegment from services.storage import BLOB_BASE_URI, StorageManager -from utils_pkg.waveform_utils import WaveformUtils +from shared_utils_pkg.waveform_utils import WaveformUtils def render_waveform(session_id: str, audio_path: str, autoplay=False): diff --git a/app/src/utils/session_state.py b/app/src/utils/session_state.py index 1cc67fc..4267b46 100644 --- a/app/src/utils/session_state.py +++ b/app/src/utils/session_state.py @@ -2,7 +2,7 @@ from typing import List, Literal, TypedDict, cast import streamlit as st -from utils_pkg.chat_utils import ContentCategory +from shared_utils_pkg.chat_utils import ContentCategory MessageRole = Literal["user", "assistant", "ai", "human"] diff --git a/utils_pkg/__init__.py b/shared_utils_pkg/__init__.py similarity index 100% rename from utils_pkg/__init__.py rename to shared_utils_pkg/__init__.py diff --git a/utils_pkg/audiocast_utils.py b/shared_utils_pkg/audiocast_utils.py similarity index 88% rename from utils_pkg/audiocast_utils.py rename to shared_utils_pkg/audiocast_utils.py index d346915..77a4f52 100644 --- a/utils_pkg/audiocast_utils.py +++ b/shared_utils_pkg/audiocast_utils.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from utils_pkg.chat_utils import ContentCategory +from shared_utils_pkg.chat_utils import ContentCategory class GenerateAudioCastRequest(BaseModel): diff --git a/utils_pkg/chat_utils.py b/shared_utils_pkg/chat_utils.py similarity index 100% rename from utils_pkg/chat_utils.py rename to shared_utils_pkg/chat_utils.py diff --git a/utils_pkg/decorators.py b/shared_utils_pkg/decorators.py similarity index 100% rename from utils_pkg/decorators.py rename to shared_utils_pkg/decorators.py diff --git a/utils_pkg/session_manager.py b/shared_utils_pkg/session_manager.py similarity index 98% rename from utils_pkg/session_manager.py rename to shared_utils_pkg/session_manager.py index 370c0b2..78ad4f5 100644 --- a/utils_pkg/session_manager.py +++ b/shared_utils_pkg/session_manager.py @@ -8,7 +8,7 @@ arrayUnion, collections, ) -from utils_pkg.chat_utils import SessionChatMessage +from shared_utils_pkg.chat_utils import SessionChatMessage @dataclass diff --git a/utils_pkg/setup.py b/shared_utils_pkg/setup.py similarity index 85% rename from utils_pkg/setup.py rename to shared_utils_pkg/setup.py index 91ba350..8d7a076 100644 --- a/utils_pkg/setup.py +++ b/shared_utils_pkg/setup.py @@ -1,7 +1,7 @@ from setuptools import find_packages, setup setup( - name="utils_pkg", + name="shared_utils_pkg", version="1.0.0", packages=find_packages(), install_requires=[ diff --git a/utils_pkg/waveform_utils.py b/shared_utils_pkg/waveform_utils.py similarity index 100% rename from utils_pkg/waveform_utils.py rename to shared_utils_pkg/waveform_utils.py