Skip to content

Commit

Permalink
fix: add logger info
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed May 3, 2024
1 parent 1707c01 commit bed1997
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/core/src/modules/ai/ai.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ export class AiService {
const taskPromise = handle.bind(this)(
articleId,
this.serializeText(article.document.text),
article.document.title,
) as Promise<any>

this.cachedTaskId2AiPromise.set(taskId, taskPromise)
return await taskPromise

async function handle(this: AiService, id: string, text: string) {
async function handle(
this: AiService,
id: string,
text: string,
title: string,
) {
// 等待 30s
await redis.set(taskId, 'processing', 'EX', 30)

Expand All @@ -110,7 +116,7 @@ CONCISE SUMMARY:`,
const summary = completion.choices[0].message.content

this.logger.log(
`OpenAI 生成文章 ${articleId} 的摘要花费了 ${completion.usage?.total_tokens}token`,
`OpenAI 生成文章 ${id}${title}的摘要花费了 ${completion.usage?.total_tokens}token`,
)
const contentMd5 = md5(text)

Expand Down

0 comments on commit bed1997

Please sign in to comment.