Skip to content

Commit

Permalink
improve summarizer prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomarin committed Jan 3, 2025
1 parent 56ba596 commit e57bed6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
Binary file modified apps/frontend/frontend.zip
Binary file not shown.
6 changes: 1 addition & 5 deletions common/audio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,10 @@ def speech_to_text_from_bytes(audio_bytes: BytesIO, temp_filename: str = "temp_a

def summarize_text(input_text: str) -> str:
"""
Summarize the text using the Azure GPT-4o mini model if it exceeds 500 characters.
Otherwise, return the text as-is.
Converts the input text to a voice-ready short answer.
This uses LangChain's AzureChatOpenAI with your custom summarization instructions.
"""
# If text is short, no need to summarize
if len(input_text) <= 500:
return input_text

# For example, define how many tokens we allow for the completion
COMPLETION_TOKENS = 1000
Expand Down
18 changes: 11 additions & 7 deletions common/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,18 @@
"""

SUMMARIZER_TEXT = """
You are a helpful assistant that summarizes long text answers into shorter versions (around 450 characters) for text-to-voice responses.
You are a helpful assistant that prepares/edits a text for a text-to-voice responses. These are your instructions on how to convert the input text for a text-to-speech-ready text:
(1) Maintain a personal touch.
(2) DO NOT include any URLs or web links; instead refer the listener to the full text answer for more details.
Respond in the first person.
Convert prices in USD to their text form, e.g. $5,600,345 USD -> five million six hundred thousand three hundred and forty-five dollars.
(3) Do not add anything else, just the summary.
(4) Very important: the summary should be in the same language as the text.
(5) Remember to keep your response around 450 characters.
(2) Respond in the same person as the input text.
(3) DO NOT include any URLs or web links
(4) If the input text is more than 500 characters, summarize it and refer the listener to the full text answer for more details.
(5) If the input text is less than 500 characters do not summarize, respond as is, just remove URLs from it.
(6) Convert prices in USD and telephone numbers to their text form, Examples:
- $5,600,345 USD -> five million six hundred thousand three hundred and forty-five dollars.
- 972-456-3432 -> nine seven two four five six three four three two.
(7) Do not add anything else, just the edited text.
(8) Very important: your reponse (edited text) should be in the same language as the input text.
(9) Remember to keep your response less than 500 characters.
"""
2 changes: 0 additions & 2 deletions credentials.env
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,3 @@ AZURE_SPEECH_VOICE_NAME="en-US-AriaNeural"
BOT_ID="ENTER YOUR VALUE HERE" # This is the name of your bot service created in Notebook 12
BOT_SERVICE_DIRECT_LINE_SECRET="ENTER YOUR VALUE HERE" # Find this in Azure Bot Service -> Channels -> Direct Line



0 comments on commit e57bed6

Please sign in to comment.