forked from microsoft/autogen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Agent notebook example with human feedback; Support shell command and…
… multiple code blocks; Improve the system message for assistant agent; Improve utility functions for config lists; reuse docker image (microsoft#1056) * add agent notebook and documentation * fix bug * set flush to True when printing msg in agent * add a math problem in agent notebook * remove * header * improve notebook doc * notebook update * improve notebook example * improve doc * agent notebook example with user feedback * log * log * improve notebook doc * improve print * doc * human_input_mode * human_input_mode str * indent * indent * Update flaml/autogen/agent/user_proxy_agent.py Co-authored-by: Chi Wang <[email protected]> * shell command and multiple code blocks * Update notebook/autogen_agent.ipynb Co-authored-by: Chi Wang <[email protected]> * Update notebook/autogen_agent.ipynb Co-authored-by: Chi Wang <[email protected]> * Update notebook/autogen_agent.ipynb Co-authored-by: Chi Wang <[email protected]> * coding agent * math notebook * renaming and doc format * typo * infer lang * sh * docker * docker * reset consecutive autoreply counter * fix explanation * paper talk * human feedback * web info * rename test * config list explanation * link to blogpost * installation * homepage features * features * features * rename agent * remove notebook * notebook test * docker command * notebook update * lang -> cmd * notebook * make it work for gpt-3.5 * return full log * quote * docker * docker * docker * docker * docker * docker image list * notebook * notebook * use_docker * use_docker * use_docker * doc * agent * doc * abs path * pandas * docker * reuse docker image * context window * news * print format * pyspark version in py3.8 * pyspark in py3.8 * pyspark and ray * quote * pyspark * pyspark * pyspark --------- Co-authored-by: Qingyun Wu <[email protected]>
- Loading branch information
1 parent
d36b2af
commit 5387a0a
Showing
28 changed files
with
2,199 additions
and
1,283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .agent import Agent | ||
from .assistant_agent import AssistantAgent | ||
from .user_proxy_agent import UserProxyAgent | ||
|
||
__all__ = ["Agent", "AssistantAgent", "UserProxyAgent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from .agent import Agent | ||
from flaml.autogen.code_utils import DEFAULT_MODEL | ||
from flaml import oai | ||
|
||
|
||
class AssistantAgent(Agent): | ||
"""(Experimental) Assistant agent, able to suggest code blocks.""" | ||
|
||
DEFAULT_SYSTEM_MESSAGE = """You are a helpful AI assistant. | ||
In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute. You must indicate the script type in the code block. | ||
1. When you need to ask the user for some info, use the code to output the info you need, for example, browse or search the web, download/read a file. | ||
2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly. Solve the task step by step if you need to. | ||
If you want the user to save the code in a file before executing it, put # filename: <filename> inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user. | ||
If the result indicates there is an error, fix the error and output the code again. Suggeset the full code instead of partial code or code changes. | ||
Reply "TERMINATE" in the end when everything is done. | ||
""" | ||
|
||
DEFAULT_CONFIG = { | ||
"model": DEFAULT_MODEL, | ||
} | ||
|
||
def __init__(self, name, system_message=DEFAULT_SYSTEM_MESSAGE, **config): | ||
""" | ||
Args: | ||
name (str): agent name. | ||
system_message (str): system message to be sent to the agent. | ||
**config (dict): other configurations allowed in | ||
[oai.Completion.create](../oai/Completion#create). | ||
These configurations will be used when invoking LLM. | ||
""" | ||
super().__init__(name, system_message) | ||
self._config = self.DEFAULT_CONFIG.copy() | ||
self._config.update(config) | ||
self._sender_dict = {} | ||
|
||
def receive(self, message, sender): | ||
if sender.name not in self._sender_dict: | ||
self._sender_dict[sender.name] = sender | ||
self._conversations[sender.name] = [{"content": self._system_message, "role": "system"}] | ||
super().receive(message, sender) | ||
responses = oai.ChatCompletion.create(messages=self._conversations[sender.name], **self._config) | ||
response = oai.ChatCompletion.extract_text(responses)[0] | ||
self._send(response, sender) | ||
|
||
def reset(self): | ||
self._sender_dict.clear() | ||
self._conversations.clear() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.