-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
89 lines (69 loc) · 3.9 KB
/
Copy pathsetup.py
File metadata and controls
89 lines (69 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from setuptools import setup, find_packages
import os
import re
def update_common_rules():
"""Update COMMON_RULES in function_prompt.py and memory_prompt.py with content from ToolPrompt.txt and MemoryPrompt.txt."""
# Update function prompt
tool_prompt_path = os.path.join("mfcs-prompt", "ToolPrompt.txt")
function_prompt_path = os.path.join("src", "mfcs", "function_prompt.py")
if not os.path.exists(tool_prompt_path):
print(f"Warning: {tool_prompt_path} not found. Skipping COMMON_RULES update.")
else:
try:
with open(tool_prompt_path, "r", encoding="utf-8") as f:
tool_prompt_content = f.read()
with open(function_prompt_path, "r", encoding="utf-8") as f:
function_prompt_content = f.read()
# Replace the COMMON_RULES content
pattern = r'(COMMON_RULES = """).*?(""")'
new_content = re.sub(pattern, f'\\1{tool_prompt_content}\\2',
function_prompt_content, flags=re.DOTALL)
with open(function_prompt_path, "w", encoding="utf-8") as f:
f.write(new_content)
print("Successfully updated COMMON_RULES with ToolPrompt.txt content")
except Exception as e:
print(f"Error updating COMMON_RULES: {e}")
# Update memory prompt
memory_prompt_path = os.path.join("mfcs-prompt", "MemoryPrompt.txt")
memory_prompt_py_path = os.path.join("src", "mfcs", "memory_prompt.py")
if not os.path.exists(memory_prompt_path):
print(f"Warning: {memory_prompt_path} not found. Skipping COMMON_RULES update.")
else:
try:
with open(memory_prompt_path, "r", encoding="utf-8") as f:
memory_prompt_content = f.read()
with open(memory_prompt_py_path, "r", encoding="utf-8") as f:
memory_prompt_py_content = f.read()
# Replace the COMMON_RULES content
pattern = r'(COMMON_RULES = """).*?(""")'
new_content = re.sub(pattern, f'\\1{memory_prompt_content}\\2',
memory_prompt_py_content, flags=re.DOTALL)
with open(memory_prompt_py_path, "w", encoding="utf-8") as f:
f.write(new_content)
print("Successfully updated COMMON_RULES with MemoryPrompt.txt content")
except Exception as e:
print(f"Error updating memory COMMON_RULES: {e}")
# Update agent prompt
agent_prompt_path = os.path.join("mfcs-prompt", "AgentPrompt.txt")
agent_prompt_py_path = os.path.join("src", "mfcs", "agent_prompt.py")
if not os.path.exists(agent_prompt_path):
print(f"Warning: {agent_prompt_path} not found. Skipping COMMON_RULES update.")
else:
try:
with open(agent_prompt_path, "r", encoding="utf-8") as f:
agent_prompt_content = f.read()
with open(agent_prompt_py_path, "r", encoding="utf-8") as f:
agent_prompt_py_content = f.read()
# Replace the COMMON_RULES content
pattern = r'(COMMON_RULES = """).*?(""")'
new_content = re.sub(pattern, f'\\1{agent_prompt_content}\\2',
agent_prompt_py_content, flags=re.DOTALL)
with open(agent_prompt_py_path, "w", encoding="utf-8") as f:
f.write(new_content)
print("Successfully updated COMMON_RULES with AgentPrompt.txt content")
except Exception as e:
print(f"Error updating agent COMMON_RULES: {e}")
# Update COMMON_RULES before setup
update_common_rules()
# 使用pyproject.toml中的配置,这里只提供基本的setup调用
setup()