diff --git a/app/app.py b/app/app.py index db8590a..a7963e4 100644 --- a/app/app.py +++ b/app/app.py @@ -83,6 +83,15 @@ else 1, ) + # Max tokens slider + max_tokens = st.slider( + "Max Tokens", + min_value=1000, + max_value=32000, + value=8000, + step=500, + help="Select the maximum number of tokens to be used for generating the podcast script. Adjust this according to your OpenAI quota.", + ) # Submit button generate_podcast = form_container.button( "Generate Podcast", type="primary", disabled=not uploaded_file @@ -131,6 +140,7 @@ title=podcast_title, voice_1=voice_1, voice_2=voice_2, + max_tokens=max_tokens, ) podcast_script = podcast_response.podcast["script"] diff --git a/app/utils/llm.py b/app/utils/llm.py index 9a8f1f8..65c95c2 100644 --- a/app/utils/llm.py +++ b/app/utils/llm.py @@ -103,6 +103,7 @@ def document_to_podcast_script( title: str = "AI in Action", voice_1: str = "Andrew", voice_2: str = "Emma", + max_tokens: int = 8000, ) -> PodcastScriptResponse: """Get LLM response.""" @@ -136,7 +137,7 @@ def document_to_podcast_script( model=os.getenv("AZURE_OPENAI_MODEL_DEPLOYMENT", "gpt-4o"), temperature=0.7, response_format={"type": "json_schema", "json_schema": JSON_SCHEMA}, - max_tokens=8000, + max_tokens=max_tokens, ) message = chat_completion.choices[0].message.content