Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
from typing import List, Optional
|
|
|
|
from dataclasses import asdict
|
|
|
|
import autogen
|
2024-01-23 11:59:58 -08:00
|
|
|
from .datamodel import AgentConfig, AgentFlowSpec, AgentWorkFlowConfig, GroupChatConfig, Message
|
2023-12-24 04:20:59 -08:00
|
|
|
from .utils import get_skills_from_prompt, clear_folder
|
|
|
|
from datetime import datetime
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
|
|
|
|
|
2023-12-01 16:22:02 -08:00
|
|
|
class AutoGenWorkFlowManager:
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
"""
|
2023-12-01 16:22:02 -08:00
|
|
|
AutoGenWorkFlowManager class to load agents from a provided configuration and run a chat between them
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(
|
2023-12-01 16:22:02 -08:00
|
|
|
self,
|
|
|
|
config: AgentWorkFlowConfig,
|
|
|
|
history: Optional[List[Message]] = None,
|
|
|
|
work_dir: str = None,
|
2023-12-24 04:20:59 -08:00
|
|
|
clear_work_dir: bool = True,
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
) -> None:
|
|
|
|
"""
|
|
|
|
Initializes the AutoGenFlow with agents specified in the config and optional
|
|
|
|
message history.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
config: The configuration settings for the sender and receiver agents.
|
|
|
|
history: An optional list of previous messages to populate the agents' history.
|
|
|
|
|
|
|
|
"""
|
2023-12-01 16:22:02 -08:00
|
|
|
self.work_dir = work_dir or "work_dir"
|
2023-12-24 04:20:59 -08:00
|
|
|
if clear_work_dir:
|
|
|
|
clear_folder(self.work_dir)
|
|
|
|
|
2024-01-23 11:59:58 -08:00
|
|
|
# given the config, return an AutoGen agent object
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
self.sender = self.load(config.sender)
|
2024-01-23 11:59:58 -08:00
|
|
|
# given the config, return an AutoGen agent object
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
self.receiver = self.load(config.receiver)
|
2023-12-24 04:20:59 -08:00
|
|
|
self.agent_history = []
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
|
|
|
|
if history:
|
|
|
|
self.populate_history(history)
|
|
|
|
|
2023-12-24 04:20:59 -08:00
|
|
|
def process_reply(self, recipient, messages, sender, config):
|
|
|
|
if "callback" in config and config["callback"] is not None:
|
|
|
|
callback = config["callback"]
|
|
|
|
callback(sender, recipient, messages[-1])
|
2024-01-23 11:59:58 -08:00
|
|
|
last_message = messages[-1]
|
|
|
|
|
|
|
|
sender = sender.name
|
|
|
|
recipient = recipient.name
|
|
|
|
if "name" in last_message:
|
|
|
|
sender = last_message["name"]
|
|
|
|
|
2023-12-24 04:20:59 -08:00
|
|
|
iteration = {
|
2024-01-23 11:59:58 -08:00
|
|
|
"recipient": recipient,
|
|
|
|
"sender": sender,
|
|
|
|
"message": last_message,
|
2023-12-24 04:20:59 -08:00
|
|
|
"timestamp": datetime.now().isoformat(),
|
|
|
|
}
|
|
|
|
self.agent_history.append(iteration)
|
|
|
|
return False, None
|
|
|
|
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
def _sanitize_history_message(self, message: str) -> str:
|
|
|
|
"""
|
|
|
|
Sanitizes the message e.g. remove references to execution completed
|
|
|
|
|
|
|
|
Args:
|
|
|
|
message: The message to be sanitized.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
The sanitized message.
|
|
|
|
"""
|
|
|
|
to_replace = ["execution succeeded", "exitcode"]
|
|
|
|
for replace in to_replace:
|
|
|
|
message = message.replace(replace, "")
|
|
|
|
return message
|
|
|
|
|
|
|
|
def populate_history(self, history: List[Message]) -> None:
|
|
|
|
"""
|
|
|
|
Populates the agent message history from the provided list of messages.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
history: A list of messages to populate the agents' history.
|
|
|
|
"""
|
|
|
|
for msg in history:
|
|
|
|
if isinstance(msg, dict):
|
|
|
|
msg = Message(**msg)
|
|
|
|
if msg.role == "user":
|
|
|
|
self.sender.send(
|
|
|
|
msg.content,
|
|
|
|
self.receiver,
|
|
|
|
request_reply=False,
|
|
|
|
)
|
|
|
|
elif msg.role == "assistant":
|
|
|
|
self.receiver.send(
|
|
|
|
msg.content,
|
|
|
|
self.sender,
|
|
|
|
request_reply=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
def sanitize_agent_spec(self, agent_spec: AgentFlowSpec) -> AgentFlowSpec:
|
|
|
|
"""
|
|
|
|
Sanitizes the agent spec by setting loading defaults
|
|
|
|
|
|
|
|
Args:
|
|
|
|
config: The agent configuration to be sanitized.
|
|
|
|
agent_type: The type of the agent.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
The sanitized agent configuration.
|
|
|
|
"""
|
|
|
|
|
|
|
|
agent_spec.config.is_termination_msg = agent_spec.config.is_termination_msg or (
|
2024-01-23 11:59:58 -08:00
|
|
|
lambda x: "TERMINATE" in x.get("content", "").rstrip()[-20:]
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
)
|
2023-12-24 04:20:59 -08:00
|
|
|
skills_prompt = ""
|
|
|
|
if agent_spec.skills:
|
|
|
|
# get skill prompt, also write skills to a file named skills.py
|
|
|
|
skills_prompt = get_skills_from_prompt(agent_spec.skills, self.work_dir)
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
|
|
|
|
if agent_spec.type == "userproxy":
|
|
|
|
code_execution_config = agent_spec.config.code_execution_config or {}
|
|
|
|
code_execution_config["work_dir"] = self.work_dir
|
|
|
|
agent_spec.config.code_execution_config = code_execution_config
|
2023-12-01 16:22:02 -08:00
|
|
|
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
if agent_spec.type == "assistant":
|
|
|
|
agent_spec.config.system_message = (
|
|
|
|
autogen.AssistantAgent.DEFAULT_SYSTEM_MESSAGE
|
|
|
|
+ "\n\n"
|
|
|
|
+ agent_spec.config.system_message
|
|
|
|
+ "\n\n"
|
2023-12-24 04:20:59 -08:00
|
|
|
+ skills_prompt
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
return agent_spec
|
|
|
|
|
|
|
|
def load(self, agent_spec: AgentFlowSpec) -> autogen.Agent:
|
|
|
|
"""
|
|
|
|
Loads an agent based on the provided agent specification.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
agent_spec: The specification of the agent to be loaded.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
An instance of the loaded agent.
|
|
|
|
"""
|
2024-01-23 11:59:58 -08:00
|
|
|
|
|
|
|
if agent_spec.type == "groupchat":
|
|
|
|
agents = [
|
|
|
|
self.load(self.sanitize_agent_spec(agent_config)) for agent_config in agent_spec.groupchat_config.agents
|
|
|
|
]
|
|
|
|
group_chat_config = agent_spec.groupchat_config.dict()
|
|
|
|
group_chat_config["agents"] = agents
|
|
|
|
groupchat = autogen.GroupChat(**group_chat_config)
|
|
|
|
manager = autogen.GroupChatManager(groupchat=groupchat, **agent_spec.config.dict())
|
|
|
|
return manager
|
|
|
|
|
|
|
|
else:
|
|
|
|
agent_spec = self.sanitize_agent_spec(agent_spec)
|
|
|
|
agent = self.load_agent_config(agent_spec.config, agent_spec.type)
|
|
|
|
return agent
|
|
|
|
|
|
|
|
def load_agent_config(self, agent_config: AgentConfig, agent_type: str) -> autogen.Agent:
|
|
|
|
"""
|
|
|
|
Loads an agent based on the provided agent configuration.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
agent_config: The configuration of the agent to be loaded.
|
|
|
|
agent_type: The type of the agent to be loaded.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
An instance of the loaded agent.
|
|
|
|
"""
|
|
|
|
if agent_type == "assistant":
|
|
|
|
agent = autogen.AssistantAgent(**agent_config.dict())
|
2023-12-24 04:20:59 -08:00
|
|
|
agent.register_reply([autogen.Agent, None], reply_func=self.process_reply, config={"callback": None})
|
2024-01-23 11:59:58 -08:00
|
|
|
elif agent_type == "userproxy":
|
|
|
|
agent = autogen.UserProxyAgent(**agent_config.dict())
|
2023-12-24 04:20:59 -08:00
|
|
|
agent.register_reply([autogen.Agent, None], reply_func=self.process_reply, config={"callback": None})
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
else:
|
2024-01-23 11:59:58 -08:00
|
|
|
raise ValueError(f"Unknown agent type: {agent_type}")
|
Sample Web Application Built with AutoGen (#695)
* Adding research assistant code
* Adding research assistant code
* checking in RA files
* Remove used text file
* Update README.md to include Saleema's name to the Contributors list.
* remove extraneous files
* update gitignore
* improve structure on global skills
* fix linting error
* readme update
* readme update
* fix wrong function bug
* readme update
* update ui build
* cleanup, remove unused modules
* readme and docs updates
* set default user
* ui build update
* add screenshot to improve instructions
* remove logout behaviour, replace with note to developers to add their own logout logic
* Create blog and edit ARA README
* Added the stock prices example in the readme for ARA
* Include edits from review with Saleema
* fix format issues
* Cosmetic changes for betting debug messages
* edit authors
* remove references to request_timeout to support autogen v0.0.2
* update bg color for UI
* readme update
* update research assistant blog post
* omit samples folder from codecov
* ui build update + precommit refactor
* formattiing updates fromo pre-commit
* readme update
* remove compiled source files
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* update gitignore
* refactor, file removals
* refactor for improved structure - datamodel, chat and db helper
* refactor skills view
* general refactor
* gitignore update and general refactor
* skills update
* general refactor
* ui folder structure refactor
* improve support for skills loading
* add fetch profile default skill
* refactor chat to autogenchat
* qol refactor
* improve metadata display
* early support for autogenflow in ui
* docs update general refactor
* general refactor
* readme update
* readme update
* readme and cli update
* pre-commit updates
* precommit update
* readme update
* add steup.py for older python build versions
* add manifest.in, update app icon
* in-progress changes to agent specification
* remove use_cache refs
* update datamodel, and fix for default serverurl
* request_timeout
* readme update, fix autogen values
* fix pyautogen version
* precommit formatting and other qol items
* update folder structure
* req update
* readme and docs update
* docs update
* remove duplicate in yaml file
* add support for explicit skills addition
* readme and documentation updates
* general refactor
* remove blog post, schedule for future PR
* readme update, add info on llmconfig
* make use_cache False by default unless set
* minor ui updates
* upgrade ui to use latest uatogen lib version 0.2.0b5
* Ui refactor, support for adding arbitrary model specifications
* formatting/precommit checks
* update readme, utils default skill
---------
Co-authored-by: Piali Choudhury <pialic@microsoft.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2023-11-20 10:40:30 -08:00
|
|
|
return agent
|
|
|
|
|
|
|
|
def run(self, message: str, clear_history: bool = False) -> None:
|
|
|
|
"""
|
|
|
|
Initiates a chat between the sender and receiver agents with an initial message
|
|
|
|
and an option to clear the history.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
message: The initial message to start the chat.
|
|
|
|
clear_history: If set to True, clears the chat history before initiating.
|
|
|
|
"""
|
|
|
|
self.sender.initiate_chat(
|
|
|
|
self.receiver,
|
|
|
|
message=message,
|
|
|
|
clear_history=clear_history,
|
|
|
|
)
|