Skip to content

Add Google Financial News Analysis Prompt Generator#49

Open
ewdlop wants to merge 1 commit intomainfrom
add-finance-news-prompt-generator-257007181494074076
Open

Add Google Financial News Analysis Prompt Generator#49
ewdlop wants to merge 1 commit intomainfrom
add-finance-news-prompt-generator-257007181494074076

Conversation

@ewdlop
Copy link
Owner

@ewdlop ewdlop commented Feb 6, 2026

Added Finance/generate_news_prompt.py to generate prompts for Google Financial News Analysis based on user input. Included a test script Finance/test_generate_news_prompt.py.


PR created automatically by Jules for task 257007181494074076 started by @ewdlop

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>
Copilot AI review requested due to automatic review settings February 6, 2026 04:34
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py with a generate_prompt() function and CLI interface
  • Added Finance/test_generate_news_prompt.py with 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:
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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")

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +22
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)
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
self.assertIn(f"地區(可選):{region}", prompt)
self.assertIn(f"關注面向:{focus}", prompt)

self.assertIn("Google 財經新聞分析 Prompt(專業版)", prompt)
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants