mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-04-29 03:00:45 -04:00
disable overriding event source
This commit is contained in:
@@ -2,7 +2,7 @@ import asyncio
|
||||
import json
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Callable, Iterable
|
||||
from typing import Callable, Iterable, Optional
|
||||
|
||||
from opendevin.core.logger import opendevin_logger as logger
|
||||
from opendevin.events.serialization.event import event_from_dict, event_to_dict
|
||||
@@ -94,12 +94,13 @@ class EventStream:
|
||||
del self._subscribers[id]
|
||||
|
||||
# TODO: make this not async
|
||||
async def add_event(self, event: Event, source: EventSource):
|
||||
async def add_event(self, event: Event, source: Optional[EventSource] = None):
|
||||
async with self._lock:
|
||||
event._id = self._cur_id # type: ignore [attr-defined]
|
||||
self._cur_id += 1
|
||||
event._timestamp = datetime.now() # type: ignore [attr-defined]
|
||||
event._source = source # type: ignore [attr-defined]
|
||||
if not event.source:
|
||||
event._source = source # type: ignore [attr-defined]
|
||||
data = event_to_dict(event)
|
||||
if event.id is not None:
|
||||
self._file_store.write(
|
||||
|
||||
@@ -96,12 +96,13 @@ class Session:
|
||||
await self._initialize_agent(data)
|
||||
return
|
||||
event = event_from_dict(data.copy())
|
||||
event._source = EventSource.USER # type: ignore[attr-defined]
|
||||
if not event.source:
|
||||
event._source = EventSource.USER # type: ignore[attr-defined]
|
||||
if isinstance(event, Action):
|
||||
logger.info(
|
||||
event, extra={'msg_type': 'ACTION', 'event_source': EventSource.USER}
|
||||
)
|
||||
await self.agent_session.event_stream.add_event(event, EventSource.USER)
|
||||
await self.agent_session.event_stream.add_event(event)
|
||||
|
||||
async def send(self, data: dict[str, object]) -> bool:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user