mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
chore: track condeser metadata for llm completion (#7938)
This commit is contained in:
@@ -51,6 +51,7 @@ class Condenser(ABC):
|
||||
|
||||
def __init__(self):
|
||||
self._metadata_batch: dict[str, Any] = {}
|
||||
self._llm_metadata: dict[str, Any] = {}
|
||||
|
||||
def add_metadata(self, key: str, value: Any) -> None:
|
||||
"""Add information to the current metadata batch.
|
||||
@@ -100,6 +101,7 @@ class Condenser(ABC):
|
||||
|
||||
def condensed_history(self, state: State) -> View | Condensation:
|
||||
"""Condense the state's history."""
|
||||
self._llm_metadata = state.to_llm_metadata('condenser')
|
||||
with self.metadata_batch(state):
|
||||
return self.condense(state.view)
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ CURRENT_STATE: Last flip: Heads, Haiku count: 15/20"""
|
||||
|
||||
response = self.llm.completion(
|
||||
messages=self.llm.format_messages_for_llm(messages),
|
||||
extra_body={'metadata': self._llm_metadata},
|
||||
)
|
||||
summary = response.choices[0].message.content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user