chore: 更新.gitignore并添加新文件
在.gitignore中添加对*.png、*.log、*-lock.json、*.woff2文件的忽略规则,并新增OFL.txt文件。同时,添加vue.svg图标文件以支持前端展示。更新多个TypeScript文件以优化代码格式和增强可读性。
This commit is contained in:
@@ -31,14 +31,13 @@ export class AiService {
|
||||
@InjectRepository(BidItem)
|
||||
private readonly bidItemRepository: Repository<BidItem>,
|
||||
) {
|
||||
const apiKey = this.configService.get<string>('ARK_API_KEY');
|
||||
// this.openai = new OpenAI({
|
||||
// apiKey: apiKey || '',
|
||||
// apiKey: this.configService.get<string>('ARK_API_KEY') || '',
|
||||
// baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
|
||||
// timeout: 120000, // 120秒超时
|
||||
// });
|
||||
this.openai = new OpenAI({
|
||||
apiKey: 'sk-5sSOxrJl31MGz76bE14d2fDbA55b44869fCcA0C813Fc893a' ,
|
||||
apiKey: 'sk-5sSOxrJl31MGz76bE14d2fDbA55b44869fCcA0C813Fc893a',
|
||||
baseURL: 'https://aihubmix.com/v1',
|
||||
timeout: 120000, // 120秒超时
|
||||
});
|
||||
@@ -49,7 +48,9 @@ export class AiService {
|
||||
this.logger.log(`发送给 AI 的数据数量: ${bids.length}`);
|
||||
|
||||
try {
|
||||
const prompt =PromptString+ `请根据以下投标项目标题列表,筛选出我关心的项目。请以 JSON 格式返回,格式如下:
|
||||
const prompt =
|
||||
PromptString +
|
||||
`请根据以下投标项目标题列表,筛选出我关心的项目。请以 JSON 格式返回,格式如下:
|
||||
[
|
||||
{
|
||||
"title": "项目标题",
|
||||
@@ -58,7 +59,11 @@ 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);
|
||||
const completion = await this.openai.chat.completions.create({
|
||||
model: 'mimo-v2-flash-free',
|
||||
@@ -97,7 +102,9 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
|
||||
}
|
||||
}
|
||||
|
||||
async saveRecommendations(recommendations: AIRecommendation[]): Promise<void> {
|
||||
async saveRecommendations(
|
||||
recommendations: AIRecommendation[],
|
||||
): Promise<void> {
|
||||
this.logger.log('开始保存 AI 推荐结果');
|
||||
|
||||
try {
|
||||
@@ -105,7 +112,7 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
|
||||
await this.aiRecommendationRepository.clear();
|
||||
|
||||
// 保存新的推荐结果(只保存 title 和 confidence)
|
||||
const entities = recommendations.map(rec => {
|
||||
const entities = recommendations.map((rec) => {
|
||||
const entity = new AiRecommendationEntity();
|
||||
entity.title = rec.title;
|
||||
entity.confidence = rec.confidence;
|
||||
@@ -125,14 +132,14 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
|
||||
|
||||
try {
|
||||
const entities = await this.aiRecommendationRepository.find({
|
||||
order: { confidence: 'DESC' }
|
||||
order: { confidence: 'DESC' },
|
||||
});
|
||||
|
||||
// 从 bid-items 表获取 url、source 和 publishDate
|
||||
const result: AIRecommendation[] = [];
|
||||
for (const entity of entities) {
|
||||
const bidItem = await this.bidItemRepository.findOne({
|
||||
where: { title: entity.title }
|
||||
where: { title: entity.title },
|
||||
});
|
||||
|
||||
result.push({
|
||||
@@ -140,7 +147,7 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
|
||||
url: bidItem?.url || '',
|
||||
source: bidItem?.source || '',
|
||||
confidence: entity.confidence,
|
||||
publishDate: bidItem?.publishDate
|
||||
publishDate: bidItem?.publishDate,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,7 +155,9 @@ ${JSON.stringify(bids.map(b => b.title), null, 2)}`;
|
||||
result.sort((a, b) => {
|
||||
if (!a.publishDate) return 1;
|
||||
if (!b.publishDate) return -1;
|
||||
return new Date(b.publishDate).getTime() - new Date(a.publishDate).getTime();
|
||||
return (
|
||||
new Date(b.publishDate).getTime() - new Date(a.publishDate).getTime()
|
||||
);
|
||||
});
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm';
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity('ai_recommendations')
|
||||
export class AiRecommendation {
|
||||
|
||||
Reference in New Issue
Block a user