Files
Yi.Framework/Yi.Abp.Net8/module/ai-stock/Yi.Framework.Stock.Domain/Managers/NewsManager.cs
2025-03-08 22:14:26 +08:00

48 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Volo.Abp.Domain.Services;
using Yi.Framework.SqlSugarCore.Abstractions;
using Yi.Framework.Stock.Domain.Entities;
using Yi.Framework.Stock.Domain.Managers.SemanticKernel;
using Yi.Framework.Stock.Domain.Managers.SemanticKernel.Plugins;
namespace Yi.Framework.Stock.Domain.Managers;
public class NewsManager:DomainService
{
private SemanticKernelClient _skClient;
private ISqlSugarRepository<StockNewsAggregateRoot> _newsRepository;
public NewsManager(SemanticKernelClient skClient,ISqlSugarRepository<StockNewsAggregateRoot> newsRepository)
{
_skClient = skClient;
_newsRepository = newsRepository;
}
/// <summary>
/// 生成一个新闻
/// </summary>
/// <returns></returns>
public async Task GenerateNewsAsync()
{ var question = """
""";
await _skClient.ChatCompletionAsync(question, ("NewsPlugins","save_news"));
}
public async Task SaveNewsAsync(NewsModel news)
{
var newsEntity = new StockNewsAggregateRoot(
title: news.Title,
content: news.Content,
source: news.Source
)
{
Summary = news.Summary,
CreationTime = DateTime.Now,
IsDeleted = false,
OrderNum = 0
};
await _newsRepository.InsertAsync(newsEntity);
}
}