Add Google Financial News Analysis Prompt Generator#49
Conversation
This commit adds a python script `Finance/generate_news_prompt.py` which generates a structured prompt for analyzing financial news. It accepts command line arguments for keyword, time range, region, and focus area. It also includes a unit test `Finance/test_generate_news_prompt.py`. 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 Python module and test file to generate prompts for Google Financial News Analysis. The module provides both a function API and a command-line interface for generating structured prompts in Chinese that can be used with AI assistants to analyze financial news.
Changes:
- Added
Finance/generate_news_prompt.pywith agenerate_prompt()function and CLI interface - Added
Finance/test_generate_news_prompt.pywith basic unit tests using unittest framework
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 | Implements prompt generation with a Chinese-language template for financial news analysis, includes argparse for CLI usage |
| Finance/test_generate_news_prompt.py | Provides basic unittest coverage for the generate_prompt function with Chinese text inputs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,106 @@ | |||
| import argparse | |||
|
|
|||
| def generate_prompt(keyword: str, time_range: str, region: str, focus: str) -> str: | |||
There was a problem hiding this comment.
The function lacks input validation. Consider adding checks to ensure that keyword, time_range, region, and focus are not empty strings or None values. Empty or None inputs would result in incomplete prompts that may not be useful for the intended purpose.
| def generate_prompt(keyword: str, time_range: str, region: str, focus: str) -> str: | |
| def generate_prompt(keyword: str, time_range: str, region: str, focus: str) -> str: | |
| # Basic input validation to avoid generating incomplete or low-quality prompts | |
| for name, value in (("keyword", keyword), | |
| ("time_range", time_range), | |
| ("region", region), | |
| ("focus", focus)): | |
| if not isinstance(value, str) or not value.strip(): | |
| raise ValueError(f"{name} must be a non-empty string") |
| def test_generate_prompt(self): | ||
| keyword = "Tesla" | ||
| time_range = "7 天" | ||
| region = "全球" | ||
| focus = "市場波動" | ||
|
|
||
| prompt = generate_news_prompt.generate_prompt(keyword, time_range, region, focus) | ||
|
|
||
| self.assertIn(f"查詢關鍵字:{keyword}", prompt) | ||
| self.assertIn(f"時間範圍:{time_range}", prompt) | ||
| self.assertIn(f"地區(可選):{region}", prompt) | ||
| self.assertIn(f"關注面向:{focus}", prompt) |
There was a problem hiding this comment.
The test only verifies that specific strings are present in the output but doesn't test edge cases or invalid inputs. Consider adding test cases for: empty string inputs, None values, special characters in inputs, very long inputs, and verifying the actual structure and formatting of the generated prompt beyond simple string presence checks.
| self.assertIn(f"地區(可選):{region}", prompt) | ||
| self.assertIn(f"關注面向:{focus}", prompt) | ||
|
|
||
| self.assertIn("Google 財經新聞分析 Prompt(專業版)", prompt) |
There was a problem hiding this comment.
The test only covers the generate_prompt function but doesn't test the command-line interface (the argparse functionality and main execution block). Consider adding a test that verifies the ArgumentParser correctly handles command-line arguments, including the required --keyword argument and the optional arguments with their default values.
Added
Finance/generate_news_prompt.pyto generate prompts for Google Financial News Analysis based on user input. Included a test scriptFinance/test_generate_news_prompt.py.PR created automatically by Jules for task 257007181494074076 started by @ewdlop