mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
chore: track condeser metadata for llm completion (#7938)
This commit is contained in:
parent
f751f8ab37
commit
06fcf54475
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user