You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the simulation ends after a predefined number of turns. This can lead to waste where the desired stopping point occurs before the predefined number of turns.
To solve this, we could add a monitor class that would check for a condition at the end of each agent's "turn" in the simulation and break the simulation loop in the event that the condition has been satisfied.
Example:
import json
from langchain.schema import SystemMessage, HumanMessage
from agent_sim.util import extract_json
from agent_sim.prompts_library import (
MONITOR_USER_PROMPT,
MONITOR_SYSTEM_PROMPT,
)
class Monitor:
def __init__(self, model, condition):
self.model = model
self.condition = condition
def check_condition(self, message_history):
llm_messages = [
SystemMessage(content=MONITOR_SYSTEM_PROMPT),
HumanMessage(content=MONITOR_USER_PROMPT.format(messages=message_history, condition=self.condition))
]
response = self.model.predict_messages(llm_messages).content
print(response)
json_response = extract_json(self.model, response)
return json_response['condition']
The text was updated successfully, but these errors were encountered:
chutcheson
changed the title
Automated Stopping upon Condition
Automated Stopping
Jun 30, 2023
Right now, the simulation ends after a predefined number of turns. This can lead to waste where the desired stopping point occurs before the predefined number of turns.
To solve this, we could add a monitor class that would check for a condition at the end of each agent's "turn" in the simulation and break the simulation loop in the event that the condition has been satisfied.
Example:
The text was updated successfully, but these errors were encountered: