feat: ai完成stock模块搭建
This commit is contained in:
@@ -30,7 +30,6 @@ namespace Yi.Abp.Application.Services
|
||||
public ISqlSugarRepository<BannerAggregateRoot> sqlSugarRepository { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 动态Api
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
34
Yi.Abp.Net8/src/Yi.Abp.Web/Jobs/ai-stock/GenerateNewsJob.cs
Normal file
34
Yi.Abp.Net8/src/Yi.Abp.Web/Jobs/ai-stock/GenerateNewsJob.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.BackgroundWorkers.Hangfire;
|
||||
using Yi.Framework.Stock.Domain.Managers;
|
||||
|
||||
namespace Yi.Abp.Web.Jobs.ai_stock
|
||||
{
|
||||
public class GenerateNewsJob : HangfireBackgroundWorkerBase
|
||||
{
|
||||
private NewsManager _newsManager;
|
||||
|
||||
public GenerateNewsJob(NewsManager newsManager)
|
||||
{
|
||||
_newsManager = newsManager;
|
||||
|
||||
RecurringJobId = "AI股票新闻生成";
|
||||
//每个小时整点执行一次
|
||||
CronExpression = "0 0 * * * ?";
|
||||
}
|
||||
|
||||
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
// 每次触发只有2/24的概率执行生成新闻
|
||||
var random = new Random();
|
||||
var probability = random.Next(0, 24);
|
||||
|
||||
if (probability < 2)
|
||||
{
|
||||
await _newsManager.GenerateNewsAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ using Volo.Abp.AspNetCore.VirtualFileSystem;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.BackgroundJobs.Hangfire;
|
||||
using Volo.Abp.BackgroundWorkers;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
@@ -106,6 +107,15 @@ namespace Yi.Abp.Web
|
||||
var host = context.Services.GetHostingEnvironment();
|
||||
var service = context.Services;
|
||||
|
||||
//本地开发环境,禁用作业执行
|
||||
if (host.IsDevelopment())
|
||||
{
|
||||
Configure<AbpBackgroundWorkerOptions> (options =>
|
||||
{
|
||||
options.IsEnabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
//请求日志
|
||||
Configure<AbpAuditingOptions>(options =>
|
||||
{
|
||||
|
||||
@@ -108,5 +108,13 @@
|
||||
"AiOptions": {
|
||||
"ApiKey": "",
|
||||
"BaseDomain": ""
|
||||
},
|
||||
|
||||
|
||||
//语义内核
|
||||
"SemanticKernel": {
|
||||
"ModelId": "gpt-4o",
|
||||
"Endpoint": "https://xxx.com/v1",
|
||||
"ApiKey": "sk-xxxxxx"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user