Update AWSNovaSonicLLMService to work with LLMContext and LLMContextAggregatorPair

This commit is contained in:
Paul Kompfner
2025-09-25 09:46:33 -04:00
parent d0178edad0
commit 4d9873b613
11 changed files with 571 additions and 476 deletions

View File

@@ -86,12 +86,11 @@ async def save_conversation(params: FunctionCallParams):
timestamp = datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
filename = f"{BASE_FILENAME}{timestamp}.json"
logger.debug(
f"writing conversation to {filename}\n{json.dumps(params.context.get_messages(), indent=4)}"
f"writing conversation to {filename}\n{json.dumps(params.context.get_messages_for_persistent_storage(), indent=4)}"
)
try:
with open(filename, "w") as file:
# todo: extract 'system' into the first message in the list
messages = params.context.get_messages()
messages = params.context.get_messages_for_persistent_storage()
# remove the last message (the instruction to save the context)
messages.pop()
json.dump(messages, file, indent=2)