-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial Message for LLM agnets in Sotopia Aact (Experimental) (#…
…249) * Adding OpenHands node * [autofix.ci] apply automated fixes * Added LLM Agent Node * [autofix.ci] apply automated fixes * removing openhands * [autofix.ci] apply automated fixes * Correcting mypy error in tick agent * Moving everything to examples since its not specific to sotopia * [autofix.ci] apply automated fixes * Adding some additional final checks * Adding scene context for agents * [autofix.ci] apply automated fixes * Renaming scene context to initial message * Adding the initial message channel * Renaming to interview openhands * Adding documentation * [autofix.ci] apply automated fixes * Updating the readme * [autofix.ci] apply automated fixes * Adding scene context for agents * [autofix.ci] apply automated fixes * Renaming scene context to initial message * Adding the initial message channel * Rebasing --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
53e0798
commit df95426
Showing
2 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import sys | ||
|
||
from typing import AsyncIterator | ||
|
||
from aact import Message, NodeFactory, Node | ||
from aact.messages import Text, Tick, DataModel | ||
|
||
if sys.version_info >= (3, 11): | ||
from typing import Self | ||
else: | ||
from typing_extensions import Self | ||
|
||
|
||
@NodeFactory.register("initial_message") | ||
class InitialMessageNode(Node[DataModel, Text]): | ||
def __init__( | ||
self, | ||
input_tick_channel: str, | ||
output_channels: list[str], | ||
env_scenario: str, | ||
redis_url: str = "redis://localhost:6379/0", | ||
): | ||
super().__init__( | ||
input_channel_types=[(input_tick_channel, Tick)], | ||
output_channel_types=[ | ||
(output_channel, Text) for output_channel in output_channels | ||
], | ||
redis_url=redis_url, | ||
) | ||
self.env_scenario = env_scenario | ||
self.output_channels = output_channels | ||
|
||
async def send_env_scenario(self) -> None: | ||
for output_channel in self.output_channels: | ||
await self.r.publish( | ||
output_channel, | ||
Message[Text](data=Text(text=self.env_scenario)).model_dump_json(), | ||
) | ||
|
||
async def event_loop(self) -> None: | ||
await self.send_env_scenario() | ||
|
||
async def __aenter__(self) -> Self: | ||
return await super().__aenter__() | ||
|
||
async def event_handler( | ||
self, _: str, __: Message[DataModel] | ||
) -> AsyncIterator[tuple[str, Message[Text]]]: | ||
raise NotImplementedError("ScenarioContext does not have an event handler.") | ||
yield "", Message[Text](data=Text(text=self.env_scenario)) |