Skip to content

Commit f68a7ae

Browse files
committed
fix #47 AI-Powered Earnings Call Transcripts - Optimize summarize_key_financial_data_with_ai func
1 parent 9804154 commit f68a7ae

File tree

7 files changed

+152
-48
lines changed

7 files changed

+152
-48
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Change Log
22
===========
3+
0.0.15
4+
-------
5+
- AI-Powered Earnings Call Transcripts - Optimize summarize_key_financial_data_with_ai func[`#47 <https://github.com/defeat-beta/defeatbeta-api/issues/47>`_]
6+
37
0.0.14
48
-------
59
- Support TTM Revenue and TTM Net Income[`#46 <https://github.com/defeat-beta/defeatbeta-api/issues/46>`_]

defeatbeta_api/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.14"
1+
__version__ = "0.0.15"

defeatbeta_api/client/openai_conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class OpenAIConfiguration:
22
def __init__(
33
self,
44
model="Qwen/Qwen3-8B",
5-
temperature=0.01,
5+
temperature=0.02,
66
top_p=0.95,
77
stream=False
88
):

defeatbeta_api/data/template/transcripts_key_fin_data_prompt.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ In this step, output the user's question exactly as it is. For example, if the u
1717

1818
## Step-2 Extract Key Financial Data
1919

20-
Extract the key financial data required for function calling tools based on the earnings call transcript
20+
Extract the key financial data required for function calling tools based on the earnings call transcript. If a required financial metric is mentioned in the transcript, you MUST always extract it into key_financial_data. Do not skip it.
2121

2222
For Example:
2323

@@ -71,14 +71,14 @@ For Example:
7171
"non_gaap_net_income_for_this_quarter": null,
7272
"ebitda_for_this_quarter": null,
7373
"adjusted_ebitda_for_this_quarter": null,
74-
"gaap_diluted_earning_per_share_for_this_quarter": {
74+
"gaap_diluted_earnings_per_share_for_this_quarter": {
7575
"value_vocabulary": 0.48,
7676
"unit": "per_share",
7777
"currency_code": "USD",
7878
"speaker": "Jean X. Hu",
7979
"paragraph_number": 4
8080
},
81-
"non_gaap_diluted_earning_per_share_for_this_quarter": null,
81+
"non_gaap_diluted_earnings_per_share_for_this_quarter": null,
8282
"fcf_for_this_quarter": {
8383
"value_vocabulary": 1200,
8484
"unit": "million",
@@ -124,7 +124,10 @@ For Example:
124124
"speaker": "Jean X. Hu",
125125
"paragraph_number": 4
126126
},
127-
"gaap_earning_per_share_forecast_for_next_quarter": null,
128-
"non_gaap_earning_per_share_forecast_for_next_quarter": null,
129-
"capex_forecast_for_next_quarter": null
127+
"gaap_earnings_per_share_forecast_for_next_quarter": null,
128+
"non_gaap_earnings_per_share_forecast_for_next_quarter": null,
129+
"capex_forecast_for_next_quarter": null,
130+
"total_revenue_forecast_for_full_fiscal_year": null,
131+
"gaap_earnings_per_share_forecast_for_full_fiscal_year": null,
132+
"non_gaap_earnings_per_share_forecast_for_full_fiscal_year": null
130133
}

defeatbeta_api/data/template/transcripts_key_fin_data_tools.json

