mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-27 03:33:25 +08:00
feat: 完善提示词
This commit is contained in:
@@ -12,6 +12,7 @@ using Yi.Framework.Stock.Domain.Managers.SemanticKernel;
|
||||
using Yi.Framework.Stock.Domain.Managers.SemanticKernel.Plugins;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Yi.Framework.Stock.Domain.Managers
|
||||
{
|
||||
@@ -422,35 +423,18 @@ namespace Yi.Framework.Stock.Domain.Managers
|
||||
{
|
||||
if (stockPrices.TryGetValue(stock.Id, out var price))
|
||||
{
|
||||
stocksContext.AppendLine($"{stock.MarketName}:id:{stock.Id} 最后一次价格:{price:F2}");
|
||||
stocksContext.AppendLine($"{stock.MarketName}:id:{stock.Id},简介:{stock.Description} 最后一次价格:{price:F2}");
|
||||
}
|
||||
}
|
||||
|
||||
var question = $$"""
|
||||
根据最近的新闻和当前股票价格,预测多家股票未来24小时的价格走势
|
||||
|
||||
{{newsContext}}
|
||||
|
||||
{{stocksContext}}
|
||||
|
||||
请分析上述新闻对各个股票可能产生的影响,并预测每支股票未来24小时的价格变动:
|
||||
1. 考虑新闻中提到的行业、公司或经济趋势
|
||||
2. 分析这些因素对不同股票的积极或消极影响
|
||||
3. 根据分析生成合理的价格波动
|
||||
|
||||
对每支股票,请返回:
|
||||
- 股票id
|
||||
- 一个长度为24的价格数组,表示未来24小时(每小时整点)的预测价格
|
||||
|
||||
价格变动应当符合以下规则:
|
||||
- 相邻时间点的价格波动通常不超过前值的20%
|
||||
- 考虑市场开盘和收盘时间可能带来的较大波动
|
||||
- 不同股票之间的相关性(如同行业股票可能有类似走势)
|
||||
- 部分股票可能对某些新闻更敏感
|
||||
|
||||
请确保数据格式正确,以便系统能够自动处理。
|
||||
""";
|
||||
|
||||
// 从文件读取问题模板
|
||||
string promptTemplate = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot", "stock", "marketPrompt.txt"));
|
||||
|
||||
// 替换变量
|
||||
string question = promptTemplate
|
||||
.Replace("{{newsContext}}", newsContext.ToString())
|
||||
.Replace("{{stocksContext}}", stocksContext.ToString());
|
||||
|
||||
await _skClient.ChatCompletionAsync(question, ("StockPlugins", "save_stocks"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user