-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
45 lines (41 loc) · 1.84 KB
/
Copy pathutils.py
File metadata and controls
45 lines (41 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Utility methods - mostly prompt builders for different stages of the Sentibot pipeline
"""
def topic_namer_prompt_builder(sample_titles):
return (
"The following news article headlines belong to the same topic group.\n"
"Give this group a short, descriptive name.\n"
"Return ONLY the topic name, nothing else.\n\n"
f"Headlines:\n{sample_titles}\n\n"
"Topic name:"
)
def facts_and_tickers_extractor_prompt_builder(title, text):
return (
"You are a financial news analyst. Read the article below and return TWO things:\n\n"
"1. FACTS: 2-3 bullet points of key verifiable facts "
"(numbers, names, decisions, market movements, outcomes). No opinions.\n"
"2. TICKERS: A comma-separated list of stock ticker symbols mentioned or implied "
"(e.g. AAPL, MSFT). Infer the ticker from company names. Write NONE if none found.\n\n"
"Use exactly this format:\n"
"FACTS:\n- fact one\n- fact two\nTICKERS: AAPL, MSFT\n\n"
f"Title: {title}\n"
f"Article: {text[:2000]}\n\n"
"Response:"
)
def topic_summariser_prompt_builder(group_name, corpus):
return (
f"You are a financial news analyst summarising the '{group_name}' topic.\n"
"Write a detailed 6-7 sentence summary of the key developments below.\n"
"Focus on market impact, decisions, and outcomes. Be factual.\n\n"
f"Articles:\n{corpus}\n\n"
"Summary:"
)
def group_summary_prompt_builder(group_name, combined):
return (
f"You are a financial news analyst. Below are partial summaries of "
f"today's '{group_name}' news.\n"
"Synthesise them into a single detailed 6-7 sentence summary.\n"
"Preserve all key facts, numbers, and market-relevant details.\n\n"
f"{combined}\n\n"
"Final summary:"
)