纠正Unix时间戳(毫秒):
1738040400000
28-01-2025
tracked_stocks = ["NVDA"]
agent_a = Agent(
model=OpenAIChat(id=OPENAI_MODEL_NAME, api_key=OPENAI_API_KEY, base_url=API_BASE_URL),
tools=[YFinanceTools(stock_price=True, historical_prices=True)],
show_tool_calls=True,
name="Market Data Fetcher",
description="Fetches the latest 30 days of OHLCV stock data.",
instructions=[
"Retrieve the recent 30 days of OHLCV (Open, High, Low, Close, Volume) for the given stock symbol.",
"Return the data as a structured JSON object: {date, open, high, low, close, volume}.",
]
)
from datetime import datetime
unix_timestamp = 1738040400000 # Example from Yahoo Finance
correct_date = datetime.utcfromtimestamp(unix_timestamp / 1000).strftime('%d-%m-%Y')
print("Converted Date:", correct_date)
✅这在Agno之外正确起作用,返回“ 28-01-2025”。❌但是在AGNO框架内,该模型仍然输出错误的日期。
i明确指示代理:
“将日期从UNIX TIMESTAMP(毫秒)转换为DD-MM-yyyy格式:dateTime.utcfromtimestamp(timestamp / 1000).strftime('%d-%m-%y')。till给了错误的日期。
我完全到达了你的来源!在LLM和数学方面,最大的挑战之一就是它们如何处理令牌。像“ 1,234,567”之类的数字可能会被分解为较小的部分(“ 1”,“”,“ 234”等),这使得模型更难将其视为单个值。另外,由于LLM旨在预测接下来的令牌而不是执行精确的计算,因此它们并未真正优化数学精度。
如果您需要100%的准确性,我真的建议您手动处理数学,而不是依靠代理商。我知道这是一个额外的一步,但它可以使您免受任何潜在的错误。让我知道我是否可以帮助集思广益更好的方法!