Skip to content

Commit ce7d8eb

Browse files
authored
Merge pull request #14 from jihe520/dev
fix cite
2 parents 4af8e29 + 9149700 commit ce7d8eb

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

backend/app/core/prompts.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,29 @@ def get_writer_prompt(
151151
* Block formulas with $$...$$
152152
- Visual elements:
153153
* Image references on new lines: ![alt_text](filename.ext)
154+
* Images should be placed after paragraphs
154155
* Table formatting with markdown syntax
155156
- Citation system:
156-
* Direct inline citations with full bibliographic details
157+
* Direct inline citations with full bibliographic details in curly braces format
157158
* Prohibit end-of-document reference lists
158159
159160
## Citation Protocol
160-
1. Unique numbering from [^1] with sequential increments
161-
2. Must remember each reference can only be cited once
162-
3. When citing references in the text, directly write the complete citation information inline after the relevant sentence or paragraph, do not list references separately at the end of the document
163-
Infant sleep patterns affect parental mental health[^1]: Jayne Smart, Harriet Hiscock (2007). Early infant crying and sleeping problems: A review of the literature.
164-
4. Mandatory literature search for theoretical sections using search_papers
161+
1. **CRITICAL: Each reference can ONLY be cited ONCE throughout the entire document**
162+
2. Citation format: {{[^1] Complete citation information}}
163+
3. Unique numbering from [^1] with sequential increments
164+
4. When citing references, use curly braces to wrap the entire citation:
165+
Example: 婴儿睡眠模式影响父母心理健康{{[^1]: Jayne Smart, Harriet Hiscock (2007). Early infant crying and sleeping problems: A review of the literature.}}
166+
5. **IMPORTANT**: Before adding any citation, check if the same reference content has been used before. If it has been cited already, DO NOT cite it again
167+
6. Track all used references internally to avoid duplication
168+
7. Mandatory literature search for theoretical sections using search_papers
165169
166170
167171
# Execution Constraints
168172
1. Autonomous operation without procedural inquiries
169173
2. Output pure {format_output} content without codeblock markers
170174
3. Strict filename adherence for image references
171175
4. Language consistency with user input (currently English)
176+
5. **NEVER repeat citations**: Each unique reference content must appear only once in the entire document
172177
173178
# Exception Handling
174179
Automatic tool invocation triggers:

backend/app/models/user_output.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ def get_model_build_solve(self) -> str:
6666
return model_build_solve
6767

6868
def replace_references_with_uuid(self, text: str) -> str:
69-
# 匹配引用内容,格式为 [^数字]: 引用内容
70-
# 修改正则表达式,更精确地匹配单个引用,避免包含其他引用
71-
references = re.findall(
72-
r"\[\^(\d+)\]:\s*(.*?)(?=\s*!\[|\s*\[\^|\n\n|\Z)", text, re.DOTALL
73-
)
69+
# 匹配引用内容,格式为 {[^数字]: 引用内容}
70+
# 修改正则表达式,匹配大括号包裹的引用格式
71+
references = re.findall(r"\{\[\^(\d+)\]:\s*(.*?)\}", text, re.DOTALL)
7472

7573
for ref_num, ref_content in references:
7674
# 清理引用内容,去除末尾的空格和点号
@@ -86,7 +84,7 @@ def replace_references_with_uuid(self, text: str) -> str:
8684
if existing_uuid:
8785
# 如果已存在,使用现有的UUID
8886
text = re.sub(
89-
rf"\[\^{ref_num}\]:.*?(?=\s*!\[|\s*\[\^|\n\n|\Z)",
87+
rf"\{{\[\^{ref_num}\]:.*?\}}",
9088
f"[{existing_uuid}]",
9189
text,
9290
flags=re.DOTALL,
@@ -98,7 +96,7 @@ def replace_references_with_uuid(self, text: str) -> str:
9896
"content": ref_content,
9997
}
10098
text = re.sub(
101-
rf"\[\^{ref_num}\]:.*?(?=\s*!\[|\s*\[\^|\n\n|\Z)",
99+
rf"\{{\[\^{ref_num}\]:.*?\}}",
102100
f"[{new_uuid}]",
103101
text,
104102
flags=re.DOTALL,

0 commit comments

Comments
 (0)