Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
import asyncio
|
|
|
|
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
|
|
|
import json
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
from queue import Queue
|
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
|
|
|
import time
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
from typing import Any, List, Dict, Optional, Tuple
|
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
|
|
|
import os
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
from fastapi import WebSocket, WebSocketDisconnect
|
|
|
|
import websockets
|
|
|
|
from .datamodel import AgentWorkFlowConfig, Message, SocketMessage
|
|
|
|
from .utils import extract_successful_code_blocks, get_modified_files, summarize_chat_history
|
|
|
|
from .workflowmanager import 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
|
|
|
class AutoGenChatManager:
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
"""
|
|
|
|
This class handles the automated generation and management of chat interactions
|
|
|
|
using an automated workflow configuration and message queue.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, message_queue: Queue) -> None:
|
|
|
|
"""
|
|
|
|
Initializes the AutoGenChatManager with a message queue.
|
|
|
|
|
|
|
|
:param message_queue: A queue to use for sending messages asynchronously.
|
|
|
|
"""
|
|
|
|
self.message_queue = message_queue
|
|
|
|
|
|
|
|
def send(self, message: str) -> None:
|
|
|
|
"""
|
|
|
|
Sends a message by putting it into the message queue.
|
|
|
|
|
|
|
|
:param message: The message string to be sent.
|
|
|
|
"""
|
|
|
|
if self.message_queue is not None:
|
|
|
|
self.message_queue.put_nowait(message)
|
|
|
|
|
|
|
|
def chat(
|
|
|
|
self,
|
|
|
|
message: Message,
|
|
|
|
history: List[Dict[str, Any]],
|
|
|
|
flow_config: Optional[AgentWorkFlowConfig] = None,
|
|
|
|
connection_id: Optional[str] = None,
|
|
|
|
user_dir: Optional[str] = None,
|
|
|
|
**kwargs,
|
|
|
|
) -> Message:
|
|
|
|
"""
|
|
|
|
Processes an incoming message according to the agent's workflow configuration
|
|
|
|
and generates a response.
|
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
|
|
|
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
:param message: An instance of `Message` representing an incoming message.
|
|
|
|
:param history: A list of dictionaries, each representing a past interaction.
|
|
|
|
:param flow_config: An instance of `AgentWorkFlowConfig`. If None, defaults to a standard configuration.
|
|
|
|
:param connection_id: An optional connection identifier.
|
|
|
|
:param kwargs: Additional keyword arguments.
|
|
|
|
:return: An instance of `Message` representing a response.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# create a working director for workflow based on user_dir/session_id/time_hash
|
|
|
|
work_dir = os.path.join(user_dir, message.session_id, datetime.now().strftime("%Y%m%d_%H-%M-%S"))
|
|
|
|
os.makedirs(work_dir, exist_ok=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
|
|
|
|
|
|
|
# if no flow config is provided, use the default
|
|
|
|
if flow_config is None:
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
raise ValueError("flow_config must be specified")
|
|
|
|
|
|
|
|
flow = AutoGenWorkFlowManager(
|
|
|
|
config=flow_config,
|
|
|
|
history=history,
|
|
|
|
work_dir=work_dir,
|
|
|
|
send_message_function=self.send,
|
|
|
|
connection_id=connection_id,
|
|
|
|
)
|
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
|
|
|
|
|
|
|
message_text = message.content.strip()
|
|
|
|
|
|
|
|
start_time = time.time()
|
|
|
|
flow.run(message=f"{message_text}", clear_history=False)
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
end_time = time.time()
|
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
|
|
|
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
metadata = {
|
|
|
|
"messages": flow.agent_history,
|
|
|
|
"summary_method": flow_config.summary_method,
|
|
|
|
"time": end_time - start_time,
|
|
|
|
"files": get_modified_files(start_time, end_time, source_dir=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
|
|
|
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
print("Modified files: ", len(metadata["files"]))
|
|
|
|
|
|
|
|
output = self._generate_output(message_text, flow, flow_config)
|
|
|
|
|
|
|
|
output_message = Message(
|
|
|
|
user_id=message.user_id,
|
|
|
|
root_msg_id=message.root_msg_id,
|
|
|
|
role="assistant",
|
|
|
|
content=output,
|
|
|
|
metadata=json.dumps(metadata),
|
|
|
|
session_id=message.session_id,
|
|
|
|
)
|
|
|
|
|
|
|
|
return output_message
|
2023-12-24 04:20:59 -08:00
|
|
|
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
def _generate_output(
|
|
|
|
self, message_text: str, flow: AutoGenWorkFlowManager, flow_config: AgentWorkFlowConfig
|
|
|
|
) -> str:
|
|
|
|
"""
|
|
|
|
Generates the output response based on the workflow configuration and agent history.
|
|
|
|
|
|
|
|
:param message_text: The text of the incoming message.
|
|
|
|
:param flow: An instance of `AutoGenWorkFlowManager`.
|
|
|
|
:param flow_config: An instance of `AgentWorkFlowConfig`.
|
|
|
|
:return: The output response as a string.
|
|
|
|
"""
|
|
|
|
|
|
|
|
output = ""
|
2023-12-24 04:20:59 -08:00
|
|
|
if flow_config.summary_method == "last":
|
|
|
|
successful_code_blocks = extract_successful_code_blocks(flow.agent_history)
|
Autogenstudio Updates [CSV support, Workflow Export, Skill Editing, Windows Testing ] (#1475)
* support groupchat, other QOL fixes
* remove gallery success toast
* Fix #1328. Add CSVLoader component and related support for rendering CSV files. Add download link in the modal for appropriate file types including CSV, Code, and PDF.
* add name and description field to session datamodel
* Update website/blog/2023-12-01-AutoGenStudio/index.mdx
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
* sanitize llmconfig, remove additional fields
* improve models UX, only modify models from model tab.
* readme updates
* improve db defaults
* improve ui hover behavior and add note on models
* general qol updats
* add support for returning summary_method
* use ant design tables
* icon and layout updates
* css and layout updates
* readme updates and QOL updates
* fix bug where empty string is used as apikey #1415
* add speaker selection to UI #1373
* Fixed a bug that localAgent updates were not synchronized between GroupChatFlowSpecView and AgentFlowSpecView.
* Fixed a bug in Agent Specification Modal that caused localAgent updates to remain in state when closing a modal other than onOk.
* Fixed a bug that the updated Agent Specification Modal was not saved when the content of FlowConfigViewer Modal was changed after the Agent Specification Modal was updated when an updatedFlowConfig was created using localFlowConfig.
* add version to package
* remove sample key
* early support for versions table and testing models
* Add support for testing model when created #1404
* remove unused imports, qol updates
* fix bug on workflowmanager
* make file_name optional in skills datamodel
* update instructions on models
* fix errors from merge conflict with main
* santize workflow before download
* add support for editing skills in full fledged editor (monaco) #1442
* fix merge artifacts
* Fix build command for windows
Replaced && to & to continue execution when the 'ui' folder doesn't exist and also suppressed error "The system cannot find the file specified."
* Fix setup instructions
The config file starts with a dot (according to gatsby-config.ts).
* Throw error if env file doesn't exist
Otherwise the app will not work (issue very hard to trace)
* version bump
* formattin gupdates
* formatting updates
* Show warning instead of error if env config file doesn't exist
Fix: https://github.com/microsoft/autogen/pull/1475#issuecomment-1918114520
* add rel noopener to a tags
* formating updates
* remove double section in readme.
* update dev readme
* format update
* add default autoreply to agent config datamodel
* add check for empty messages list
* improve groupchat behavior, add sender to list of agents
* update system_message defaults to fit autogen default system message #1474
* simplify response from test_model to only return content, fix serialization issue in #1404
* readme and other formatting updates
* add support for showing temp and default auto reply #1521
* formatting updates
* formating and other updates
---------
Co-authored-by: Paul Retherford <paul@scanpower.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: junkei_okinawa <ceazy.x2.okinawan@gmail.com>
Co-authored-by: Christopher Pereira <kripper@imatronix.com>
2024-02-05 18:45:18 -08:00
|
|
|
last_message = flow.agent_history[-1]["message"]["content"] if flow.agent_history else ""
|
2023-12-24 04:20:59 -08:00
|
|
|
successful_code_blocks = "\n\n".join(successful_code_blocks)
|
|
|
|
output = (last_message + "\n" + successful_code_blocks) if successful_code_blocks else last_message
|
|
|
|
elif flow_config.summary_method == "llm":
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
model = flow.config.receiver.config.llm_config.config_list[0]
|
|
|
|
status_message = SocketMessage(
|
|
|
|
type="agent_status",
|
|
|
|
data={"status": "summarizing", "message": "Generating summary of agent dialogue"},
|
|
|
|
connection_id=flow.connection_id,
|
|
|
|
)
|
|
|
|
self.send(status_message.dict())
|
|
|
|
output = summarize_chat_history(task=message_text, messages=flow.agent_history, model=model)
|
|
|
|
|
2023-12-24 04:20:59 -08:00
|
|
|
elif flow_config.summary_method == "none":
|
|
|
|
output = ""
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
return output
|
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
|
|
|
|
|
|
|
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
class WebSocketConnectionManager:
|
|
|
|
"""
|
|
|
|
Manages WebSocket connections including sending, broadcasting, and managing the lifecycle of connections.
|
|
|
|
"""
|
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
|
|
|
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
def __init__(
|
|
|
|
self, active_connections: List[Tuple[WebSocket, str]] = None, active_connections_lock: asyncio.Lock = None
|
|
|
|
) -> None:
|
|
|
|
"""
|
|
|
|
Initializes WebSocketConnectionManager with an optional list of active WebSocket connections.
|
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
|
|
|
|
Autogenstudio Updates [Upload/Dowload of Skills/Workflows, Streaming Agent Replies, Agent Message Summarization] (#1801)
* update default agent system message
* session friendly name functionality
* minor formatting
* fix issues with groupchat and version bump
* fix issues with groupchat and version bump. address #1580
* update groupchat system message
* add support for copying message in chatbox
* rewrite how agent history is maintained in workflow manager. Directly extend GroupChat and Conversable agent and override process_message method. Allow passing a message processor.
Fixes bug where the last message from a groupchat manager does not get called via register_reply.
* general qol updates
* add support for downloading + copying skills, models and agents from UI
* add regex check to agent name, address #1507
* add support for uploading workflow files
* refactor, add support for streaming intermediate agent response to ui
* improve streaming ux
* add support for uploading skills, models, agents, workflows
* add datamodel for socket message
* version update
* fix chatbox height bug
* fix csv pagination issue
* improve hidden menu for uploading entities
* fix minor issue with animation timing on chat interface
* version bump, css fixes
* use description field in autogen conversable class for description
* add implementation for llm summarization of agent chat
* support for llm summary of agent history
* formatting fixes
* formatting updates
* add dockerfile to run autogenstudio in a docker contailer
* autogenstudio docker container
* updates to websockets
* update socket connection logic,
* support using socket for passing message requests where a socket is available
* improve command for building frontend
* formatting updates
* remove duplicated code
# overwrite skills.py in work_dir is duplicated
* update description location
as Where the code calls is like config.description
* version bump
* refactor to ensure each session and call within a session has an independent working directory
* support use of socket for sending messages where available
* use rsync to copy built files to ui direction instead of cp -rT
* spelling correctino
* readme update
* fix numpy version
* version bump
* add support for dot env variables and updating default app dir to /home/<user>/.autogenstudio
* formatting update
* update gitignore
* formatting updates
---------
Co-authored-by: James Woffinden-Luey <jluey@microsoft.com>
Co-authored-by: cillyfly <cillyfly@gmail.com>
2024-03-15 19:44:47 -07:00
|
|
|
:param active_connections: A list of tuples, each containing a WebSocket object and its corresponding client_id.
|
|
|
|
"""
|
|
|
|
if active_connections is None:
|
|
|
|
active_connections = []
|
|
|
|
self.active_connections_lock = active_connections_lock
|
|
|
|
self.active_connections: List[Tuple[WebSocket, str]] = active_connections
|
|
|
|
|
|
|
|
async def connect(self, websocket: WebSocket, client_id: str) -> None:
|
|
|
|
"""
|
|
|
|
Accepts a new WebSocket connection and appends it to the active connections list.
|
|
|
|
|
|
|
|
:param websocket: The WebSocket instance representing a client connection.
|
|
|
|
:param client_id: A string representing the unique identifier of the client.
|
|
|
|
"""
|
|
|
|
await websocket.accept()
|
|
|
|
async with self.active_connections_lock:
|
|
|
|
self.active_connections.append((websocket, client_id))
|
|
|
|
print(f"New Connection: {client_id}, Total: {len(self.active_connections)}")
|
|
|
|
|
|
|
|
async def disconnect(self, websocket: WebSocket) -> None:
|
|
|
|
"""
|
|
|
|
Disconnects and removes a WebSocket connection from the active connections list.
|
|
|
|
|
|
|
|
:param websocket: The WebSocket instance to remove.
|
|
|
|
"""
|
|
|
|
async with self.active_connections_lock:
|
|
|
|
try:
|
|
|
|
self.active_connections = [conn for conn in self.active_connections if conn[0] != websocket]
|
|
|
|
print(f"Connection Closed. Total: {len(self.active_connections)}")
|
|
|
|
except ValueError:
|
|
|
|
print("Error: WebSocket connection not found")
|
|
|
|
|
|
|
|
async def disconnect_all(self) -> None:
|
|
|
|
"""
|
|
|
|
Disconnects all active WebSocket connections.
|
|
|
|
"""
|
|
|
|
for connection, _ in self.active_connections[:]:
|
|
|
|
await self.disconnect(connection)
|
|
|
|
|
|
|
|
async def send_message(self, message: Dict, websocket: WebSocket) -> None:
|
|
|
|
"""
|
|
|
|
Sends a JSON message to a single WebSocket connection.
|
|
|
|
|
|
|
|
:param message: A JSON serializable dictionary containing the message to send.
|
|
|
|
:param websocket: The WebSocket instance through which to send the message.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
async with self.active_connections_lock:
|
|
|
|
await websocket.send_json(message)
|
|
|
|
except WebSocketDisconnect:
|
|
|
|
print("Error: Tried to send a message to a closed WebSocket")
|
|
|
|
await self.disconnect(websocket)
|
|
|
|
except websockets.exceptions.ConnectionClosedOK:
|
|
|
|
print("Error: WebSocket connection closed normally")
|
|
|
|
await self.disconnect(websocket)
|
|
|
|
except Exception as e:
|
|
|
|
print(f"Error in sending message: {str(e)}")
|
|
|
|
await self.disconnect(websocket)
|
|
|
|
|
|
|
|
async def broadcast(self, message: Dict) -> None:
|
|
|
|
"""
|
|
|
|
Broadcasts a JSON message to all active WebSocket connections.
|
|
|
|
|
|
|
|
:param message: A JSON serializable dictionary containing the message to broadcast.
|
|
|
|
"""
|
|
|
|
# Create a message dictionary with the desired format
|
|
|
|
message_dict = {"message": message}
|
|
|
|
|
|
|
|
for connection, _ in self.active_connections[:]:
|
|
|
|
try:
|
|
|
|
if connection.client_state == websockets.protocol.State.OPEN:
|
|
|
|
# Call send_message method with the message dictionary and current WebSocket connection
|
|
|
|
await self.send_message(message_dict, connection)
|
|
|
|
else:
|
|
|
|
print("Error: WebSocket connection is closed")
|
|
|
|
await self.disconnect(connection)
|
|
|
|
except (WebSocketDisconnect, websockets.exceptions.ConnectionClosedOK) as e:
|
|
|
|
print(f"Error: WebSocket disconnected or closed({str(e)})")
|
|
|
|
await self.disconnect(connection)
|