Skip to content

Commit

Permalink
update models and openai api key error logic
Browse files Browse the repository at this point in the history
  • Loading branch information
knowsuchagency committed Nov 15, 2024
1 parent bad2df2 commit 256ba8e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ cython_debug/

.gradio/
.DS_Store
gradio_cached_examples/
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ services:
OPENAI_API_KEY: ${OPENAI_API_KEY}
SENTRY_DSN: ${SENTRY_DSN}
PROMPTIC_DEBUG: ${PROMPTIC_DEBUG}
GEMINI_API_KEY: ${GEMINI_API_KEY}
volumes:
- gradio:/app/.gradio
- pdf_to_podcast_gradio:/app/.gradio
- pdf_to_podcast_gradio_cache:/app/gradio_cached_examples

volumes:
gradio:
pdf_to_podcast_gradio:
pdf_to_podcast_gradio_cache:
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_mp3(text: str, voice: str, api_key: str = None) -> bytes:

def generate_audio(file: str, openai_api_key: str = None) -> bytes:

if not os.getenv("OPENAI_API_KEY", openai_api_key):
if not (os.getenv("OPENAI_API_KEY") or openai_api_key):
raise gr.Error("OpenAI API key is required")

with Path(file).open("rb") as f:
Expand All @@ -72,7 +72,7 @@ def generate_audio(file: str, openai_api_key: str = None) -> bytes:

@retry(retry=retry_if_exception_type(ValidationError))
@llm(
model="gpt-4o-mini",
model="gemini/gemini-1.5-flash-002",
)
def generate_dialogue(text: str) -> Dialogue:
"""
Expand Down

0 comments on commit 256ba8e

Please sign in to comment.