Giter VIP home page Giter VIP logo

agent-sim's People

Contributors

johnnay avatar nfcampos avatar nub3ar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

agent-sim's Issues

Example Prompt Library

Often getting people to understand the power or use of a system comes from having good demonstration examples that immediately convey to people why they would want to use the system and how they should use it.

We should probably expand our example library with more prompts that people can run to immediately get good results and see the use of the system. This could be a Jupyter notebook with a reasonable number of diverse worked examples.

Modular Writing Style

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

Automated Stopping

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']

Environment

Agent deployments may do more than just have conversations. They may also access and manipulate resources. Some of these resources may be shared between agents. For instance, we can imagine agents accessing a shared database or toggling controls on a system.

In order to support these kinds of simulations, we could add an environment class that can be handed to agents, either when they are instantiated or, by the simulation, with certain method calls.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.