mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +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,8 +912,12 @@ class Coder:
|
||||||
if user_lang:
|
if user_lang:
|
||||||
platform_text += f"- Language: {user_lang}\n"
|
platform_text += f"- Language: {user_lang}\n"
|
||||||
|
|
||||||
dt = datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S%z")
|
if self.cache_prompts:
|
||||||
platform_text += f"- Current date/time: {dt}"
|
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")
|
||||||
|
platform_text += f"- Current date/time: {dt}"
|
||||||
|
|
||||||
prompt = prompt.format(
|
prompt = prompt.format(
|
||||||
fence=self.fence,
|
fence=self.fence,
|
||||||
|
@ -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
|
||||||
|
|
|
@ -17,7 +17,7 @@ from aider.dump import dump # noqa: F401
|
||||||
from aider.llm import AIDER_APP_NAME, AIDER_SITE_URL, litellm
|
from aider.llm import AIDER_APP_NAME, AIDER_SITE_URL, litellm
|
||||||
|
|
||||||
DEFAULT_MODEL_NAME = "gpt-4o"
|
DEFAULT_MODEL_NAME = "gpt-4o"
|
||||||
ANTHROPIC_BETA_HEADER = "max-tokens-3-5-sonnet-2024-07-15, prompt-caching-2024-07-31"
|
ANTHROPIC_BETA_HEADER = "max-tokens-3-5-sonnet-2024-07-15,prompt-caching-2024-07-31"
|
||||||
|
|
||||||
OPENAI_MODELS = """
|
OPENAI_MODELS = """
|
||||||
gpt-4
|
gpt-4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue