MCPcopy
hub / github.com/HKUDS/DeepCode / _save_segmentation_config

Method _save_segmentation_config

cli/cli_interface.py:66–102  ·  view source on GitHub ↗

Save segmentation configuration to mcp_agent.config.yaml

(self)

Source from the content-addressed store, hash-verified

64 self.segmentation_threshold = 50000
65
66 def _save_segmentation_config(self):
67 """Save segmentation configuration to mcp_agent.config.yaml"""
68 import yaml
69 import os
70
71 # Get the project root directory (where mcp_agent.config.yaml is located)
72 current_file = os.path.abspath(__file__)
73 cli_dir = os.path.dirname(current_file) # cli directory
74 project_root = os.path.dirname(cli_dir) # project root
75 config_path = os.path.join(project_root, "mcp_agent.config.yaml")
76
77 try:
78 # Read current config
79 with open(config_path, "r", encoding="utf-8") as f:
80 config = yaml.safe_load(f)
81
82 # Update document segmentation settings
83 if "document_segmentation" not in config:
84 config["document_segmentation"] = {}
85
86 config["document_segmentation"]["enabled"] = self.segmentation_enabled
87 config["document_segmentation"]["size_threshold_chars"] = (
88 self.segmentation_threshold
89 )
90
91 # Write updated config
92 with open(config_path, "w", encoding="utf-8") as f:
93 yaml.dump(config, f, default_flow_style=False, allow_unicode=True)
94
95 print(
96 f"{Colors.OKGREEN}✅ Document segmentation configuration updated{Colors.ENDC}"
97 )
98
99 except Exception as e:
100 print(
101 f"{Colors.WARNING}⚠️ Failed to update segmentation config: {str(e)}{Colors.ENDC}"
102 )
103
104 def _init_tkinter(self):
105 """Initialize tkinter availability check"""

Callers 2

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected