update news prompt, change telegram to global news

This commit is contained in:
rdyzakya 2025-12-25 23:19:58 +08:00
parent c3b17e0629
commit 31a67d2125
3 changed files with 42 additions and 6 deletions

View File

@ -4,7 +4,7 @@ from typing import Annotated
from .local import get_YFin_data, get_finnhub_news, get_finnhub_company_insider_sentiment, get_finnhub_company_insider_transactions, get_simfin_balance_sheet, get_simfin_cashflow, get_simfin_income_statements, get_reddit_global_news, get_reddit_company_news
from .y_finance import get_YFin_data_online, get_stock_stats_indicators_window, get_balance_sheet as get_yfinance_balance_sheet, get_cashflow as get_yfinance_cashflow, get_income_statement as get_yfinance_income_statement, get_insider_transactions as get_yfinance_insider_transactions
from .google import get_google_news
from .openai import get_stock_news_openai, get_global_news_openai, get_fundamentals_openai
from .openai import get_crypto_news_openai, get_global_news_openai, get_fundamentals_openai
from .alpha_vantage import (
get_stock as get_alpha_vantage_stock,
get_indicator as get_alpha_vantage_indicator,
@ -99,14 +99,14 @@ VENDOR_METHODS = {
# news_data
"get_news": {
"alpha_vantage": get_alpha_vantage_news,
"openai": get_stock_news_openai,
"openai": get_crypto_news_openai,
"google": get_google_news,
"telegram": get_crypto_news_telegram,
"local": [get_finnhub_news, get_reddit_company_news, get_google_news],
# "local": [get_finnhub_news, get_reddit_company_news, get_google_news],
},
"get_global_news": {
"openai": get_global_news_openai,
"local": get_reddit_global_news
"telegram": get_crypto_news_telegram,
# "local": get_reddit_global_news
},
"get_insider_sentiment": {
"local": get_finnhub_company_insider_sentiment

View File

@ -36,6 +36,39 @@ def get_stock_news_openai(query, start_date, end_date):
return response.output[1].content[0].text
def get_crypto_news_openai(query, start_date, end_date):
config = get_config()
client = OpenAI(base_url=config["backend_url"])
response = client.responses.create(
model=config["quick_think_llm"],
input=[
{
"role": "system",
"content": [
{
"type": "input_text",
"text": f"Can you search News for {query} from {start_date} to {end_date}? Make sure you only get the data posted during that period.",
}
],
}
],
text={"format": {"type": "text"}},
reasoning={},
tools=[
{
"type": "web_search_preview",
"user_location": {"type": "approximate"},
"search_context_size": "low",
}
],
temperature=1,
max_output_tokens=4096,
top_p=1,
store=True,
)
return response.output[1].content[0].text
def get_global_news_openai(curr_date, look_back_days=7, limit=5):
config = get_config()

View File

@ -45,5 +45,8 @@ async def _get_channel_history_async(start_date_str, end_date_str):
return intro + formatted_log
def get_crypto_news_telegram(symbol, start_date, end_date):
def get_crypto_news_telegram(curr_date, look_back_days=7, limit=100):
# ignore limit for now
start_date = curr_date - timedelta(days=look_back_days)
end_date = curr_date
return asyncio.run(_get_channel_history_async(start_date, end_date))