|
@@ -5,6 +5,7 @@ import os
|
|
|
import json
|
|
|
from openai import OpenAI
|
|
|
|
|
|
+from applications.functions.chatgpt import OpenAIServer
|
|
|
from applications.functions.log import logging
|
|
|
|
|
|
|
|
@@ -23,8 +24,38 @@ class KimiServer(object):
|
|
|
title = params['title'].split("@@")[-1]
|
|
|
contents = params['content']
|
|
|
trace_id = params['trace_id']
|
|
|
- kimi_title = await cls.kimi_title(title)
|
|
|
- kimi_info = await cls.kimi_mining(contents)
|
|
|
+ try:
|
|
|
+ kimi_title = await cls.kimi_title(title)
|
|
|
+ except Exception as e:
|
|
|
+ logging(
|
|
|
+ code="9000",
|
|
|
+ info="kimi 挖掘失败--{}, 采用 gpt".format(e),
|
|
|
+ trace_id=trace_id
|
|
|
+ )
|
|
|
+ gpt = OpenAIServer()
|
|
|
+ kimi_title = gpt.gpt_mining(
|
|
|
+ text=title,
|
|
|
+ prompt=gpt.prompt_generate(
|
|
|
+ prompt_type="title"
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ kimi_title = kimi_title.replace("'", "").replace('"', "").replace("\\", "")
|
|
|
+ try:
|
|
|
+ kimi_info = await cls.kimi_mining(contents)
|
|
|
+ except Exception as e:
|
|
|
+ logging(
|
|
|
+ code="9000",
|
|
|
+ info="kimi 挖掘失败--{}, 采用 gpt".format(e),
|
|
|
+ trace_id=trace_id
|
|
|
+ )
|
|
|
+ gpt = OpenAIServer()
|
|
|
+ kimi_info = gpt.gpt_mining(
|
|
|
+ text=contents,
|
|
|
+ prompt=gpt.prompt_generate(
|
|
|
+ prompt_type="text"
|
|
|
+ )
|
|
|
+ )
|
|
|
kimi_info['k_title'] = kimi_title
|
|
|
kimi_info['ori_title'] = title
|
|
|
logging(
|
|
@@ -138,7 +169,7 @@ class KimiServer(object):
|
|
|
"content": ori_title + "\n" + single_title_prompt,
|
|
|
}
|
|
|
],
|
|
|
- model="moonshot-v1-8k",
|
|
|
+ model="moonshot-v1-32k",
|
|
|
)
|
|
|
response = chat_completion.choices[0].message.content
|
|
|
return response.split("\n")[0]
|
|
@@ -170,7 +201,7 @@ class KimiServer(object):
|
|
|
"content": text_prompt + text,
|
|
|
}
|
|
|
],
|
|
|
- model="moonshot-v1-8k",
|
|
|
+ model="moonshot-v1-32k",
|
|
|
)
|
|
|
response = chat_completion.choices[0].message.content.replace('```json', '').replace('```', '')
|
|
|
try:
|