Lines changed: 92 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@
340340
}
341341
}
342342
},
343-
"gaap_diluted_earning_per_share_for_this_quarter": {
343+
"gaap_diluted_earnings_per_share_for_this_quarter": {
344344
"type": ["object", "null"],
345-
"description": "Diluted Earnings per share (EPS) for the current quarter, as disclosed in the transcript. This may appear as 'diluted earnings per share' or 'diluted earnings per ADS'. Return null if unavailable.",
345+
"description": "GAAP Diluted Earnings per share (EPS) for the current quarter, as disclosed in the transcript. This may appear as 'diluted earnings per share' or 'diluted earnings per ADS'. Return null if unavailable.",
346346
"properties": {
347347
"value_vocabulary": {
348348
"type": "number",
@@ -366,7 +366,7 @@
366366
}
367367
}
368368
},
369-
"non_gaap_diluted_earning_per_share_for_this_quarter": {
369+
"non_gaap_diluted_earnings_per_share_for_this_quarter": {
370370
"type": ["object", "null"],
371371
"description": "Non-GAAP Diluted Earnings per share (EPS) for the current quarter, as disclosed in the transcript. This may appear as 'Non-GAAP diluted earnings per share' or 'Non-GAAP diluted earnings per ADS'. Return null if unavailable.",
372372
"properties": {
@@ -618,9 +618,9 @@
618618
}
619619
}
620620
},
621-
"gaap_earning_per_share_forecast_for_next_quarter": {
621+
"gaap_earnings_per_share_forecast_for_next_quarter": {
622622
"type": ["object", "null"],
623-
"description": "Earning per share forecast for the next quarter. This may appear as 'earnings per share' or 'earnings per ADS'. Return null if unavailable.",
623+
"description": "GAAP Earning per share forecast for the next quarter. This may appear as 'earnings per share' or 'earnings per ADS'. Return null if unavailable.",
624624
"properties": {
625625
"value_vocabulary": {
626626
"type": "number",
@@ -644,7 +644,7 @@
644644
}
645645
}
646646
},
647-
"non_gaap_earning_per_share_forecast_for_next_quarter": {
647+
"non_gaap_earnings_per_share_forecast_for_next_quarter": {
648648
"type": ["object", "null"],
649649
"description": "Non-GAAP earnings per share forecast for the next quarter. In transcripts, this may appear as 'non-GAAP EPS', 'non-GAAP earnings per share' 'non-GAAP earnings per share', or 'non-GAAP earnings per ADS'. Return null if unavailable.",
650650
"properties": {
@@ -695,6 +695,84 @@
695695
"description": "Sequential paragraph number in the transcript where this information was mentioned."
696696
}
697697
}
698+
},
699+
"total_revenue_forecast_for_full_fiscal_year": {
700+
"type": ["object", "null"],
701+
"description": "Total revenue forecast for the full fiscal year (FY) as a single numerical value. Return null if unavailable.",
702+
"properties": {
703+
"value_vocabulary": {
704+
"type": "number",
705+
"description": "Numerical value extracted from transcript. Can be positive or negative. For example: -3.8, 1.8, 7.4.. If a range is provided (min/max), return the midpoint as the value."
706+
},
707+
"unit": {
708+
"type": "string",
709+
"description": "Magnitude unit of the number, e.g., million, billion, thousand"
710+
},
711+
"currency_code": {
712+
"type": "string",
713+
"description": "ISO 4217 currency code, e.g., USD, CNY, EUR"
714+
},
715+
"speaker": {
716+
"type": "string",
717+
"description": "Name or role of the speaker who provided this number in the transcript, e.g., 'CFO', 'CEO', or 'John Smith'."
718+
},
719+
"paragraph_number": {
720+
"type": "number",
721+
"description": "The sequential number of the paragraph in the transcript where this information was mentioned. Useful for traceability."
722+
}
723+
}
724+
},
725+
"gaap_earnings_per_share_forecast_for_full_fiscal_year": {
726+
"type": ["object", "null"],
727+
"description": "GAAP Earning per share forecast for the full fiscal year (FY). Return null if unavailable.",
728+
"properties": {
729+
"value_vocabulary": {
730+
"type": "number",
731+
"description": "Numerical value extracted from transcript. Can be positive or negative. For example: -3.8, 1.8, 7.4.. If a range is provided (min/max), return the midpoint as the value."
732+
},
733+
"unit": {
734+
"type": "string",
735+
"description": "Always use 'per_share' to indicate EPS is measured per share."
736+
},
737+
"currency_code": {
738+
"type": "string",
739+
"description": "ISO 4217 currency code, e.g., USD, CNY, EUR"
740+
},
741+
"speaker": {
742+
"type": "string",
743+
"description": "Name or role of the speaker who provided this number in the transcript, e.g., 'CFO', 'CEO', or 'John Smith'."
744+
},
745+
"paragraph_number": {
746+
"type": "number",
747+
"description": "The sequential number of the paragraph in the transcript where this information was mentioned. Useful for traceability."
748+
}
749+
}
750+
},
751+
"non_gaap_earnings_per_share_forecast_for_full_fiscal_year": {
752+
"type": ["object", "null"],
753+
"description": "Non-GAAP earnings per share forecast for the full fiscal year (FY). Return null if unavailable.",
754+
"properties": {
755+
"value_vocabulary": {
756+
"type": "number",
757+
"description": "Numerical value extracted from transcript. Can be positive or negative. For example: -3.8, 1.8, 7.4.. If a range is provided (min/max), return the midpoint as the value."
758+
},
759+
"unit": {
760+
"type": "string",
761+
"description": "Always use 'per_share' to indicate EPS is measured per share."
762+
},
763+
"currency_code": {
764+
"type": "string",
765+
"description": "ISO 4217 currency code, e.g., USD, CNY, EUR"
766+
},
767+
"speaker": {
768+
"type": "string",
769+
"description": "Name or role of the speaker who provided this number in the transcript, e.g., 'CFO', 'CEO', or 'John Smith'."
770+
},
771+
"paragraph_number": {
772+
"type": "number",
773+
"description": "The sequential number of the paragraph in the transcript where this information was mentioned. Useful for traceability."
774+
}
775+
}
698776
}
699777
},
700778
"required": [
@@ -711,8 +789,8 @@
711789
"non_gaap_net_income_for_this_quarter",
712790
"ebitda_for_this_quarter",
713791
"adjusted_ebitda_for_this_quarter",
714-
"gaap_diluted_earning_per_share_for_this_quarter",
715-
"non_gaap_diluted_earning_per_share_for_this_quarter",
792+
"gaap_diluted_earnings_per_share_for_this_quarter",
793+
"non_gaap_diluted_earnings_per_share_for_this_quarter",
716794
"fcf_for_this_quarter",
717795
"total_cash_position_for_this_quarter",
718796
"share_repurchase_for_this_quarter",
@@ -722,9 +800,12 @@
722800
"non_gaap_gross_margin_forecast_for_next_quarter",
723801
"gaap_operating_expense_forecast_for_next_quarter",
724802
"non_gaap_operating_expense_forecast_for_next_quarter",
725-
"gaap_earning_per_share_forecast_for_next_quarter",
726-
"non_gaap_earning_per_share_forecast_for_next_quarter",
727-
"capex_forecast_for_next_quarter"
803+
"gaap_earnings_per_share_forecast_for_next_quarter",
804+
"non_gaap_earnings_per_share_forecast_for_next_quarter",
805+
"capex_forecast_for_next_quarter",
806+
"total_revenue_forecast_for_full_fiscal_year",
807+
"gaap_earnings_per_share_forecast_for_full_fiscal_year",
808+
"non_gaap_earnings_per_share_forecast_for_full_fiscal_year"
728809
]
729810
}
730811
},

defeatbeta_api/data/transcripts.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,26 @@ def summarize_key_financial_data_with_ai(self, fiscal_year: int, fiscal_quarter:
130130
except Exception as e:
131131
raise ValueError(f"Bad value in {k}: {v}, error: {e}")
132132

133+
metric = k
134+
time_scope = "raw"
135+
if k.endswith("_for_this_quarter"):
136+
metric = k[: -len("_for_this_quarter")]
137+
time_scope = "this_quarter"
138+
elif k.endswith("_for_next_quarter"):
139+
metric = k[: -len("_for_next_quarter")]
140+
time_scope = "next_quarter"
141+
elif k.endswith("_for_full_fiscal_year"):
142+
metric = k[: -len("_for_full_fiscal_year")]
143+
time_scope = "full_fiscal_year"
144+
133145
records.append({
134146
"symbol": self.ticker,
135147
"fiscal_year": fiscal_year,
136148
"fiscal_quarter": fiscal_quarter,
137149
"speaker": speaker,
138150
"paragraph_number": paragraph_number,
139-
"key_financial_metric": k,
151+
"key_financial_metric": metric,
152+
"time_scope": time_scope,
140153
"value": value,
141154
"currency_code": currency_code
142155
})

0 commit comments

Comments
 (0)