Add Google Financial News Analysis Prompt Generator#43
Conversation
- Created `Finance/generate_news_prompt.py`: A CLI tool to generate a structured financial news analysis prompt based on user inputs. - Created `Finance/test_generate_news_prompt.py`: Unit tests for the prompt generator. - The prompt is designed for professional, neutral, and fact-oriented financial analysis. Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR adds a reusable Python-based generator for the “Google Financial News Analysis” prompt plus basic unit tests, enabling both programmatic and CLI-driven creation of the prompt with customizable parameters.
Changes:
- Implemented
generate_news_prompt.pywith a formatted prompt template and an argparse-based CLI that accepts keyword, time range, region, and focus area. - Added
test_generate_news_prompt.pyto verify default and custom parameter substitution and to check that key structural sections of the prompt are present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Finance/generate_news_prompt.py | Defines the financial news analysis prompt template, parameterized by keyword, time range, region, and focus, and exposes a CLI entry point. |
| Finance/test_generate_news_prompt.py | Provides unit tests to validate prompt content for default/custom arguments and ensure core structural sections appear in the generated prompt. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,117 @@ | |||
| import argparse | |||
| import sys | |||
There was a problem hiding this comment.
sys is imported but never used in this module, which adds unnecessary clutter; consider removing the unused import to keep the script clean and avoid lint warnings.
| import sys |
| def generate_prompt(keyword, time_range="7 天", region="全球", focus="宏觀經濟"): | ||
| return PROMPT_TEMPLATE.format( | ||
| keyword=keyword, | ||
| time_range=time_range, | ||
| region=region, | ||
| focus=focus | ||
| ) | ||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser(description="Generate Google Financial News Prompt") | ||
| parser.add_argument("keyword", help="查詢關鍵字") | ||
| parser.add_argument("--time_range", default="7 天", help="時間範圍") | ||
| parser.add_argument("--region", default="全球", help="地區") | ||
| parser.add_argument("--focus", default="宏觀經濟", help="關注面向") |
There was a problem hiding this comment.
The default values for time_range, region, and focus are duplicated between the generate_prompt function signature and the argparse add_argument(..., default=...) calls, which can drift out of sync if one is changed without the other; it would be more maintainable to define these defaults in a single place and have both the function and CLI reuse them.
| import os | ||
|
|
||
| # Add the directory containing the script to sys.path | ||
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) |
There was a problem hiding this comment.
Using sys.path.append(...) means the test directory is added to the end of sys.path, so if there is an installed module named generate_news_prompt elsewhere, the tests may import that module instead of the local file; using sys.path.insert(0, ...) (or another approach that prefers the local path) would ensure the tests actually cover this script.
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) |
Implemented a Python script to generate the "Google Financial News Analysis" prompt as requested. The script accepts CLI arguments for keyword, time range, region, and focus area, and outputs the filled-in prompt. Included unit tests to verify functionality.
PR created automatically by Jules for task 16652745256423206052 started by @ewdlop