From 5f34b4561e43e9bf6362832cfde93d4e2d79573c Mon Sep 17 00:00:00 2001 From: xming521 <1223398803@qq.com> Date: Wed, 9 Jul 2025 23:15:51 +0800 Subject: [PATCH] feat(dataset): adds option to include time Adds a configuration option to include the current datetime in the system prompt of the generated dataset. This allows models to be aware of the temporal context of the conversations. --- settings.template.jsonc | 1 + weclone/data/qa_generator.py | 6 +++++- weclone/utils/config_models.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/settings.template.jsonc b/settings.template.jsonc index b465208..e6736f6 100644 --- a/settings.template.jsonc +++ b/settings.template.jsonc @@ -29,6 +29,7 @@ "例如 密码", "//....." ], + "add_time": false, "single_combine_strategy": "time_window", // 单人组成单句策略 "qa_match_strategy": "time_window", // 组成qa策略 "single_combine_time_window": 2, // 单人组成单句时间窗口(分钟), diff --git a/weclone/data/qa_generator.py b/weclone/data/qa_generator.py index a7c69d2..0a3c16c 100644 --- a/weclone/data/qa_generator.py +++ b/weclone/data/qa_generator.py @@ -278,13 +278,17 @@ class DataProcessor: ) return qa_id + system_content = self.system_prompt + if self.c.add_time: + system_content += f" Current datetime: {time_stamp.strftime('%Y-%m-%d %H:%M:%S')}" + qa_pair = self.QaPair( id=qa_id, time=time_stamp, score=0, messages=current_conversation_messages.copy(), images=current_conversation_images.copy(), - system=self.system_prompt, + system=system_content, ) qa_res.append(qa_pair) return qa_id + 1 diff --git a/weclone/utils/config_models.py b/weclone/utils/config_models.py index dfa8060..e4601c4 100644 --- a/weclone/utils/config_models.py +++ b/weclone/utils/config_models.py @@ -134,6 +134,7 @@ class MakeDatasetArgs(BaseConfigModel): include_type: List[DataModality] = Field([DataModality.TEXT], description="Types of data to include") max_image_num: int = Field(2, description="Maximum number of images per single data entry") blocked_words: List[str] = Field([], description="List of blocked words") + add_time: bool = Field(False, description="Whether to add time to the dataset") single_combine_strategy: CombineStrategy = Field( CombineStrategy.TIME_WINDOW, description="Strategy for combining single person's messages into a single sentence",