Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated Stopping #6

Open
chutcheson opened this issue Jun 30, 2023 · 0 comments
Open

Automated Stopping #6

chutcheson opened this issue Jun 30, 2023 · 0 comments

Comments

@chutcheson
Copy link

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']
@chutcheson chutcheson changed the title Automated Stopping upon Condition Automated Stopping Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant