feat: 在AI推荐列表中添加发布日期字段并更新AI服务配置

This commit is contained in:
dmy
2026-01-12 22:48:43 +08:00
parent bfac194c14
commit 996289c671
3 changed files with 22 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ export interface AIRecommendation {
url: string;
source: string;
confidence: number;
publishDate?: Date;
}
@Injectable()
@@ -31,9 +32,14 @@ export class AiService {
private readonly bidItemRepository: Repository<BidItem>,
) {
const apiKey = this.configService.get<string>('ARK_API_KEY');
// this.openai = new OpenAI({
// apiKey: apiKey || '',
// baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
// timeout: 120000, // 120秒超时
// });
this.openai = new OpenAI({
apiKey: apiKey || '',
baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
apiKey: 'sk-5sSOxrJl31MGz76bE14d2fDbA55b44869fCcA0C813Fc893a' ,
baseURL: 'https://aihubmix.com/v1',
timeout: 120000, // 120秒超时
});
}
@@ -43,7 +49,7 @@ export class AiService {
this.logger.log(`发送给 AI 的数据数量: ${bids.length}`);
try {
const prompt =PromptString+ `请根据以下投标项目标题列表,推荐最值得关注的 5-10 个项目。请以 JSON 格式返回,格式如下:
const prompt =PromptString+ `请根据以下投标项目标题列表,筛选出我关心的项目。请以 JSON 格式返回,格式如下:
[
{
"title": "项目标题",
@@ -55,8 +61,8 @@ export class AiService {
${JSON.stringify(bids.map(b => b.title), null, 2)}`;
this.logger.log('发给AI的内容',prompt);
const completion = await this.openai.chat.completions.create({
model: 'doubao-seed-1-6-lite-251015',
max_tokens: 32768,
model: 'mimo-v2-flash-free',
// max_tokens: 32768,
reasoning_effort: 'medium',
messages: [
{
@@ -122,7 +128,7 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
order: { confidence: 'DESC' }
});
// 从 bid-items 表获取 urlsource
// 从 bid-items 表获取 urlsource 和 publishDate
const result: AIRecommendation[] = [];
for (const entity of entities) {
const bidItem = await this.bidItemRepository.findOne({
@@ -133,7 +139,8 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
title: entity.title,
url: bidItem?.url || '',
source: bidItem?.source || '',
confidence: entity.confidence
confidence: entity.confidence,
publishDate: bidItem?.publishDate
});
}