fix(agent): Omit EventHistory progress message if empty

Also add a heading to the progress section
This commit is contained in:
Reinier van der Leer
2024-04-24 18:56:43 +02:00
parent 126aacb2e3
commit bdda3a6698

View File

@@ -34,13 +34,12 @@ class EventHistoryComponent(MessageProvider, AfterParse, AfterExecute):
self.llm_provider = llm_provider self.llm_provider = llm_provider
def get_messages(self) -> Iterator[ChatMessage]: def get_messages(self) -> Iterator[ChatMessage]:
yield ChatMessage.system( if progress := self._compile_progress(
self._compile_progress( self.event_history.episodes,
self.event_history.episodes, self.max_tokens,
self.max_tokens, self.count_tokens,
self.count_tokens, ):
) yield ChatMessage.system(f"## Progress on your Task so far\n\n{progress}")
)
def after_parse(self, result: ThoughtProcessOutput) -> None: def after_parse(self, result: ThoughtProcessOutput) -> None:
if result.command_name: if result.command_name: