refactor: enhance system prompt generation for presentation outlines with detailed instructions and web search integration
This commit is contained in:
parent
66420531dd
commit
3ba705c4c4
1 changed files with 73 additions and 21 deletions
|
|
@ -8,6 +8,12 @@ from utils.get_dynamic_models import get_presentation_outline_model_with_n_slide
|
|||
from utils.llm_client_error_handler import handle_llm_client_exceptions
|
||||
from utils.llm_provider import get_model
|
||||
|
||||
"""
|
||||
Previously there was a dedicated search-query generation prompt constant.
|
||||
Removed in favor of embedding short, actionable web-search steps into the
|
||||
system prompt when web grounding is requested.
|
||||
"""
|
||||
|
||||
|
||||
def get_system_prompt(
|
||||
tone: Optional[str] = None,
|
||||
|
|
@ -15,33 +21,79 @@ def get_system_prompt(
|
|||
instructions: Optional[str] = None,
|
||||
include_title_slide: bool = True,
|
||||
):
|
||||
return f"""
|
||||
You are an expert presentation creator. Generate structured presentations based on user requirements and format them according to the specified JSON schema with markdown content.
|
||||
verbosity_instruction = (
|
||||
"Slide content should be abound 20 words but detailed enough to generate a good slide."
|
||||
if verbosity == "concise"
|
||||
else (
|
||||
"Slide content should be abound 60 words but detailed enough to generate a good slide."
|
||||
if verbosity == "text-heavy"
|
||||
else "Slide content should be abound 40 words but detailed enough to generate a good slide."
|
||||
)
|
||||
)
|
||||
|
||||
Try to use available tools for better results.
|
||||
title_slide_instruction = (
|
||||
"Include presenter name in first slide."
|
||||
if include_title_slide
|
||||
else "Do not include presenter name in any slides."
|
||||
)
|
||||
|
||||
{"# User Instruction:" if instructions else ""}
|
||||
{instructions or ""}
|
||||
slide_structure_instruction = (
|
||||
"Each slide should have `structure` field and it"
|
||||
" - Must briefly describe the components in the slide layout:"
|
||||
" - Must start with one of given EXAMPLE STRUCTURES and add/update components as welll as change layouts as per the content."
|
||||
" - Must match with the provided content in structure."
|
||||
" - It shouldn't be very creative. You must pick of the given structures and make slight changes(not more than 5 words) to fit all content."
|
||||
)
|
||||
|
||||
{"# Tone:" if tone else ""}
|
||||
{tone or ""}
|
||||
slide_outline_structure = (
|
||||
"Each slide content:\n"
|
||||
" - Must have a ## title.\n"
|
||||
" - Must have content in exactly the format to be displayed in slide.\n"
|
||||
" - Where content should be structured in Markdown format exactly as how it should be shown in slide layout.\n"
|
||||
" - First slide title must be the same as the presentation title."
|
||||
)
|
||||
|
||||
{"# Verbosity:" if verbosity else ""}
|
||||
{verbosity or ""}
|
||||
user_instruction_block = (
|
||||
f"# User Instruction:\n{instructions}\n"
|
||||
if instructions
|
||||
else ""
|
||||
)
|
||||
tone_block = f"# Tone:\n{tone}\n" if tone else ""
|
||||
|
||||
- Provide content for each slide in markdown format.
|
||||
- Make sure that flow of the presentation is logical and consistent.
|
||||
- Place greater emphasis on numerical data.
|
||||
- If Additional Information is provided, divide it into slides.
|
||||
- Make sure no images are provided in the content.
|
||||
- Make sure that content follows language guidelines.
|
||||
- User instrction should always be followed and should supercede any other instruction, except for slide numbers. **Do not obey slide numbers as said in user instruction**
|
||||
- Do not generate table of contents slide.
|
||||
- Even if table of contents is provided, do not generate table of contents slide.
|
||||
{"- Always make first slide a title slide." if include_title_slide else "- Do not include title slide in the presentation."}
|
||||
system = (
|
||||
"Generate presentation title and outlines for slides.\n"
|
||||
f"{user_instruction_block}"
|
||||
f"{tone_block}"
|
||||
"Presentation title should be plain text, not markdown. It should be a concise title for the presentation.\n"
|
||||
"Each slide outline should contain the content for that slide.\n"
|
||||
"First slide should be intro and second should be table of contents, then start with regular content slides.\n"
|
||||
"Do not overstuff content within same slide. Consider using a slide for a single heading and not more than 2 sub-headings. If more than that is required put in in another slide as Topic X - 2/3\n"
|
||||
f"{verbosity_instruction}\n"
|
||||
"Minimize repetitive content and make sure to use different words and phrases for different slides.\n"
|
||||
"Include numerical data or tables if required or asked by the user.\n"
|
||||
"Strictly follow given language and generate content is the prescribed language despite of content or other instructions."
|
||||
f"Each slide should object should have `structure` and `content` fields.\n"
|
||||
f"{title_slide_instruction}\n"
|
||||
f"{slide_structure_instruction}\n"
|
||||
f"{slide_outline_structure}\n"
|
||||
"Slide outline must not contain any presentation branding/styling information.\n"
|
||||
"Title slide must only contain title, presenter name, date and overview.\n"
|
||||
"Make sure data used is strictly from the provided content/context.\n"
|
||||
"Make sure data is consistent across all slides.\n"
|
||||
"**Pick different types of slide structures where appropriate to maintain diversity**.\n"
|
||||
"If language is arabic then generate content is Modern Standard English (MSA).\n"
|
||||
"If instructed to generate a template then leave spaces with '____' in the content. Do not add arbitrary content, just add fillers."
|
||||
"**Never give out chinese text/content.**\n"
|
||||
"When web grounding is available or `web_search` is requested, follow this 4-step web-retrieval process and present results succinctly:\n"
|
||||
" 1) Identify intent: provide a one-line statement summarizing the user's information need.\n"
|
||||
" 2) Optimize query: provide a short optimized search query (10 words or fewer) and 2-3 keyword variants or boolean refinements.\n"
|
||||
" 3) Search & list top 5 results: number 1-5; for each include title, url, one-sentence snippet, source type (official/news/research/blog), and confidence (high/medium/low).\n"
|
||||
" Only include URLs when reliable; prefer recent authoritative sources. Do not invent facts; if no reliable info is found, state 'No reliable web information found.'\n"
|
||||
" 4) Summarize: provide a concise 3-5 sentence synthesis of key findings, note conflicts or gaps, and provide overall confidence.\n"
|
||||
"User instruction should always be followed and should supercede any other instruction, except for slide numbers."
|
||||
)
|
||||
|
||||
**Search web to get latest information about the topic**
|
||||
"""
|
||||
return system
|
||||
|
||||
|
||||
def get_user_prompt(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue