Skip to content

Commit

Permalink
rename utils_pkg to shared_utils_pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Nov 5, 2024
1 parent 928faa8 commit 25081b3
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/audiocast_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/chat_request.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
20 changes: 9 additions & 11 deletions api/src/utils/generate_audiocast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/generate_speech_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/get_audiocast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/prompt_templates/source_content_prompt.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/prompt_templates/tts_prompt.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/test_speech_gen.py → api/tests/test_speech_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
<Speaker1>Hello there! Today, we're diving into a personal reflection on justice as explored in Plato's <phoneme alphabet="ipa" ph="rɪˈpʌblɪk">Republic</phoneme>, and how it relates to today's political systems. <break time="0.2s"/> Exciting, right?</Speaker1>
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/chat_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/display_example_cards.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/metadata_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions app/src/utils/render_audiocast_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/render_chat.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/render_waveform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/session_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
arrayUnion,
collections,
)
from utils_pkg.chat_utils import SessionChatMessage
from shared_utils_pkg.chat_utils import SessionChatMessage


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion utils_pkg/setup.py → shared_utils_pkg/setup.py
Original file line number Diff line number Diff line change
@@ -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=[
Expand Down
File renamed without changes.

0 comments on commit 25081b3

Please sign in to comment.