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

@@ -55,6 +55,11 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="source" label="来源" width="200" /> <el-table-column prop="source" label="来源" width="200" />
<el-table-column prop="publishDate" label="发布日期" width="180">
<template #default="scope">
{{ formatDate(scope.row.publishDate) }}
</template>
</el-table-column>
<el-table-column prop="confidence" label="推荐度" width="120"> <el-table-column prop="confidence" label="推荐度" width="120">
<template #default="scope"> <template #default="scope">
<el-tag :type="getConfidenceType(scope.row.confidence)"> <el-tag :type="getConfidenceType(scope.row.confidence)">
@@ -117,6 +122,7 @@ interface AIRecommendation {
url: string url: string
source: string source: string
confidence: number confidence: number
publishDate?: string
} }
interface Props { interface Props {

View File

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

View File

@@ -4,6 +4,7 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
import { BidItem } from '../bids/entities/bid-item.entity'; import { BidItem } from '../bids/entities/bid-item.entity';
import { Keyword } from '../keywords/keyword.entity'; import { Keyword } from '../keywords/keyword.entity';
import { AiRecommendation } from '../ai/entities/ai-recommendation.entity'; import { AiRecommendation } from '../ai/entities/ai-recommendation.entity';
import { CrawlInfoAdd } from '../crawler/entities/crawl-info-add.entity';
@Module({ @Module({
imports: [ imports: [
@@ -17,7 +18,7 @@ import { AiRecommendation } from '../ai/entities/ai-recommendation.entity';
username: configService.get<string>('DATABASE_USERNAME', 'root'), username: configService.get<string>('DATABASE_USERNAME', 'root'),
password: configService.get<string>('DATABASE_PASSWORD', 'root'), password: configService.get<string>('DATABASE_PASSWORD', 'root'),
database: configService.get<string>('DATABASE_NAME', 'bidding'), database: configService.get<string>('DATABASE_NAME', 'bidding'),
entities: [BidItem, Keyword, AiRecommendation], entities: [BidItem, Keyword, AiRecommendation, CrawlInfoAdd],
synchronize: configService.get<boolean>('DATABASE_SYNCHRONIZE', true), synchronize: configService.get<boolean>('DATABASE_SYNCHRONIZE', true),
}), }),
}), }),