mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 03:35:00 +00:00
fix: Update content handling in ChatChunks class
feat: Add date-based caching for prompts refactor: Simplify current date/time formatting in Coder class
This commit is contained in:
parent
a0fd982546
commit
36663cf04e
2 changed files with 12 additions and 5 deletions
|
@ -91,7 +91,7 @@ class ChatChunks:
|
||||||
if not messages:
|
if not messages:
|
||||||
return
|
return
|
||||||
|
|
||||||
content = messages[-1]
|
content = messages[-1]["content"]
|
||||||
if type(content) is str:
|
if type(content) is str:
|
||||||
content = dict(
|
content = dict(
|
||||||
type="text",
|
type="text",
|
||||||
|
@ -99,6 +99,8 @@ class ChatChunks:
|
||||||
)
|
)
|
||||||
content["cache_control"] = {"type": "ephemeral"}
|
content["cache_control"] = {"type": "ephemeral"}
|
||||||
|
|
||||||
|
messages[-1]["content"] = [content]
|
||||||
|
|
||||||
|
|
||||||
class Coder:
|
class Coder:
|
||||||
abs_fnames = None
|
abs_fnames = None
|
||||||
|
@ -910,6 +912,10 @@ class Coder:
|
||||||
if user_lang:
|
if user_lang:
|
||||||
platform_text += f"- Language: {user_lang}\n"
|
platform_text += f"- Language: {user_lang}\n"
|
||||||
|
|
||||||
|
if self.cache_prompts:
|
||||||
|
dt = datetime.now().astimezone().strftime("%Y-%m-%d")
|
||||||
|
platform_text += f"- Current date: {dt}"
|
||||||
|
else:
|
||||||
dt = datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S%z")
|
dt = datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S%z")
|
||||||
platform_text += f"- Current date/time: {dt}"
|
platform_text += f"- Current date/time: {dt}"
|
||||||
|
|
||||||
|
@ -1020,7 +1026,8 @@ class Coder:
|
||||||
if self.cache_prompts and self.main_model.cache_control:
|
if self.cache_prompts and self.main_model.cache_control:
|
||||||
chunks.add_cache_control_headers()
|
chunks.add_cache_control_headers()
|
||||||
|
|
||||||
return chunks.all_messages()
|
msgs = chunks.all_messages()
|
||||||
|
return msgs
|
||||||
|
|
||||||
def send_message(self, inp):
|
def send_message(self, inp):
|
||||||
self.aider_edited_files = None
|
self.aider_edited_files = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue