xueyiming 2 mesiacov pred
rodič
commit
65bd1a2362
2 zmenil súbory, kde vykonal 8 pridanie a 7 odobranie
  1. 3 3
      utils/deepseek_utils.py
  2. 5 4
      utils/keywords_utils.py

+ 3 - 3
utils/deepseek_utils.py

@@ -99,7 +99,7 @@ def text_question(text_to_question: str):
 def create_keyword_summary_prompt(text, keyword):
     prompt = f"""
     
-    请基于以下关于关键词"{keyword}"的多条知识,生成一段全面、准确且连贯的知识。
+    请基于以下关于关键词"{keyword}"的多条知识,生成一段全面、准确且连贯的知识,不要输出与知识无关的内容,只返回关键词知识内容
 
 ## 描述内容:
 {text}
@@ -128,7 +128,7 @@ def get_keyword_summary(text, keyword):
 def update_keyword_summary_prompt(text, keyword, new_content):
     prompt = f"""
 
-    请基于以下关于关键词"{keyword}"的相关知识,融合最新的知识到现有的知识中。
+    请基于以下关于关键词"{keyword}"的相关知识,融合最新的知识到现有的知识中,不要输出与知识无关的内容,只返回关键词知识内容
 
 ## 知识要求:
 1. 识别重叠与重复:找出不同文本中表述不同但含义相同的内容。
@@ -225,4 +225,4 @@ def chat_with_deepseek(prompt, model="deepseek-chat", max_tokens=8192, temperatu
 
 
 if __name__ == '__main__':
-    print(chat_with_deepseek('你好啊'))
+    print(get_keyword_summary('这样去发布你的视频,才能增加播放量! #新人如何做抖音 #短视频创业 #自媒体创业 #抖音创业','播放量'))

+ 5 - 4
utils/keywords_utils.py

@@ -10,11 +10,12 @@ from data_models.content_chunks import ContentChunks
 from data_models.keyword_clustering import KeywordClustering
 from data_models.keyword_data import KeywordData
 from data_models.keyword_with_content_chunk import KeywordWithContentChunk
-from utils.deepseek_utils import get_keyword_summary, update_keyword_summary_prompt
+from utils.deepseek_utils import get_keyword_summary, update_keyword_summary
 
 
 class KeywordSummaryTask:
     lock_dict = {}  # 静态变量,不会随着每次实例化而重置
+
     def __init__(self):
         self.executor = ThreadPoolExecutor(max_workers=20, thread_name_prefix='KeywordSummaryTask')
 
@@ -56,9 +57,9 @@ class KeywordSummaryTask:
                                                                            'keyword_summary'])
                             db_helper.add(new_keyword_clustering)
                         else:
-                            new_keyword_summary = update_keyword_summary_prompt(keyword_clustering.keyword_summary,
-                                                                                keyword,
-                                                                                content_chunk.text)
+                            new_keyword_summary = update_keyword_summary(keyword_clustering.keyword_summary,
+                                                                         keyword,
+                                                                         content_chunk.text)
                             db_helper.update(KeywordClustering, filters={"id": keyword_clustering.id},
                                              updates={"keyword_summary": new_keyword_summary})
                         db_helper.update(KeywordWithContentChunk, filters={"id": keyword_with_content_chunk.id},