Skip to content

Commit

Permalink
move all python specific logic into api
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Nov 7, 2024
1 parent c459075 commit d0096e2
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 61 deletions.
6 changes: 0 additions & 6 deletions .streamlit/config.toml

This file was deleted.

File renamed without changes.
38 changes: 19 additions & 19 deletions requirements.txt → api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
anthropic
asyncio
elevenlabs
fastapi
pydantic
fastapi-utilities
ffmpeg-python

uvicorn
firebase-admin
google-api-python-client
google-auth
google-cloud-storage
google-generativeai
gunicorn
uvloop

streamlit
httpx
asyncio

openai
anthropic
elevenlabs
pycairo
pydantic

pydub
python-dotenv

python-multipart
python-slugify
python-dotenv
ffmpeg-python

pydub
ruff
seewav
pycairo
setuptools

firebase-admin
google-auth
google-cloud-storage
google-api-python-client
google-generativeai
streamlit

ruff
uvicorn
uvloop
watchdog
setuptools
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
from fastapi import BackgroundTasks, FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi_utilities import add_timer_middleware
from utils.chat_utils import (

from src.utils.chat_request import chat_request
from src.utils.chat_utils import (
SessionChatMessage,
SessionChatRequest,
)
from utils.session_manager import SessionManager

from src.utils.chat_request import chat_request
from src.utils.generate_audiocast import (
GenerateAudioCastRequest,
GenerateAudioCastResponse,
generate_audiocast,
)
from src.utils.get_audiocast import get_audiocast
from src.utils.session_manager import SessionManager

app = FastAPI(title="Audiora", version="1.0.0")

Expand Down
2 changes: 1 addition & 1 deletion api/src/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from services.admin_sdk import init_admin_sdk
from src.services.admin_sdk import init_admin_sdk

init_admin_sdk()
2 changes: 1 addition & 1 deletion api/src/services/anthropic_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from anthropic import Anthropic, AsyncAnthropic

from env_var import ANTHROPIC_API_KEY
from api.src.env_var import ANTHROPIC_API_KEY


def get_anthropic():
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/elevenlabs_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from elevenlabs.client import ElevenLabs

from env_var import ELEVENLABS_API_KEY
from api.src.env_var import ELEVENLABS_API_KEY

client = ElevenLabs(
api_key=ELEVENLABS_API_KEY,
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/gemini_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import google.generativeai as genai

from env_var import GEMINI_API_KEY
from api.src.env_var import GEMINI_API_KEY


def get_gemini():
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/openai_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from openai import Client

from env_var import OPENAI_API_KEY
from api.src.env_var import OPENAI_API_KEY


def get_openai():
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from google.cloud import storage
from pydub import AudioSegment

from env_var import BUCKET_NAME
from api.src.env_var import BUCKET_NAME

storage_client = storage.Client()
bucket = storage_client.bucket(BUCKET_NAME)
Expand Down
9 changes: 4 additions & 5 deletions api/src/utils/audiocast_request.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import re
from typing import Literal

from services.anthropic_client import get_anthropic_sync
from services.gemini_client import GeminiConfig, generate_content
from services.openai_client import get_openai
from utils.chat_utils import ContentCategory

from src.services.anthropic_client import get_anthropic_sync
from src.services.gemini_client import GeminiConfig, generate_content
from src.services.openai_client import get_openai
from src.utils.chat_utils import ContentCategory
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
Expand Down
3 changes: 2 additions & 1 deletion api/src/utils/audiocast_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import TypedDict

from pydantic import BaseModel
from utils.chat_utils import ContentCategory

from src.utils.chat_utils import ContentCategory


class GenerateAudioCastRequest(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions 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.chat_utils import ContentCategory, SessionChatMessage
from src.services.openai_client import get_openai
from src.utils.chat_utils import ContentCategory, SessionChatMessage


def get_system_message(content_category: ContentCategory):
Expand Down
14 changes: 7 additions & 7 deletions api/src/utils/generate_audiocast.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from datetime import datetime

from fastapi import BackgroundTasks, HTTPException
from services.storage import StorageManager
from utils.audiocast_utils import (
GenerateAudioCastRequest,
GenerateAudioCastResponse,
)
from utils.session_manager import SessionManager
from utils.waveform_utils import WaveformUtils

from src.services.storage import StorageManager
from src.utils.audio_manager import AudioManager, AudioManagerConfig
from src.utils.audiocast_request import AudioScriptMaker, generate_source_content
from src.utils.audiocast_utils import (
GenerateAudioCastRequest,
GenerateAudioCastResponse,
)
from src.utils.session_manager import SessionManager
from src.utils.waveform_utils import WaveformUtils


async def generate_audiocast(request: GenerateAudioCastRequest, background_tasks: BackgroundTasks):
Expand Down
6 changes: 3 additions & 3 deletions api/src/utils/generate_speech_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from io import BytesIO
from typing import Dict, List, Literal

from services.elevenlabs_client import get_elevenlabs_client
from services.openai_client import get_openai
from utils.decorators import process_time
from src.services.elevenlabs_client import get_elevenlabs_client
from src.services.openai_client import get_openai
from src.utils.decorators import process_time

TTSProvider = Literal["openai", "elevenlabs"]

Expand Down
4 changes: 2 additions & 2 deletions api/src/utils/get_audiocast.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime

from fastapi import HTTPException
from services.storage import StorageManager
from utils.session_manager import SessionManager

from src.services.storage import StorageManager
from src.utils.generate_audiocast import (
GenerateAudioCastResponse,
)
from src.utils.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.chat_utils import ContentCategory, category_qualifiers
from src.utils.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.chat_utils import ContentCategory, category_qualifiers
from src.utils.chat_utils import ContentCategory, category_qualifiers


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions api/src/utils/session_manager.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from dataclasses import dataclass
from typing import Callable, Dict, List, Optional, cast

from services.firestore_sdk import (
from src.services.firestore_sdk import (
Collection,
DBManager,
arrayRemove,
arrayUnion,
collections,
)
from utils.chat_utils import SessionChatMessage
from src.utils.chat_utils import SessionChatMessage


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/waveform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from seewav import visualize

from services.storage import StorageManager
from src.services.storage import StorageManager


class WaveformUtils:
Expand Down
2 changes: 1 addition & 1 deletion api/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dotenv import load_dotenv

from services.admin_sdk import init_admin_sdk
from src.services.admin_sdk import init_admin_sdk

load_dotenv()

Expand Down

0 comments on commit d0096e2

Please sign in to comment.