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

Modular Writing Style #7

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

Modular Writing Style #7

chutcheson opened this issue Jun 30, 2023 · 0 comments

Comments

@chutcheson
Copy link

Often, you are going to want to determine agent message style and agent message strategy separately.

For instance, you may want to simulate an email exchange, a text exchange or a Slack or Discord conversation between agents and want the agent conversation to reflect the way humans normally write in these contexts. This could reflect where the agents will be deployed or for another reason, such as to make the text more readable for a human reviewer.

One possible solution for this would be to add a style module:

import json

from langchain.schema import SystemMessage, HumanMessage

from agent_sim.util import extract_json
from agent_sim.prompts_library import (
    STYLIST_USER_PROMPT,
    STYLIST_SYSTEM_PROMPT,
)

class Stylist:
    def __init__(self, model, style):
        self.model = model
        self.style = style

    def stylize(self, current_message):
        llm_messages = [
            SystemMessage(content=STYLIST_SYSTEM_PROMPT.format(style=self.style)),
            HumanMessage(content=STYLIST_USER_PROMPT.format(message=current_message))
        ]
        stylized_message = self.model.predict_messages(llm_messages).content
        return stylized_message

@chutcheson chutcheson changed the title Make Agent Writing Style Modular Modular Writing Style 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