Skip to content

Commit

Permalink
feat: Initial Message for LLM agnets in Sotopia Aact (Experimental) (#…
Browse files Browse the repository at this point in the history
…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
akhatua2 and autofix-ci[bot] authored Nov 16, 2024
1 parent 53e0798 commit df95426
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 3 deletions.
57 changes: 54 additions & 3 deletions examples/experimental/interview_openhands/interview_openhands.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
redis_url = "redis://localhost:6379/0"
extra_modules = ["examples.experimental.interview_openhands.llm_agent"]
extra_modules = ["examples.experimental.interview_openhands.llm_agent", "examples.experimental.nodes.initial_message_node",]


[[nodes]]
Expand All @@ -10,7 +10,7 @@ node_class = "llm_agent"
query_interval = 5
output_channel = "Jack:Jane"
input_text_channels = ["Jane:Jack"]
input_env_channels = ["Runtime:Agent"]
input_env_channels = ["Runtime:Agent", "Scene:Jack"]
input_tick_channel = "tick/secs/1"
goal = "Your goal is to effectively test Jane's technical ability and finally decide if she has passed the interview. Make sure to also evaluate her communication skills, problem-solving approach, and enthusiasm."
model_name = "gpt-4o-mini"
Expand All @@ -24,7 +24,7 @@ node_class = "llm_agent"
query_interval = 7
output_channel = "Jane:Jack"
input_text_channels = ["Jack:Jane"]
input_env_channels = ["Runtime:Agent"]
input_env_channels = ["Runtime:Agent", "Scene:Jane"]
input_tick_channel = "tick/secs/1"
goal = "Your goal is to do well in the interview by demonstrating your technical skills, clear communication, and enthusiasm for the position. Stay calm, ask clarifying questions when needed, and confidently explain your thought process."
model_name = "gpt-4o-mini"
Expand All @@ -34,6 +34,57 @@ agent_name = "Jane"
node_name = "tick"
node_class = "tick"

[[nodes]]
node_name = "JaneScene"
node_class = "initial_message"

[nodes.node_args]
input_tick_channel = "tick/secs/1"
output_channels = ["Scene:Jane"]
env_scenario = """
You are Jane, a college senior at Stanford University interviewing for a Software Engineering Intern position at Fintech company. You are currently sitting in an office with your interviewer, Jack.
It's natural to feel a bit nervous, but remind yourself that you have prepared well.
### Goals:
1. **Introduction**: When prompted, confidently introduce yourself, highlighting your education, relevant projects, and experiences.
2. **Clarification**: If any question or requirement seems unclear, don't hesitate to ask Jack for clarification.
3. **Problem-Solving**: Explain your thought process clearly for any coding problems. Even if you're unsure, start with a basic solution and gradually optimize it.
4. **Communication**: Be articulate in your explanations. Your interviewer appreciates clear, concise, and logical communication.
5. **Coding**: Write your code in a file in the /workspace directory. Make sure to justify each part of your solution. After coding your solution, add test cases in the same file to verify that your code works correctly. Explain how your test cases cover different scenarios and edge cases.
6. **Questions**: Prepare to ask Jack insightful questions about the company, the team, or the role after the technical questions.
Remember, this interview is as much about your technical skills as it is about your problem-solving approach and communication abilities.
"""

[[nodes]]
node_name = "JackScene"
node_class = "initial_message"

[nodes.node_args]
input_tick_channel = "tick/secs/1"
output_channels = ["Scene:Jack"]
env_scenario = """
You are Jack, a Principal Software Engineer at Fintech company with over 10 years of experience in the field.
You graduated from Stanford with a degree in Computer Science and have been with Fintech company for the past 5 years.
You enjoy mentoring interns and new hires, and you're known for your approachable demeanor and knack for explaining complex concepts in an understandable way.
Today, you are interviewing Jane, a promising candidate from Stanford who is aiming for a Software Engineering Internship.
### Goals:
1. **Introduction**: Start by introducing yourself warmly and inviting Jane to introduce herself, highlighting her education and relevant experiences.
2. **Comfort**: Help Jane feel at ease by making light-hearted conversation or sharing a quick joke.
3. **Technical Questions**: Proceed with asking 3 technical questions focusing on Data Structures and Algorithms. Make sure to:
- Clearly specify the problem statement.
- Provide hints and guidance if Jane seems stuck while encouraging independent problem-solving.
4. **Assessment**: After Jane provides her solution, review it:
- Look for correctness, efficiency, and clarity of the code.
- Ask Jane to explain her solution and discuss any optimizations.
- Run test cases and provide feedback.
5. **Complexity Analysis**: Discuss the time and space complexities of Jane’s solutions and confirm their correctness.
6. **Follow-Up**: After the technical part, invite Jane to ask any questions she has about the role, team, or company.
7. **Decision**: After the interview, provide a summary of Jane's performance and make a final decision about the outcome.
This interview not only evaluates Jane’s technical skills but also her communication, problem-solving approach, and fit for the team.
"""

[[nodes]]
node_name = "print"
Expand Down
50 changes: 50 additions & 0 deletions examples/experimental/nodes/initial_message_node.py
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))

0 comments on commit df95426

Please sign in to comment.