MCPcopy
hub / github.com/Aider-AI/aider / format_chat_chunks

Method format_chat_chunks

aider/coders/base_coder.py:1226–1331  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1224 return prompt
1225
1226 def format_chat_chunks(self):
1227 self.choose_fence()
1228 main_sys = self.fmt_system_prompt(self.gpt_prompts.main_system)
1229 if self.main_model.system_prompt_prefix:
1230 main_sys = self.main_model.system_prompt_prefix + "\n" + main_sys
1231
1232 example_messages = []
1233 if self.main_model.examples_as_sys_msg:
1234 if self.gpt_prompts.example_messages:
1235 main_sys += "\n# Example conversations:\n\n"
1236 for msg in self.gpt_prompts.example_messages:
1237 role = msg["role"]
1238 content = self.fmt_system_prompt(msg["content"])
1239 main_sys += f"## {role.upper()}: {content}\n\n"
1240 main_sys = main_sys.strip()
1241 else:
1242 for msg in self.gpt_prompts.example_messages:
1243 example_messages.append(
1244 dict(
1245 role=msg["role"],
1246 content=self.fmt_system_prompt(msg["content"]),
1247 )
1248 )
1249 if self.gpt_prompts.example_messages:
1250 example_messages += [
1251 dict(
1252 role="user",
1253 content=(
1254 "I switched to a new code base. Please don't consider the above files"
1255 " or try to edit them any longer."
1256 ),
1257 ),
1258 dict(role="assistant", content="Ok."),
1259 ]
1260
1261 if self.gpt_prompts.system_reminder:
1262 main_sys += "\n" + self.fmt_system_prompt(self.gpt_prompts.system_reminder)
1263
1264 chunks = ChatChunks()
1265
1266 if self.main_model.use_system_prompt:
1267 chunks.system = [
1268 dict(role="system", content=main_sys),
1269 ]
1270 else:
1271 chunks.system = [
1272 dict(role="user", content=main_sys),
1273 dict(role="assistant", content="Ok."),
1274 ]
1275
1276 chunks.examples = example_messages
1277
1278 self.summarize_end()
1279 chunks.done = self.done_messages
1280
1281 chunks.repo = self.get_repo_messages()
1282 chunks.readonly_files = self.get_readonly_files_messages()
1283 chunks.chat_files = self.get_chat_files_messages()

Callers 2

format_messagesMethod · 0.95
cmd_copy_contextMethod · 0.45

Calls 9

choose_fenceMethod · 0.95
fmt_system_promptMethod · 0.95
summarize_endMethod · 0.95
get_repo_messagesMethod · 0.95
all_messagesMethod · 0.95
ChatChunksClass · 0.85
token_countMethod · 0.45

Tested by

no test coverage detected