mend
This commit is contained in:
@@ -146,6 +146,8 @@ class AgentRunner:
|
||||
|
||||
def __init__(self):
|
||||
self._provider: AgentProvider | None = None
|
||||
self._history: list[tuple[str, str]] = [] # (role, text)
|
||||
self.include_history = False # toggled by UI
|
||||
|
||||
def _get_provider(self) -> AgentProvider:
|
||||
if self._provider is None:
|
||||
@@ -178,6 +180,9 @@ class AgentRunner:
|
||||
def model(self, value: str):
|
||||
self._get_provider().model = value
|
||||
|
||||
def clear_history(self):
|
||||
self._history.clear()
|
||||
|
||||
def send(
|
||||
self,
|
||||
message: str,
|
||||
@@ -205,9 +210,14 @@ class AgentRunner:
|
||||
mentioned_frames=mentioned_frames,
|
||||
transcript_segments=transcript,
|
||||
mentioned_transcripts=mentioned_transcripts,
|
||||
history=list(self._history) if self.include_history else [],
|
||||
)
|
||||
self._history.append(("user", message))
|
||||
response_chunks = []
|
||||
for chunk in provider.stream(message, context):
|
||||
response_chunks.append(chunk)
|
||||
on_chunk(chunk)
|
||||
self._history.append(("assistant", "".join(response_chunks)))
|
||||
on_done(None)
|
||||
except Exception as e:
|
||||
log.error("Agent error: %s", e)
|
||||
|
||||
Reference in New Issue
Block a user