from agents.baseagent import BaseAgent class TariffTradeAgent(BaseAgent): promptsys =…
- User
from agents.base_agent import BaseAgent
class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents"
# Universal formatting enforcement line formatting_directive = """Please strictly follow these formatting guidelines for all numerical mentions and sentence structures:- No Combined Elements: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion").
- Time Formatting: Use formats like "Q4 2024" (never "Q42024" or "4th quarter").
- Number Rules:
- 3.3B → 3.3 billion
- 150.2M → 150.2 million
- 0.33 → keep exact decimal
- Text Integrity:
- "net income" never "netincome"
- "year-over-year" never "YOY" or "yearoveryear"
- Style Prohibition: Do not italicize or alter text formatting; maintain a single plain format throughout.
- Bad Example:
3.3billioninQ42024,withanadjustednetincomeof,106million,withadjustedearningsperdilutedshareat0.95→ REJECTED - ALWAYS Required Format:
3.3 billion in Q4 2024, with an adjusted net income of→ ACCEPTED
APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES."""
prompt_analyze = ( "Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”.\n\n" "The output should be a summary of the commentary, in 100 words or less. The summary should be in the third person (name of the company, management, the company).\n\n" "For every topic, ALWAYS provide excerpts mentioned under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If a topic is present in multiple documents, include a separate \"Ground Truth\" excerpt for each document.\n" "- Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the source exactly, including all formatting, punctuation, and special characters.\n" "- If the LLM cannot find an exact match in the document, do NOT fabricate or modify the excerpt—only include what is present in the document.\n\n" "Format the output as a concise summary without recommendations.\n\n" "Document Text: " + formatting_directive ) prompt_summary = ( "You are a senior tariff and trade analyst preparing a consolidated tariff and trade policy report for Macy's executive team from all documents provided.\n\n" "Identify and describe all impactful tariff, trade, and related government policy topics across the documents provided that could affect Macy's business operations including supply chain, procurement, retail sales, and technology.\n\n" "For each topic:\n" "- Provide a concise summary by combining relevant information from the documents.\n" "- Include relevant financial impacts, examples, figures, or timelines.\n" "- Provide three to five actionable strategic recommendations based on the analysis.\n\n" "For every topic, ALWAYS provide each excerpt mentioned under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If a topic is in multiple documents, include separate excerpts for each document with proper line breaks.\n" "- Do NOT paraphrase or alter any text.\n" "- If no exact excerpts are found, do NOT fabricate or modify content.\n\n" "Format the report in clear markdown with sections:\n" "- Executive Summary\n" "- Key Themes\n" "- Strategic Recommendations\n" "- Risk Assessment\n\n" "STRICTLY enforce plain text formatting:\n" + formatting_directive ) prompt_detail = ( "You are preparing a detailed briefing for Macy's CEO on the tariff and trade policy topic '{topic}', based on the provided external company document.\n\n" "Provide:\n" "1. A clear overview of the topic.\n" "2. Key insights and relevant excerpts.\n" "3. Important figures, dates, or timelines if available.\n" "4. A detailed analysis on how this topic could impact Macy's retail operations, supply chain, procurement, and consumer behavior.\n" "5. Three to five actionable strategic recommendations for Macy's leadership.\n\n" "For every topic, ALWAYS provide verbatim source excerpts under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If a topic is present in multiple documents, include a separate excerpt for each.\n" "- Do NOT paraphrase, summarize, or alter the text.\n" "- If no exact excerpts exist, do NOT fabricate or modify content.\n\n" "Document:\n" "{text}\n\n" "Topic: {topic}\n\n" "Please provide a structured briefing with clear paragraphs and bold topics.\n" + formatting_directive ) def analyze_document(self, text, custom_prompt=None): prompt_analyze = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt_analyze, text) def generate_consolidated_summary_from_topics(self, processed_files, custom_prompt=None): prompt_summary = custom_prompt if custom_prompt else self.prompt_summary return super().generate_consolidated_summary_from_topics(self.prompt_sys, prompt_summary, processed_files) def generate_topic_detail(self, text, topic, custom_prompt=None): prompt_detail = custom_prompt if custom_prompt else self.prompt_detail return super().generate_topic_detail(self.prompt_sys, prompt_detail, text, topic)make this prompt as below instruction
The output should be a summary of the commentary, in 100 words or less. The summary should be in the third person (name of the company, management, the company) We do not need the recommendation to Macy’s management for the specific commentary modules – we just want the bulleted summary of the commentary for each.
also for analyze topic prompt need like You are a senior business analyst working directly for Macy's CEO. Analyze the provided earnings call transcript and summarize mentions of consumer financial health and the macroeconomic environment.
Identify key topics including but not limited to: US consumer The company’s customer Change in demand Change in spend
For each topic, provide:
- A clear topic name (e.g., "E-commerce Growth", "Supply Chain Digitization")
- Concise 100-word summary providing key numbers and operational impacts
- Strictly preserve original numerical and textual formatting: maintain exact decimals (0.33), required spacing between numbers/text (0.11 → '0.11'), and verbatim terminology without concatenation or rephrasing.
- For every topic, ALWAYS provide excerpts mentioned under the heading "Ground Truth" as follows: - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document. - Format each excerpt as: Ground Truth: "Exact text from the document..." (Document Name) - If a topic is present in multiple documents, include a separate "Ground Truth" excerpt for each document. - Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the document data exactly, including all formatting, punctuation, and special characters. - If the LLM cannot find an exact match in the document, do NOT fabricate or modify the excerpt—only include what is present in the documents. Format each topic as:
- Topic Name: Summary [Relevance Score]
Example:
- Holiday Sales Performance: Q4 comparable sales up 4.2% driven by 18% digital growth [8]
- Inventory Optimization: Implementing AI demand forecasting to reduce carrying costs by $150M [7] Document Text:STRICTLY ENFORCE PLAIN TEXT FORMATTING:
- No Combined Elements: Always space-separate numbers/words/units (3.3 billion not 3.3billion)
- Time Formatting: Q4 2024 (never Q42024 or 4th quarter)
- Number Rules:
- 3.3B → 3.3 billion
- 150.2M → 150.2 million
- 0.33 → keep exact decimal
- Text Integrity:
- "net income" never "netincome"
- "YOY " never "year-over-year" or "yearoveryear"
- “vs.” never “versus” or “vs”
- “X billion”
- “X million”
- Style Prohibition: Do not make any word in Italic or any other format always make it in one format
- Bad Example: 3.3billioninQ42024,withanadjustednetincomeof, 106million,withadjustedearningsperdilutedshareat0.95 → REJECTED
- ALLWAYS Required Format: 3.3 billion in Q4 2024, with an adjusted net income of → ACCEPTED APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.
but have only the US Politics / Tariffs Prompt: Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”. in it
- Assistant
Certainly! Here's your revised
TariffTradeAgentclass prompts incorporating your requested changes:- Analyze prompt rewritten as a senior business analyst prompt focused on consumer financial health and macroeconomic environment topics, with all strict formatting enforcement.
- Analyze tariff impact prompt revised to only produce a concise third-person summary (≤100 words), no recommendations.
- All formatting rules strongly enforced with your specified formatting instructions.
- The tariff impact prompt narrowed to just "US Politics / Tariffs" topic with your exact wording and instructions.
from agents.base_agent import BaseAgent class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents" # Universal formatting enforcement line formatting_directive = """STRICTLY ENFORCE PLAIN TEXT FORMATTING: 1. **No Combined Elements**: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion"). 2. **Time Formatting**: Use formats like "Q4 2024" (never "Q42024" or "4th quarter"). 3. **Number Rules**: - 3.3B → 3.3 billion - 150.2M → 150.2 million - 0.33 → keep exact decimal 4. **Text Integrity**: - "net income" never "netincome" - "year-over-year" never "YOY" or "yearoveryear" - "vs." never "versus" or "vs" - "$XB" never "$X billion" - "$XM" never "$X million" 5. **Style Prohibition**: Do not italicize or alter text formatting; maintain one plain format throughout. 6. **Bad Example**: `3.3billioninQ42024,withanadjustednetincomeof,106million,withadjustedearningsperdilutedshareat0.95` → REJECTED 7. **ALWAYS Required Format**: `3.3 billion in Q4 2024, with an adjusted net income of` → ACCEPTED APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.""" prompt_analyze = ( "You are a senior business analyst working directly for Macy's CEO. Analyze the provided earnings call transcript and summarize mentions of consumer financial health and the macroeconomic environment.\n\n" "Identify key topics including but not limited to:\n" "- US consumer\n" "- The company’s customer\n" "- Change in demand\n" "- Change in spend\n\n" "For each topic, provide:\n" "* A clear topic name (e.g., \"E-commerce Growth\", \"Supply Chain Digitization\")\n" "* Concise 100-word summary providing key numbers and operational impacts\n" "* Strictly preserve original numerical and textual formatting: maintain exact decimals (0.33), required spacing between numbers/text (0.11 → '0.11'), and verbatim terminology without concatenation or rephrasing.\n" "* For every topic, ALWAYS provide excerpts mentioned under the heading \"Ground Truth\" as follows:\n" " - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" " - Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" " - If a topic is present in multiple documents, include a separate \"Ground Truth\" excerpt for each document.\n" " - Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the document data exactly, including all formatting, punctuation, and special characters.\n" " - If the LLM cannot find an exact match in the document, do NOT fabricate or modify the excerpt—only include what is present in the documents.\n\n" "Format each topic as:\n" "- Topic Name: Summary [Relevance Score]\n\n" "Document Text:\n" + formatting_directive ) prompt_analyze_tariff_impact = ( "US Politics / Tariffs\n\n" "Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”.\n\n" "The output should be a summary of the commentary, in 100 words or less. The summary should be in the third person (name of the company, management, the company).\n\n" "We do not need recommendations to Macy’s management for this commentary module – only the bulleted summary of the commentary.\n\n" "For every topic, ALWAYS provide excerpts mentioned under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If the topic is present in multiple documents, include a separate \"Ground Truth\" excerpt for each document.\n" "- Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the source exactly, including all formatting, punctuation, and special characters.\n" "- If no exact match exists, do NOT fabricate or modify content.\n\n" "Document Text:\n" + formatting_directive ) prompt_summary = ( "You are a senior tariff and trade analyst preparing a consolidated tariff and trade policy report for Macy's executive team from all documents provided.\n\n" "Identify and describe all impactful tariff, trade, and related government policy topics across the documents provided that could affect Macy's business operations including supply chain, procurement, retail sales, and technology.\n\n" "For each topic:\n" "- Provide a concise summary by combining relevant information from the documents.\n" "- Include relevant financial impacts, examples, figures, or timelines.\n" "- Provide three to five actionable strategic recommendations based on the analysis.\n\n" "For every topic, ALWAYS provide each excerpt mentioned under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If a topic is in multiple documents, include separate excerpts for each document with proper line breaks.\n" "- Do NOT paraphrase or alter any text.\n" "- If no exact excerpts are found, do NOT fabricate or modify content.\n\n" "Format the report in clear markdown with sections:\n" "- Executive Summary\n" "- Key Themes\n" "- Strategic Recommendations\n" "- Risk Assessment\n\n" "STRICTLY ENFORCE PLAIN TEXT FORMATTING:\n" + formatting_directive ) prompt_detail = ( "You are preparing a detailed briefing for Macy's CEO on the tariff and trade policy topic '{topic}', based on the provided external company document.\n\n" "Provide:\n" "1. A clear overview of the topic.\n" "2. Key insights and relevant excerpts.\n" "3. Important figures, dates, or timelines if available.\n" "4. A detailed analysis on how this topic could impact Macy's retail operations, supply chain, procurement, and consumer behavior.\n" "5. Three to five actionable strategic recommendations for Macy's leadership.\n\n" "For every topic, ALWAYS provide verbatim source excerpts under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If a topic is present in multiple documents, include a separate excerpt for each.\n" "- Do NOT paraphrase, summarize, or alter the text.\n" "- If no exact excerpts exist, do NOT fabricate or modify content.\n\n" "Document:\n" "{text}\n\n" "Topic: {topic}\n\n" "Please provide a structured briefing with clear paragraphs and bold topics.\n" + formatting_directive ) def analyze_document(self, text, custom_prompt=None): # Use new analyze prompt for consumer & macro topics by default prompt = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt, text) def analyze_tariff_impact(self, text, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_analyze_tariff_impact return super().analyze_document(self.prompt_sys, prompt, text) def generate_consolidated_summary_from_topics(self, processed_files, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_summary return super().generate_consolidated_summary_from_topics(self.prompt_sys, prompt, processed_files) def generate_topic_detail(self, text, topic, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_detail return super().generate_topic_detail(self.prompt_sys, prompt, text, topic)
Key changes summary:
prompt_analyze→ new senior business analyst-style prompt with requested topics and strict formatting enforcement.prompt_analyze_tariff_impact→ focused prompt only on tariff impact summarization, ≤100 words, 3rd person, no recommendations.- Both prompt contain your requested detailed "Ground Truth" instructions.
- Formatting directive made exact as per your specification with numbering and language.
- Added a new method
analyze_tariff_impactto call the new tariff impact prompt. - Other prompts (
prompt_summary,prompt_detail) unchanged except ensuring strict formatting enforcement is appended consistently.
You can call
analyze_tariff_impact(text)when you want the revised tariff impact commentary summary without recommendations.If you want me to help update the base agent methods to match if any changes needed, just ask!
- User
combine prompt_analyze_tariff_impact and prompt_analyze
- Assistant
Certainly! Below is the combined prompt merging the key elements of your
prompt_analyzeandprompt_analyze_tariff_impactprompts:- The prompt introduces the role as a senior business analyst working for Macy's CEO.
- Focuses on analyzing earnings call transcripts (or documents) for consumer financial health, macroeconomic environment, and specifically US politics/tariffs impact.
- The requested topics include consumer-related topics plus tariff impacts.
- For each topic, provide a clear topic name and succinct (≤100 words) third-person summary with strict formatting.
- For tariff/US politics topic, include the detailed requested substructure: country/regional exposure, quantitative financial impact, mitigation actions (or “N/A” if none).
- For every topic, always include the verbatim "Ground Truth" excerpts exactly as in the original documents.
- Strongly enforce all your formatting rules, explained clearly.
- Format each topic with topic name and summary, plus “Ground Truth” excerpts.
- No recommendations in this analyze prompt (per your instructions).
Combined
prompt_analyze:prompt_analyze = ( "You are a senior business analyst working directly for Macy's CEO. Analyze the provided earnings call transcript or documents and summarize mentions of consumer financial health, the macroeconomic environment, and US politics/tariffs impact.\n\n" "Identify key topics including but not limited to:\n" "- US consumer\n" "- The company’s customer\n" "- Change in demand\n" "- Change in spend\n" "- US politics / tariffs (including any country or regional sourcing exposure, financial impact, and mitigation actions)\n\n" "For each topic, provide:\n" "* A clear topic name (e.g., \"E-commerce Growth\", \"Supply Chain Digitization\", \"US Politics / Tariffs\")\n" "* Concise summary (100 words or less) in the third person (name of the company, management, the company) providing key numbers and operational impacts.\n" "* For the \"US Politics / Tariffs\" topic specifically, lead with any country or regional sourcing exposure, then provide any quantitative financial impact, and finally the mitigation actions already implemented or planned, including pricing changes. If no detail is provided, say “N/A”.\n" "* Strictly preserve original numerical and textual formatting: maintain exact decimals (0.33), required spacing between numbers/text (e.g., '0.11'), and verbatim terminology without concatenation or rephrasing.\n" "* For every topic, ALWAYS provide excerpts mentioned under the heading \"Ground Truth\" as follows:\n" " - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" " - Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" " - If a topic appears in multiple documents, include a separate \"Ground Truth\" excerpt for each document.\n" " - Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match exactly, including all formatting, punctuation, and special characters.\n" " - If no exact match exists, do NOT fabricate or modify excerpt—only include what is present.\n\n" "Format each topic as:\n" "- Topic Name: Summary\n\n" "Document Text:\n" + formatting_directive )
How to integrate it into your existing class
Simply replace the existing
prompt_analyzeattribute with this combined prompt, and remove or archive the separateprompt_analyze_tariff_impactif you want.Example snippet from your class with this update:
class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents" formatting_directive = """...""" # as defined prompt_analyze = ( # (paste combined prompt_analyze from above here) ) # You can remove prompt_analyze_tariff_impact or keep for legacy as needed def analyze_document(self, text, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt, text)
Let me know if you want me to provide the full updated class with this combined prompt or help with any other adjustments!
- User
give me full correct code
- Assistant
Certainly! Below is the full updated
TariffTradeAgentclass code with your combined prompt forprompt_analyze, enforcing all your formatting rules and instructions as requested.from agents.base_agent import BaseAgent class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents" # Universal formatting enforcement line formatting_directive = """STRICTLY ENFORCE PLAIN TEXT FORMATTING: 1. **No Combined Elements**: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion"). 2. **Time Formatting**: Use formats like "Q4 2024" (never "Q42024" or "4th quarter"). 3. **Number Rules**: - 3.3B → 3.3 billion - 150.2M → 150.2 million - 0.33 → keep exact decimal 4. **Text Integrity**: - "net income" never "netincome" - "year-over-year" never "YOY" or "yearoveryear" - "vs." never "versus" or "vs" - "$XB" never "$X billion" - "$XM" never "$X million" 5. **Style Prohibition**: Do not italicize or alter text formatting; maintain one plain format throughout. 6. **Bad Example**: `3.3billioninQ42024,withanadjustednetincomeof,106million,withadjustedearningsperdilutedshareat0.95` → REJECTED 7. **ALWAYS Required Format**: `3.3 billion in Q4 2024, with an adjusted net income of` → ACCEPTED APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.""" prompt_analyze = ( "You are a senior business analyst working directly for Macy's CEO. Analyze the provided earnings call transcript or documents and summarize mentions of consumer financial health, the macroeconomic environment, and US politics/tariffs impact.\n\n" "Identify key topics including but not limited to:\n" "- US consumer\n" "- The company’s customer\n" "- Change in demand\n" "- Change in spend\n" "- US politics / tariffs (including any country or regional sourcing exposure, financial impact, and mitigation actions)\n\n" "For each topic, provide:\n" "* A clear topic name (e.g., \"E-commerce Growth\", \"Supply Chain Digitization\", \"US Politics / Tariffs\")\n" "* Concise summary (100 words or less) in the third person (name of the company, management, the company) providing key numbers and operational impacts.\n" "* For the \"US Politics / Tariffs\" topic specifically, lead with any country or regional sourcing exposure, then provide any quantitative financial impact, and finally the mitigation actions already implemented or planned, including pricing changes. If no detail is provided, say “N/A”.\n" "* Strictly preserve original numerical and textual formatting: maintain exact decimals (0.33), required spacing between numbers/text (e.g., '0.11'), and verbatim terminology without concatenation or rephrasing.\n" "* For every topic, ALWAYS provide excerpts mentioned under the heading \"Ground Truth\" as follows:\n" " - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" " - Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" " - If a topic appears in multiple documents, include a separate \"Ground Truth\" excerpt for each document.\n" " - Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match exactly, including all formatting, punctuation, and special characters.\n" " - If no exact match exists, do NOT fabricate or modify excerpt—only include what is present.\n\n" "Format each topic as:\n" "- Topic Name: Summary\n\n" "Document Text:\n" + formatting_directive ) prompt_summary = ( "You are a senior tariff and trade analyst preparing a consolidated tariff and trade policy report for Macy's executive team from all documents provided.\n\n" "Identify and describe all impactful tariff, trade, and related government policy topics across the documents provided that could affect Macy's business operations including supply chain, procurement, retail sales, and technology.\n\n" "For each topic:\n" "- Provide a concise summary by combining relevant information from the documents.\n" "- Include relevant financial impacts, examples, figures, or timelines.\n" "- Provide three to five actionable strategic recommendations based on the analysis.\n\n" "For every topic, ALWAYS provide each excerpt mentioned under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If a topic is in multiple documents, include separate excerpts for each document with proper line breaks.\n" "- Do NOT paraphrase or alter any text.\n" "- If no exact excerpts are found, do NOT fabricate or modify content.\n\n" "Format the report in clear markdown with sections:\n" "- Executive Summary\n" "- Key Themes\n" "- Strategic Recommendations\n" "- Risk Assessment\n\n" "STRICTLY ENFORCE PLAIN TEXT FORMATTING:\n" + formatting_directive ) prompt_detail = ( "You are preparing a detailed briefing for Macy's CEO on the tariff and trade policy topic '{topic}', based on the provided external company document.\n\n" "Provide:\n" "1. A clear overview of the topic.\n" "2. Key insights and relevant excerpts.\n" "3. Important figures, dates, or timelines if available.\n" "4. A detailed analysis on how this topic could impact Macy's retail operations, supply chain, procurement, and consumer behavior.\n" "5. Three to five actionable strategic recommendations for Macy's leadership.\n\n" "For every topic, ALWAYS provide verbatim source excerpts under the heading \"Ground Truth\" as follows:\n" "- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n" "- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" "- If a topic is present in multiple documents, include a separate excerpt for each.\n" "- Do NOT paraphrase, summarize, or alter the text.\n" "- If no exact excerpts exist, do NOT fabricate or modify content.\n\n" "Document:\n" "{text}\n\n" "Topic: {topic}\n\n" "Please provide a structured briefing with clear paragraphs and bold topics.\n" + formatting_directive ) def analyze_document(self, text, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt, text) def generate_consolidated_summary_from_topics(self, processed_files, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_summary return super().generate_consolidated_summary_from_topics(self.prompt_sys, prompt, processed_files) def generate_topic_detail(self, text, topic, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_detail return super().generate_topic_detail(self.prompt_sys, prompt, text, topic)
Explanation
- The
prompt_analyzenow incorporates both consumer/macro topics and US politics / tariffs under a unified prompt. - For the “US Politics / Tariffs” topic, the instructions explicitly ask to lead with sourcing exposure, then financial impact, then mitigation actions or “N/A” if none.
- Every topic summary is to be ≤100 words, in the third person.
- All strict formatting rules are enforced via the
formatting_directive. - The
Ground Truthextraction instructions are explicit and require exact excerpts from the documents. - Recommendation output has been removed from this analysis prompt per your instruction (recommendations remain only in the summary and detail modules).
- The method
analyze_documentuses this updatedprompt_analyzeby default, but an override is still possible viacustom_prompt.
If you want me to also update or include a specific method to analyze only tariffs separately using this prompt, or integrate this prompt into some other part of your workflow, just let me know!
- The
- User
my prompt analyze is not working and giving as topics
can you correct that below was the example how earlier i was able to get the topics
from agents.base_agent import BaseAgent
class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents"
# Universal formatting enforcement line formatting_directive = """Please follow these formatting guidelines:- No Combined Elements: Always space-separate numbers/words/units (3.3 billion not 3.3billion)
- Time Formatting: Q4 2024 (never Q42024 or 4th quarter)
- Number Rules:
- 3.3B → 3.3 billion
- 150.2M → 150.2 million
- 0.33 → keep exact decimal
- Text Integrity:
- "net income" never "netincome"
- "year-over-year" never "YOY" or "yearoveryear"
- Style Prohibition: Do not make any word in Italic or any other format always make it in one format
- Bad Example: 3.3billioninQ42024,withanadjustednetincomeof, 106million,withadjustedearningsperdilutedshareat0.95 → REJECTED
- ALWAYS Required Format: 3.3 billion in Q4 2024, with an adjusted net income of → ACCEPTED
APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES."""
prompt_analyze = """You are a senior tariff and international trade policy analyst assisting a research team working for the CEO of Macy's.
You have received a transcript/document from another company.Carefully identify all significant tariff, trade, and related government policy topics and detailed briefing in the text of all files that could affect Macy's business operations, including supply chain, procurement, retail sales, and technology.
For each topic, provide:
- A clear and concise topic name (e.g., "Vietnam Production Impact", "US-China Tariffs").
- A brief describing in 200 words including its operational or strategic impact on Macy's retail business, considering the external company's context also include A clear overview of the topic, Key insights and any relevant direct excerpts from the document, Important figures, dates, or timelines if available, Detailed analysis on how this topic could impact Macy's retail operations, supply chain, procurement, and consumer behavior.
- A relevance score from 1 (minor) to 10 (critical).
- For every topic, ALWAYS provide verbatim source excerpts under the heading "Source Truth" as follows: - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document. - Format each excerpt as: Source Truth: "Exact text from the document..." (Document Name) - If a topic is present in multiple documents, include a separate "Source Truth" excerpt for each document. - Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the source exactly, including all formatting, punctuation, and special characters. - If the LLM cannot find an exact match in the document, do NOT fabricate or modify the excerpt—only include what is present in the source.
Format your response as one topic per line in the format from all files:
- Topic Name: Summary [Relevance Score]
Example:
- Vietnam Factory Shutdown: Supply chain delays expected due to production halt in Vietnam [9]
- Tariff Changes on Apparel: Increased costs on imports from China may raise prices [8]
Analyze the following external company document for all relevant tariff and trade topics. Text:""" + formatting_directive
prompt_summary = """You are a senior tariff and trade analyst preparing a consolidated tariff and trade policy report for Macy's executive team from all document provided.
You have reviewed tariff and trade topics extracted from multiple external company documents. These topics include their names, summaries, and relevance scores. Based on their content, please:
-
OverView: Identify and describe from all documents all their impactful tariff, trade, and related government policy topics that could affect Macy's business operations, including supply chain, procurement, retail sales, and technology.
-
For each topic:
- Provide a concise summary from combining all the documents.
- Include relevant examples, numerical data, or timelines from the documents also provide from which document it is taken.
- Explain operational and strategic impacts—positive, negative, or neutral—specifically tailored to Macy's retail business.
- Provide 3-5 actionable strategic recommendations for Macy's leadership.
- For every topic, ALWAYS provide each verbatim source excerpts under the heading "Ground Truth" as follows:
- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.
- Format each excerpt as: Ground Truth: "Exact text from the document..." (Document Name)
- If a topic is present in multiple documents, include a separate "Ground Truth" excerpt for each document with proper line breaks.
- Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the source exactly, including all formatting, punctuation, and special characters.
- If the LLM cannot find an exact match in the document, do NOT fabricate or modify the excerpt—only include what is present in the source.
-
Format in clear markdown with sections in black text with proper headings:
- Executive Summary
- Key Themes
- Strategic Recommendations
- Risk Assessment
-
Avoid jargon and focus on practical operational impacts and strategy insights.
Format your response in markdown with clear headings for each topic.
Use the following Documents Analysis Data to combine similar topics from different documents and provide a comprehensive summary: {topics_block}
Deliver a detailed, synthesized, and actionable consolidated tariff and trade policy report for Macy's.""" + formatting_directive
prompt_detail = """You are preparing a detailed briefing for Macy's CEO on the tariff and trade policy topic '{topic}', based on the provided external company document.
Provide:
- A clear overview of the topic.
- Allways Provide Key insights and relevant excerpts.- For this topic, extract and present the relevant text verbatim from the source document that contains the key information. Ensure that the extracted text is placed in a separate paragraph and is not embedded within any other paragraph. Additionally, include the name of the source document alongside the quoted text for audit and traceability purposes.
- Important figures, dates, or timelines if available.
- Detailed analysis on how this topic could impact Macy's retail operations, supply chain, procurement, and consumer behavior.
- 3-5 actionable strategic recommendations for Macy's leadership. 6 For every topic, ALWAYS provide verbatim source excerpts under the heading "Ground Truth" as follows: - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document. - Format each excerpt as: Ground Truth: "Exact text from the document..." (Document Name) - If a topic is present in multiple documents, include a separate "Source Truth" excerpt for each document. - Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the source exactly, including all formatting, punctuation, and special characters. - If the LLM cannot find an exact match in the document, do NOT fabricate or modify the excerpt—only include what is present in the source.
Document: {text}
Topic: {topic}
Please deliver the response as structured with proper paragraphs and bold topics which suitable for executive briefing.""" + formatting_directive
def analyze_document(self, text, custom_prompt=None): prompt_analyze = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt_analyze, text) def generate_consolidated_summary_from_topics(self, processed_files, custom_prompt=None): prompt_summary = custom_prompt if custom_prompt else self.prompt_summary return super().generate_consolidated_summary_from_topics(self.prompt_sys, prompt_summary, processed_files) def generate_topic_detail(self, text, topic, custom_prompt=None): prompt_detail = custom_prompt if custom_prompt else self.prompt_detail return super().generate_topic_detail(self.prompt_sys, prompt_detail, text, topic) - Assistant
Got it! Your earlier working prompt is structured to extract topics as discrete lines with relevance scores, and you want summaries with topic lines rather than generic summaries. Your merged prompt was more of a "summarize all topics in paragraphs" style, losing that format.
To fix this:
- You must format the prompt so that the LLM enumerates all discovered topics as lines with the format:
- Topic Name: Summary [Relevance Score]- Provide explicit instruction to list all topics found as lines, not paragraphs.
- Keep strict "Ground Truth" excerpt instructions.
- Keep the formatting directive attached.
- For
prompt_analyze, include tariff/US politics as a topic to find, but maintain this output format.
Here is an example of a corrected
prompt_analyzeyou can replace your current one with, that combines your earlier working style with your merged tariff instructions — and that should return the topics as discrete lines:prompt_analyze = """ You are a senior business analyst working directly for Macy's CEO. You have received a transcript or document from an external company. Carefully identify all significant topics related to consumer financial health, the macroeconomic environment, and US politics / tariffs impacting Macy's business operations, including supply chain, procurement, retail sales, and technology. For each topic, provide: - A clear and concise topic name (e.g., "US Consumer Spending Trends", "E-commerce Growth", "US Politics / Tariffs"). - A brief summary in 100 words or less, in the third person (e.g., the company, management), highlighting key numbers, operational impacts, and for "US Politics / Tariffs", lead with any country or regional sourcing exposure, then quantitative financial impact, then mitigation actions including pricing changes. If no detail is provided, say “N/A”. - A relevance score from 1 (minor) to 10 (critical). * For every topic, ALWAYS provide verbatim source excerpts under the heading "Ground Truth" as follows: - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document. - Format each excerpt as: **Ground Truth:** "Exact text from the document..." (Document Name) - If a topic is present in multiple documents, include a separate "Ground Truth" excerpt for each document. - Do NOT paraphrase, summarize, or alter the original text in any way. Format your response as one topic per line, exactly like this: - Topic Name: Summary [Relevance Score] Example: - Holiday Sales Performance: Q4 comparable sales up 4.2% driven by 18% digital growth [8] - US Politics / Tariffs: The company sources 40% of products from China, tariffs increased costs by 150 million in Q3 2023, mitigation includes raising prices by 3%. [9] Document Text: """ + formatting_directive
Updated full class example with this prompt:
from agents.base_agent import BaseAgent class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents" formatting_directive = """STRICTLY ENFORCE PLAIN TEXT FORMATTING: 1. **No Combined Elements**: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion"). 2. **Time Formatting**: Use formats like "Q4 2024" (never "Q42024" or "4th quarter"). 3. **Number Rules**: - 3.3B → 3.3 billion - 150.2M → 150.2 million - 0.33 → keep exact decimal 4. **Text Integrity**: - "net income" never "netincome" - "year-over-year" never "YOY" or "yearoveryear" - "vs." never "versus" or "vs" - "$XB" never "$X billion" - "$XM" never "$X million" 5. **Style Prohibition**: Do not italicize or alter text formatting; maintain one plain format throughout. 6. **Bad Example**: `3.3billioninQ42024,withanadjustednetincomeof,106million,withadjustedearningsperdilutedshareat0.95` → REJECTED 7. **ALWAYS Required Format**: `3.3 billion in Q4 2024, with an adjusted net income of` → ACCEPTED APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.""" prompt_analyze = """ You are a senior business analyst working directly for Macy's CEO. You have received a transcript or document from an external company. Carefully identify all significant topics related to consumer financial health, the macroeconomic environment, and US politics / tariffs impacting Macy's business operations, including supply chain, procurement, retail sales, and technology. For each topic, provide: - A clear and concise topic name (e.g., "US Consumer Spending Trends", "E-commerce Growth", "US Politics / Tariffs"). - A brief summary in 100 words or less, in the third person (e.g., the company, management), highlighting key numbers, operational impacts, and for "US Politics / Tariffs", lead with any country or regional sourcing exposure, then quantitative financial impact, then mitigation actions including pricing changes. If no detail is provided, say “N/A”. - A relevance score from 1 (minor) to 10 (critical). * For every topic, ALWAYS provide verbatim source excerpts under the heading "Ground Truth" as follows: - For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document. - Format each excerpt as: **Ground Truth:** "Exact text from the document..." (Document Name) - If a topic is present in multiple documents, include a separate "Ground Truth" excerpt for each document. - Do NOT paraphrase, summarize, or alter the original text in any way. Format your response as one topic per line, exactly like this: - Topic Name: Summary [Relevance Score] Example: - Holiday Sales Performance: Q4 comparable sales up 4.2% driven by 18% digital growth [8] - US Politics / Tariffs: The company sources 40% of products from China, tariffs increased costs by 150 million in Q3 2023, mitigation includes raising prices by 3%. [9] Document Text: """ + formatting_directive prompt_summary = """ # (keep your existing prompt_summary here unchanged, or update per need) """ + formatting_directive prompt_detail = """ # (keep your existing prompt_detail here unchanged, or update per need) """ + formatting_directive def analyze_document(self, text, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt, text) def generate_consolidated_summary_from_topics(self, processed_files, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_summary return super().generate_consolidated_summary_from_topics(self.prompt_sys, prompt, processed_files) def generate_topic_detail(self, text, topic, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_detail return super().generate_topic_detail(self.prompt_sys, prompt, text, topic)
Why this works:
- The prompt explicitly instructs returning a list of topics as lines.
- Each line follows your required topical format with relevance score.
- This lines-based output is what you relied on before and what your post-processing logic expects.
- Maintains your strict formatting and exact excerpt instructions.
- Includes your requested tariff topic structure in the summary, still concise and structured.
- Keeps the output deterministic and easy to parse.
If needed, I can also help with a few example outputs or how to post-process the output to extract topics cleanly. Let me know!
- User
but we need to focus on this only US Politics / Tariffs Prompt: Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”.
- Assistant
Understood. You want a focused prompt just on the "US Politics / Tariffs" topic with the specific instructions you gave, but you want the output in the same topic-per-line format with relevance score and Ground Truth excerpts, no extraneous topics.
Here’s how you can implement that — a prompt that instructs the LLM to:
- ONLY produce a single topic: US Politics / Tariffs.
- Summarize tariff impact per your exact instructions.
- Provide verbatim excerpts under “Ground Truth”.
- Format as a single line topic summary with relevance score.
- Enforce your strict formatting rules.
The focused
prompt_analyzefor only US Politics / Tariffs topic:prompt_analyze = """ You are a senior business analyst working directly for Macy’s CEO. Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”. The output must be a single topic summary: - Topic Name: US Politics / Tariffs - Summary in 100 words or less, in third person (the company, management), strictly following all formatting rules below. - Assign a relevance score from 1 (minor) to 10 (critical). * ALWAYS provide verbatim source excerpts under the heading “Ground Truth” as follows: - Extract the exact, unmodified sentence(s) or paragraph(s) from the original document where the tariff topic appears. - Format each excerpt as: **Ground Truth:** "Exact text from the document..." (Document Name) - If multiple documents contain the topic, include separate excerpts. - Do NOT paraphrase or alter text. Format your entire response exactly as: - US Politics / Tariffs: Summary [Relevance Score] **Ground Truth:** "Exact text from the document..." (Document Name) (Additional Ground Truth excerpts if relevant) STRICTLY ENFORCE PLAIN TEXT FORMATTING: 1. **No Combined Elements**: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion"). 2. **Time Formatting**: Use formats like "Q4 2024" (never "Q42024" or "4th quarter"). 3. **Number Rules**: - 3.3B → 3.3 billion - 150.2M → 150.2 million - 0.33 → keep exact decimal 4. **Text Integrity**: - "net income" never "netincome" - "year-over-year" never "YOY" or "yearoveryear" 5. **Style Prohibition**: Do not italicize or change any text formatting; maintain plain format. 6. **Bad Example**: `3.3billioninQ42024,withanadjustednetincomeof106million` → REJECTED 7. **Required Format**: `3.3 billion in Q4 2024, with an adjusted net income of` → ACCEPTED APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES. Document Text: """ + formatting_directive
Full class integration snippet:
from agents.base_agent import BaseAgent class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents" formatting_directive = """STRICTLY ENFORCE PLAIN TEXT FORMATTING: 1. **No Combined Elements**: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion"). 2. **Time Formatting**: Use formats like "Q4 2024" (never "Q42024" or "4th quarter"). 3. **Number Rules**: - 3.3B → 3.3 billion - 150.2M → 150.2 million - 0.33 → keep exact decimal 4. **Text Integrity**: - "net income" never "netincome" - "year-over-year" never "YOY" or "yearoveryear" 5. **Style Prohibition**: Do not italicize or change any text formatting; maintain plain format. 6. **Bad Example**: `3.3billioninQ42024,withanadjustednetincomeof106million` → REJECTED 7. **Required Format**: `3.3 billion in Q4 2024, with an adjusted net income of` → ACCEPTED APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.""" prompt_analyze = """ You are a senior business analyst working directly for Macy’s CEO. Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”. The output must be a single topic summary: - Topic Name: US Politics / Tariffs - Summary in 100 words or less, in third person (the company, management), strictly following all formatting rules below. - Assign a relevance score from 1 (minor) to 10 (critical). * ALWAYS provide verbatim source excerpts under the heading “Ground Truth” as follows: - Extract the exact, unmodified sentence(s) or paragraph(s) from the original document where the tariff topic appears. - Format each excerpt as: **Ground Truth:** "Exact text from the document..." (Document Name) - If multiple documents contain the topic, include separate excerpts. - Do NOT paraphrase or alter text. Format your entire response exactly as: - US Politics / Tariffs: Summary [Relevance Score] **Ground Truth:** "Exact text from the document..." (Document Name) (Additional Ground Truth excerpts if relevant) STRICTLY ENFORCE PLAIN TEXT FORMATTING: 1. **No Combined Elements**: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion"). 2. **Time Formatting**: Use formats like "Q4 2024" (never "Q42024" or "4th quarter"). 3. **Number Rules**: - 3.3B → 3.3 billion - 150.2M → 150.2 million - 0.33 → keep exact decimal 4. **Text Integrity**: - "net income" never "netincome" - "year-over-year" never "YOY" or "yearoveryear" 5. **Style Prohibition**: Do not italicize or change any text formatting; maintain plain format. 6. **Bad Example**: `3.3billioninQ42024,withanadjustednetincomeof106million` → REJECTED 7. **Required Format**: `3.3 billion in Q4 2024, with an adjusted net income of` → ACCEPTED APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES. Document Text: """ + formatting_directive def analyze_document(self, text, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt, text)
Usage
Call the
analyze_document(text)method with a document to get a single, well-structured summary and excerpts on just the US Politics / Tariffs topic formatted exactly as you want.
If you want, I can help with example outputs or integration with other methods or with handling fallback when no tariff info exists. Just ask!
- User
prompt_analyze = """ You are a senior business analyst working directly for Macy’s CEO.
Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”.
The output must be a single topic summary:
- Topic Name: US Politics / Tariffs
- Summary in 100 words or less, in third person (the company, management), strictly following all formatting rules below.
- Assign a relevance score from 1 (minor) to 10 (critical).
- ALWAYS provide verbatim source excerpts under the heading “Ground Truth” as follows:
- Extract the exact, unmodified sentence(s) or paragraph(s) from the original document where the tariff topic appears.
- Format each excerpt as: Ground Truth: "Exact text from the document..." (Document Name)
- If multiple documents contain the topic, include separate excerpts.
- Do NOT paraphrase or alter text.
Format your entire response exactly as:
- US Politics / Tariffs: Summary [Relevance Score]
Ground Truth: "Exact text from the document..." (Document Name)
(Additional Ground Truth excerpts if relevant)
STRICTLY ENFORCE PLAIN TEXT FORMATTING:
- No Combined Elements: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion").
- Time Formatting: Use formats like "Q4 2024" (never "Q42024" or "4th quarter").
- Number Rules:
- 3.3B → 3.3 billion
- 150.2M → 150.2 million
- 0.33 → keep exact decimal
- Text Integrity:
- "net income" never "netincome"
- "year-over-year" never "YOY" or "yearoveryear"
- Style Prohibition: Do not italicize or change any text formatting; maintain plain format.
- Bad Example:
3.3billioninQ42024,withanadjustednetincomeof106million→ REJECTED - Required Format:
3.3 billion in Q4 2024, with an adjusted net income of→ ACCEPTED
APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.
Document Text: """ + formatting_directive
this was the tarrif one but not giving me topics it is summarizing it make it as below take as an example do not copy paste
prompt_analyze = ( "You are a senior monthly performance analyst specializing in analyzing Macy's retail sales for February, March, and April. " "You have received a transcript/document from another company.\n\n" "Identify all significant sales performance topics that could affect Macy's monthly sales reporting, revenue trends, and operational effectiveness for the months of February, March, and April.\n\n" "For each topic, provide:\n" "- A concise topic name (e.g., "February Sales Growth", "April Marketing Impact").\n" "- A brief 200-word description including relevance or impact on Macy's monthly sales performance, covering: overview of the topic, key insights, important figures/dates/timelines (specific to Feb, Mar, Apr), and detailed impact analysis.\n" "- A relevance score from 1 (minor) to 10 (critical).\n\n" "Format your response one topic per line:\n" "- Topic Name: Summary [Relevance Score]\n\n" "Example:\n" "- February Sales Performance: Comparable sales grew 5.2% driven by strong digital channel growth [8]\n" "- March Marketing Campaign: New campaigns boosted foot traffic by 15% [7]\n\n" "Analyze the following external company document:" + formatting_directive )
- Assistant
Thanks for the clarification! You want your tariff prompt to identify topics explicitly as topic lines (with relevance scores), not just a plain summary. Let's model your tariff prompt exactly in the style of your sales analyst example — with:
- Identification of topics (here, focused on US Politics / Tariffs)
- Output of one topic per line:
- Topic Name: Summary [Relevance Score] - Full formatting and extraction guidance.
Here is the modified tariff prompt in that style:
prompt_analyze = ( "You are a senior tariff and trade analyst for Macy's CEO.\n\n" "Carefully identify all significant tariff and trade policy topics impacting Macy's business operations, especially US Politics / Tariffs.\n\n" "For each topic, provide:\n" "- A concise topic name (e.g., \"US Politics / Tariffs\").\n" "- A brief summary in 100 words or less in third person (the company, management), covering: country or regional sourcing exposure where applicable, any quantitative financial impact if provided, and mitigation actions (such as pricing changes). If no details are available, say “N/A.”\n" "- A relevance score from 1 (minor) to 10 (critical).\n\n" "Format your response as one topic per line:\n" "- Topic Name: Summary [Relevance Score]\n\n" "Example:\n" "- US Politics / Tariffs: The company sources 40% of products from China, tariffs added 150 million in costs in Q3 2023, mitigation includes 3% price increases. [9]\n\n" "* ALWAYS provide verbatim source excerpts under the heading \"Ground Truth\" as follows:\n" " - For each document where the topic appears, extract the exact unmodified sentence(s) or paragraph(s) from the document.\n" " - Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" " - If the topic is present in multiple documents, include separate excerpts.\n" " - Do NOT paraphrase or alter the text.\n\n" "STRICTLY ENFORCE PLAIN TEXT FORMATTING:\n" "1. No combined elements: always space-separate numbers, words, and units (e.g., \"3.3 billion\" not \"3.3billion\").\n" "2. Time format: use \"Q4 2024\" (never \"Q42024\" or \"4th quarter\").\n" "3. Number rules:\n" " - 3.3B → 3.3 billion\n" " - 150.2M → 150.2 million\n" " - 0.33 → keep exact decimal\n" "4. Text integrity:\n" " - \"net income\" never \"netincome\"\n" " - \"year-over-year\" never \"YOY\" or \"yearoveryear\"\n" "5. Style prohibition: Do not italicize or alter any text formatting.\n" "6. Bad example: `3.3billioninQ42024,withanadjustednetincomeof106million` REJECTED.\n" "7. Required format: `3.3 billion in Q4 2024, with an adjusted net income of` ACCEPTED.\n\n" "APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.\n\n" "Document Text:\n" + formatting_directive )
How to integrate:
Replace your existing
prompt_analyzewith this in your class. It will prompt the model to produce one or more topics (including the key US Politics / Tariffs topic if present), each as a single line with summary and relevance score, and then the ground truth excerpts as instructed.
Optional snippet for your class:
class TariffTradeAgent(BaseAgent): prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents" formatting_directive = """STRICTLY ENFORCE PLAIN TEXT FORMATTING: 1. No combined elements: always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion"). 2. Time format: use "Q4 2024" (never "Q42024" or "4th quarter"). 3. Number rules: - 3.3B → 3.3 billion - 150.2M → 150.2 million - 0.33 → keep exact decimal 4. Text integrity: - "net income" never "netincome" - "year-over-year" never "YOY" or "yearoveryear" 5. Style prohibition: Do not italicize or alter any text formatting. 6. Bad example: `3.3billioninQ42024,withanadjustednetincomeof106million` REJECTED. 7. Required format: `3.3 billion in Q4 2024, with an adjusted net income of` ACCEPTED. APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES.""" prompt_analyze = ( "You are a senior tariff and trade analyst for Macy's CEO.\n\n" "Carefully identify all significant tariff and trade policy topics impacting Macy's business operations, especially US Politics / Tariffs.\n\n" "For each topic, provide:\n" "- A concise topic name (e.g., \"US Politics / Tariffs\").\n" "- A brief summary in 100 words or less in third person (the company, management), covering: country or regional sourcing exposure where applicable, any quantitative financial impact if provided, and mitigation actions (such as pricing changes). If no details are available, say “N/A.”\n" "- A relevance score from 1 (minor) to 10 (critical).\n\n" "Format your response as one topic per line:\n" "- Topic Name: Summary [Relevance Score]\n\n" "Example:\n" "- US Politics / Tariffs: The company sources 40% of products from China, tariffs added 150 million in costs in Q3 2023, mitigation includes 3% price increases. [9]\n\n" "* ALWAYS provide verbatim source excerpts under the heading \"Ground Truth\" as follows:\n" " - For each document where the topic appears, extract the exact unmodified sentence(s) or paragraph(s) from the document.\n" " - Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n" " - If the topic is present in multiple documents, include separate excerpts.\n" " - Do NOT paraphrase or alter the text.\n\n" + formatting_directive + "\n" "Document Text:\n" + formatting_directive ) def analyze_document(self, text, custom_prompt=None): prompt = custom_prompt if custom_prompt else self.prompt_analyze return super().analyze_document(self.prompt_sys, prompt, text)
Summary
- This prompt closely mirrors your working earlier prompt style, but tailored for tariff topics.
- The model will respond with lines per topic with relevance scores, rather than a generic paragraph summary.
- Ground truth excerpts are included exactly.
- Strict formatting is enforced.
Try this out, and if you want me to help tune it further (including examples or post-processing tips), just ask!