Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing IOStream protocol and adding support for websockets #1551

Merged
merged 72 commits into from
Mar 26, 2024

Conversation

davorrunje
Copy link
Collaborator

@davorrunje davorrunje commented Feb 5, 2024

The goals of this PR are:

  • introduction of IOStream class and a mechanism to change the default output from the console to alternative outputs such as websockets
  • Introduction of IOWebsockets class that can be used to output streams to websocket.

The plan is to accomplish this by the following steps:

  • introducing a new protocol IOStream with print and input methods
  • creating an IOConsole implementing the protocol using console
  • refactoring ConversableAgent, OpenAIClient and OpenAIWrapper to use IOStream internally
  • testing ConversableAgent, OpenAIClient and OpenAIWrapper using IOConsole
  • creating an IOWebSockets implementing the protocol using web sockets
  • testing IOWebSockets with unit tests (a bit tricky because it has to be a multithreaded test)
  • testing IOWebSockets with a new notebook
  • write documentation for implementing classes implementing IOStream protocol

Why are these changes needed?

Related issue number

Closes #1199 , closes #1143 , closes #217 , closes #394

Related pull requests

#1290, #1414

Checks

@davorrunje davorrunje marked this pull request as draft February 5, 2024 22:05
@tyler-suard-parker
Copy link
Contributor

@davorrunje Congratulations, I have seen you working hard every day on this feature for months! Excellent work.

@ekzhu
Copy link
Collaborator

ekzhu commented Mar 26, 2024

Merging this to anticipate changes in #2030 for structured output of prints.

Can you also create a topic page under /website/docs/topics/ to explain how to use this streaming util? You can simply copy the notebook to the /website/docs/topics/iostream.ipynb to make it available as a web page. I think the first example should be just about the utils not involving any agents: how to redirect iostream to a different place, etc. to illustrate the usage. Then you can show an example of using with ... context manager to change the output stream to a file, for example.

@ekzhu ekzhu disabled auto-merge March 26, 2024 21:07
@sonichi sonichi requested a review from cheng-tan March 26, 2024 21:20
@davorrunje
Copy link
Collaborator Author

Merging this to anticipate changes in #2030 for structured output of prints.

Can you also create a topic page under /website/docs/topics/ to explain how to use this streaming util? You can simply copy the notebook to the /website/docs/topics/iostream.ipynb to make it available as a web page. I think the first example should be just about the utils not involving any agents: how to redirect iostream to a different place, etc. to illustrate the usage. Then you can show an example of using with ... context manager to change the output stream to a file, for example.

@ekzhu sure, I'll do it tomorrow night.

@sonichi sonichi added this pull request to the merge queue Mar 26, 2024
Merged via the queue into main with commit 78aa0eb Mar 26, 2024
72 checks passed
@ekzhu ekzhu deleted the add-output-protocol branch March 26, 2024 23:13
@beckortikov
Copy link

beckortikov commented Mar 29, 2024

davorrunje Getting problem with this notebook

 - test_setup() with websocket server running on ws://127.0.0.1:8765.
 - on_connect(): Connected to client using IOWebsockets <autogen.io.websockets.IOWebsockets object at 0x0000021BDE10ED70> - Connected to server on ws://127.0.0.1:8765

 - on_connect(): Receiving message from client. - Sending message to server.

 - IOWebsockets._handler(): Error in on_connect: [Errno 22] Cache directory "./C:\Users\erifi\AppData\Local\Temp\tmpa7t3_152/42" does not exist and could not be created
Traceback (most recent call last):

sharsha315 pushed a commit to sharsha315/autogen that referenced this pull request Mar 29, 2024
…osoft#1551)

* Introducing IOStream

* bug fixing

* polishing

* refactoring

* refactoring

* refactoring

* wip: async tests

* websockets added

* wip

* merge with main

* notebook added

* FastAPI example added

* wip

* merge

* getter/setter to iostream added

* website/blog/2024-03-03-AutoGen-Update/img/dalle_gpt4v.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/gaia.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/teach.png: convert to Git LFS

* add SSL support

* wip

* wip

* exception handling added to on_connect()

* refactoring: default iostream is being set in a context manager

* test fix

* polishing

* polishing

* polishing

* fixed bug with new thread

* polishing

* a bit of refactoring and docs added

* notebook added to docs

* type checking added to CI

* CI fix

* CI fix

* CI fix

* polishing

* obsolete todo comment removed

* fixed precommit error

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
@SsspongeBob
Copy link

SsspongeBob commented Mar 30, 2024

davorrunje Getting problem with this notebook

 - test_setup() with websocket server running on ws://127.0.0.1:8765.
 - on_connect(): Connected to client using IOWebsockets <autogen.io.websockets.IOWebsockets object at 0x0000021BDE10ED70> - Connected to server on ws://127.0.0.1:8765

 - on_connect(): Receiving message from client. - Sending message to server.

 - IOWebsockets._handler(): Error in on_connect: [Errno 22] Cache directory "./C:\Users\erifi\AppData\Local\Temp\tmpa7t3_152/42" does not exist and could not be created
Traceback (most recent call last):

@beckortikov The author provided the answer above; you can scroll up to see it.
image

@davorrunje
Copy link
Collaborator Author

davorrunje Getting problem with this notebook

  • test_setup() with websocket server running on ws://127.0.0.1:8765.
  • on_connect(): Connected to client using IOWebsockets <autogen.io.websockets.IOWebsockets object at 0x0000021BDE10ED70> - Connected to server on ws://127.0.0.1:8765
  • on_connect(): Receiving message from client. - Sending message to server.
  • IOWebsockets._handler(): Error in on_connect: [Errno 22] Cache directory "./C:\Users\erifi\AppData\Local\Temp\tmpa7t3_152/42" does not exist and could not be created

Traceback (most recent call last):

@beckortikov The author provided the answer above; you can scroll up to see it.

image

Thanx for reporting it, the workaround is above. I'll update the notebook.

@beckortikov
Copy link

@davorrunje Thank you sir! I have also one questions. How can I implement it to AI chat with human_input_mode ALWAYS, where I also have function calls. Looking for a lot of issues, but couldn't find any solution how to deploy it through FastAPI, and make conversable agent. Will begreat if you could provide little code in this case. Thank you!

@davorrunje
Copy link
Collaborator Author

@davorrunje Thank you sir! I have also one questions. How can I implement it to AI chat with human_input_mode ALWAYS, where I also have function calls. Looking for a lot of issues, but couldn't find any solution how to deploy it through FastAPI, and make conversable agent. Will begreat if you could provide little code in this case. Thank you!

@beckortikov can you please check out https://captn.ai/ for an example of a larger system built with this and related code not yet merged into autogen?

I’ll factor out the mechanism to build it and open-source it in the following weeks. One major part is distributing it to multiple workers and streaming results back to clients. The streaming part was merged this week into autogen. The distribution of workers is not yet as it is a bit more complex to factor it out. There is also a code injection mechanism with a bunch of security related features. LLM never get any sensitive information about users, but functions called by LLM have access to it through code injection. There are also helpers like a decorator for checking if the user explicitly approves calling a function with specific parameters (when human mode is never). Anyway, you should be able to easily build something like this very soon.

@davorrunje davorrunje mentioned this pull request Mar 31, 2024
3 tasks
github-merge-queue bot pushed a commit that referenced this pull request Apr 3, 2024
* DOC FIX - Formatted Docstrings for the retrieve_user_proxy_agent.py and Added first single line for the class RetrieveUserProxyAgent.

* DOC FIX - Formatted Docstrings for  theinitiate_chats functiion of ChatResult class in  autogen/agentchat/chat.py

* Add vision capability (#2025)

* Add vision capability

* Configurate: description_prompt

* Print warning instead of raising issues for type

* Skip vision capability test if dependencies not installed

* Append "vision" to agent's system message when enabled VisionCapability

* GPT-4V notebook update with ConversableAgent

* Clean GPT-4V notebook

* Add vision capability test to workflow

* Lint import

* Update system message for vision capability

* Add a `custom_caption_func` to VisionCapability

* Add custom function example for vision capability

* Skip test Vision capability custom func

* GPT-4V notebook metadata to website

* Remove redundant files

* The custom caption function takes more inputs now

* Add a more complex example of custom caption func

* Remove trailing space

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Native tool call support for Mistral AI API and topic notebook. (#2135)

* Support for Mistral AI API and topic notebook.

* formatting

* formatting

* New conversational chess notebook using nested chats and tool use (#2137)

* add chess notebook

* update

* update

* Update notebook with figure

* Add example link

* redirect

* Clean up example format

* address gagan's comments

* update references

* fix links

* add webarena in samples (#2114)

* add webarena in samples/tools

* Update samples/tools/webarena/README.md

Co-authored-by: gagb <gagb@users.noreply.github.com>

* Update samples/tools/webarena/README.md

Co-authored-by: gagb <gagb@users.noreply.github.com>

* Update samples/tools/webarena/README.md

Co-authored-by: gagb <gagb@users.noreply.github.com>

* update installation instructions

* black formatting

* Update README.md

---------

Co-authored-by: gagb <gagb@users.noreply.github.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* context to kwargs (#2064)

* context to kwargs

* add tag

* add test

* text to kwargs

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /website (#2131)

Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4.
- [Release notes](https://github.com/webpack/webpack-dev-middleware/releases)
- [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md)
- [Commits](webpack/webpack-dev-middleware@v5.3.3...v5.3.4)

---
updated-dependencies:
- dependency-name: webpack-dev-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* Parse Any HTML-esh Style Tags (#2046)

* tried implementing my own regex

* improves tests

* finally works

* removes prints

* fixed test

* adds start and end

* delete unused imports

* refactored to use new tool

* significantly improved algo

* tag content -> tag attr

* fix tests + adds new field

* return full match

* return remove start and end

* update docstrings

* update docstrings

* update docstrings

---------

Co-authored-by: Beibin Li <BeibinLi@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Integrate AgentOptimizer (#1767)

* draft agent optimizer

* refactor

* remove

* change openai config interface

* notebook

* update blog

* add test

* clean up

* redir

* update

* update interface

* change model name

* move to contrib

* Update autogen/agentchat/contrib/agent_optimizer.py

Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>

---------

Co-authored-by: “skzhang1” <“shaokunzhang529@gmail.com”>
Co-authored-by: Beibin Li <BeibinLi@users.noreply.github.com>
Co-authored-by: Jieyu Zhang <jieyuz2@cs.washington.edu>
Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>

* Introducing IOStream protocol and adding support for websockets (#1551)

* Introducing IOStream

* bug fixing

* polishing

* refactoring

* refactoring

* refactoring

* wip: async tests

* websockets added

* wip

* merge with main

* notebook added

* FastAPI example added

* wip

* merge

* getter/setter to iostream added

* website/blog/2024-03-03-AutoGen-Update/img/dalle_gpt4v.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/gaia.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/teach.png: convert to Git LFS

* add SSL support

* wip

* wip

* exception handling added to on_connect()

* refactoring: default iostream is being set in a context manager

* test fix

* polishing

* polishing

* polishing

* fixed bug with new thread

* polishing

* a bit of refactoring and docs added

* notebook added to docs

* type checking added to CI

* CI fix

* CI fix

* CI fix

* polishing

* obsolete todo comment removed

* fixed precommit error

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* [CAP] [Feature] Get list of actors from directory service. (#2073)

* Search directory for list of actors using regex '.*' gets all actors

* docs changes

* pre-commit fixes

* Use ActorInfo from protobuf

* pre-commit

* Added zmq tests to work on removing sleeps

* minor refactor of zmq tests

* 1) Change DirSvr to user Broker.  2) Add req-router to broker 3) In ActorConnector use handshake and req/resp to remove sleep

* 1) Change DirSvr to user Broker.  2) Add req-router to broker 3) In ActorConnector use handshake and req/resp to remove sleep

* move socket creation to thread with recv

* move socket creation to thread with recv

* Better logging for DirectorySvc

* better logging for directory svc

* Use logging config

* Start removing sleeps

* pre-commit

* Cleanup monitor socket

* Mark cache as a protocol and update type hints to reflect (#2168)

* Mark cache as a protocl and update type hints to reflect

* int

* undo init change

	modified:   autogen/agentchat/chat.py

* fix(): fix word spelling errors (#2171)

* Implement User Defined Functions for Local CLI Executor (#2102)

* Implement user defined functions feature for local cli exec, add docs

* add tests, update docs

* fixes

* fix test

* add pandas test dep

* install test

* provide template as func

* formatting

* undo change

* address comments

* add test deps

* formatting

* test only in 1 env

* formatting

* remove test for local only

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* simplify getting-started; update news (#2175)

* simplify getting-started; update news

* bug fix

* update (#2178)

Co-authored-by: AnonymousRepoSub <“shaokunzhang529@outlook.com” >

* Fix formatting of admonitions in udf docs (#2188)

* Fix iostream on new thread (#2181)

* fixed get_stream in new thread by introducing a global default

* fixed get_stream in new thread by introducing a global default

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Add link for rendering notebooks docs on website (#2191)

* Transform Messages Capability (#1923)

* wip

* Adds docstrings

* fixed spellings

* wip

* fixed errors

* better class names

* adds tests

* added tests to workflow

* improved token counting

* improved notebook

* improved token counting in test

* improved docstrings

* fix inconsistencies

* changed by mistake

* fixed docstring

* fixed details

* improves tests + adds openai contrib test

* fix spelling oai contrib test

* clearer docstrings

* remove repeated docstr

* improved notebook

* adds metadata to notebook

* Improve outline and description (#2125)

* better dir structure

* clip max tokens to allowed tokens

* more accurate comments/docstrs

* add deperecation warning

* fix front matter desc

* add deperecation warning notebook

* undo local notebook settings changes

* format notebook

* format workflow

---------

Co-authored-by: gagb <gagb@users.noreply.github.com>

* Bump express from 4.18.2 to 4.19.2 in /website (#2157)

Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](expressjs/express@4.18.2...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add clarity analytics (#2201)

* Docstring formatting fix: Standardize docstrings to adhere to Google style guide, ensuring consistency and clarity. and also fixed the broken link for autogen/agentchat/chat.py

* Docstring fix: Reformattted docstrings to adhere to Google style guide, nsuring consistency and clarity. For agentchat/contrib/retrieve_user_proxy_agent.py file

* Fixed Pre-Commit Error, Trailing spaces on agentchat/chat.py

* Fixed Pre-Commit Error, Trailing spaces on agentchat/chat.py

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Li Jiang <bnujli@gmail.com>
Co-authored-by: Beibin Li <BeibinLi@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Co-authored-by: olgavrou <olgavrou@gmail.com>
Co-authored-by: gagb <gagb@users.noreply.github.com>
Co-authored-by: Qingyun Wu <qingyun0327@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wael Karkoub <wael.karkoub96@gmail.com>
Co-authored-by: Shaokun Zhang <shaokunzhang529@gmail.com>
Co-authored-by: “skzhang1” <“shaokunzhang529@gmail.com”>
Co-authored-by: Jieyu Zhang <jieyuz2@cs.washington.edu>
Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>
Co-authored-by: Davor Runje <davor@airt.ai>
Co-authored-by: Rajan <rajan.chari@yahoo.com>
Co-authored-by: calm <1191465097@qq.com>
Co-authored-by: AnonymousRepoSub <“shaokunzhang529@outlook.com” >
@harrywang
Copy link
Collaborator

any docs on how to use streaming? Thanks a lot for the help.

@sonichi
Copy link
Collaborator

sonichi commented Apr 17, 2024

any docs on how to use streaming? Thanks a lot for the help.

@ekzhu @jackgerrits could you check if this is in the doc roadmap?

@davorrunje
Copy link
Collaborator Author

any docs on how to use streaming? Thanks a lot for the help.

@ekzhu @jackgerrits could you check if this is in the doc roadmap?

@sonichi there is another PR coming that will make websockets much easier to use, the main idea is to use structured JSON-encoded messages for websockets and convert them to strings for console output. Right now there is an example in notebooks on how to use it, I could quickly make a documentation out of it.

@ekzhu
Copy link
Collaborator

ekzhu commented Apr 17, 2024

@davorrunje thanks, we can covert the notebook to a user guide page under /website/docs/topics/. I have added this to our documentation roadmap: #1597 feel free to convert that task into an issue.

whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
…osoft#1551)

* Introducing IOStream

* bug fixing

* polishing

* refactoring

* refactoring

* refactoring

* wip: async tests

* websockets added

* wip

* merge with main

* notebook added

* FastAPI example added

* wip

* merge

* getter/setter to iostream added

* website/blog/2024-03-03-AutoGen-Update/img/dalle_gpt4v.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/gaia.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/teach.png: convert to Git LFS

* add SSL support

* wip

* wip

* exception handling added to on_connect()

* refactoring: default iostream is being set in a context manager

* test fix

* polishing

* polishing

* polishing

* fixed bug with new thread

* polishing

* a bit of refactoring and docs added

* notebook added to docs

* type checking added to CI

* CI fix

* CI fix

* CI fix

* polishing

* obsolete todo comment removed

* fixed precommit error

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
* DOC FIX - Formatted Docstrings for the retrieve_user_proxy_agent.py and Added first single line for the class RetrieveUserProxyAgent.

* DOC FIX - Formatted Docstrings for  theinitiate_chats functiion of ChatResult class in  autogen/agentchat/chat.py

* Add vision capability (microsoft#2025)

* Add vision capability

* Configurate: description_prompt

* Print warning instead of raising issues for type

* Skip vision capability test if dependencies not installed

* Append "vision" to agent's system message when enabled VisionCapability

* GPT-4V notebook update with ConversableAgent

* Clean GPT-4V notebook

* Add vision capability test to workflow

* Lint import

* Update system message for vision capability

* Add a `custom_caption_func` to VisionCapability

* Add custom function example for vision capability

* Skip test Vision capability custom func

* GPT-4V notebook metadata to website

* Remove redundant files

* The custom caption function takes more inputs now

* Add a more complex example of custom caption func

* Remove trailing space

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Native tool call support for Mistral AI API and topic notebook. (microsoft#2135)

* Support for Mistral AI API and topic notebook.

* formatting

* formatting

* New conversational chess notebook using nested chats and tool use (microsoft#2137)

* add chess notebook

* update

* update

* Update notebook with figure

* Add example link

* redirect

* Clean up example format

* address gagan's comments

* update references

* fix links

* add webarena in samples (microsoft#2114)

* add webarena in samples/tools

* Update samples/tools/webarena/README.md

Co-authored-by: gagb <gagb@users.noreply.github.com>

* Update samples/tools/webarena/README.md

Co-authored-by: gagb <gagb@users.noreply.github.com>

* Update samples/tools/webarena/README.md

Co-authored-by: gagb <gagb@users.noreply.github.com>

* update installation instructions

* black formatting

* Update README.md

---------

Co-authored-by: gagb <gagb@users.noreply.github.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* context to kwargs (microsoft#2064)

* context to kwargs

* add tag

* add test

* text to kwargs

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /website (microsoft#2131)

Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4.
- [Release notes](https://github.com/webpack/webpack-dev-middleware/releases)
- [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md)
- [Commits](webpack/webpack-dev-middleware@v5.3.3...v5.3.4)

---
updated-dependencies:
- dependency-name: webpack-dev-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* Parse Any HTML-esh Style Tags (microsoft#2046)

* tried implementing my own regex

* improves tests

* finally works

* removes prints

* fixed test

* adds start and end

* delete unused imports

* refactored to use new tool

* significantly improved algo

* tag content -> tag attr

* fix tests + adds new field

* return full match

* return remove start and end

* update docstrings

* update docstrings

* update docstrings

---------

Co-authored-by: Beibin Li <BeibinLi@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Integrate AgentOptimizer (microsoft#1767)

* draft agent optimizer

* refactor

* remove

* change openai config interface

* notebook

* update blog

* add test

* clean up

* redir

* update

* update interface

* change model name

* move to contrib

* Update autogen/agentchat/contrib/agent_optimizer.py

Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>

---------

Co-authored-by: “skzhang1” <“shaokunzhang529@gmail.com”>
Co-authored-by: Beibin Li <BeibinLi@users.noreply.github.com>
Co-authored-by: Jieyu Zhang <jieyuz2@cs.washington.edu>
Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>

* Introducing IOStream protocol and adding support for websockets (microsoft#1551)

* Introducing IOStream

* bug fixing

* polishing

* refactoring

* refactoring

* refactoring

* wip: async tests

* websockets added

* wip

* merge with main

* notebook added

* FastAPI example added

* wip

* merge

* getter/setter to iostream added

* website/blog/2024-03-03-AutoGen-Update/img/dalle_gpt4v.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/gaia.png: convert to Git LFS

* website/blog/2024-03-03-AutoGen-Update/img/teach.png: convert to Git LFS

* add SSL support

* wip

* wip

* exception handling added to on_connect()

* refactoring: default iostream is being set in a context manager

* test fix

* polishing

* polishing

* polishing

* fixed bug with new thread

* polishing

* a bit of refactoring and docs added

* notebook added to docs

* type checking added to CI

* CI fix

* CI fix

* CI fix

* polishing

* obsolete todo comment removed

* fixed precommit error

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* [CAP] [Feature] Get list of actors from directory service. (microsoft#2073)

* Search directory for list of actors using regex '.*' gets all actors

* docs changes

* pre-commit fixes

* Use ActorInfo from protobuf

* pre-commit

* Added zmq tests to work on removing sleeps

* minor refactor of zmq tests

* 1) Change DirSvr to user Broker.  2) Add req-router to broker 3) In ActorConnector use handshake and req/resp to remove sleep

* 1) Change DirSvr to user Broker.  2) Add req-router to broker 3) In ActorConnector use handshake and req/resp to remove sleep

* move socket creation to thread with recv

* move socket creation to thread with recv

* Better logging for DirectorySvc

* better logging for directory svc

* Use logging config

* Start removing sleeps

* pre-commit

* Cleanup monitor socket

* Mark cache as a protocol and update type hints to reflect (microsoft#2168)

* Mark cache as a protocl and update type hints to reflect

* int

* undo init change

	modified:   autogen/agentchat/chat.py

* fix(): fix word spelling errors (microsoft#2171)

* Implement User Defined Functions for Local CLI Executor (microsoft#2102)

* Implement user defined functions feature for local cli exec, add docs

* add tests, update docs

* fixes

* fix test

* add pandas test dep

* install test

* provide template as func

* formatting

* undo change

* address comments

* add test deps

* formatting

* test only in 1 env

* formatting

* remove test for local only

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* simplify getting-started; update news (microsoft#2175)

* simplify getting-started; update news

* bug fix

* update (microsoft#2178)

Co-authored-by: AnonymousRepoSub <“shaokunzhang529@outlook.com” >

* Fix formatting of admonitions in udf docs (microsoft#2188)

* Fix iostream on new thread (microsoft#2181)

* fixed get_stream in new thread by introducing a global default

* fixed get_stream in new thread by introducing a global default

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>

* Add link for rendering notebooks docs on website (microsoft#2191)

* Transform Messages Capability (microsoft#1923)

* wip

* Adds docstrings

* fixed spellings

* wip

* fixed errors

* better class names

* adds tests

* added tests to workflow

* improved token counting

* improved notebook

* improved token counting in test

* improved docstrings

* fix inconsistencies

* changed by mistake

* fixed docstring

* fixed details

* improves tests + adds openai contrib test

* fix spelling oai contrib test

* clearer docstrings

* remove repeated docstr

* improved notebook

* adds metadata to notebook

* Improve outline and description (microsoft#2125)

* better dir structure

* clip max tokens to allowed tokens

* more accurate comments/docstrs

* add deperecation warning

* fix front matter desc

* add deperecation warning notebook

* undo local notebook settings changes

* format notebook

* format workflow

---------

Co-authored-by: gagb <gagb@users.noreply.github.com>

* Bump express from 4.18.2 to 4.19.2 in /website (microsoft#2157)

Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](expressjs/express@4.18.2...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add clarity analytics (microsoft#2201)

* Docstring formatting fix: Standardize docstrings to adhere to Google style guide, ensuring consistency and clarity. and also fixed the broken link for autogen/agentchat/chat.py

* Docstring fix: Reformattted docstrings to adhere to Google style guide, nsuring consistency and clarity. For agentchat/contrib/retrieve_user_proxy_agent.py file

* Fixed Pre-Commit Error, Trailing spaces on agentchat/chat.py

* Fixed Pre-Commit Error, Trailing spaces on agentchat/chat.py

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Li Jiang <bnujli@gmail.com>
Co-authored-by: Beibin Li <BeibinLi@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Co-authored-by: olgavrou <olgavrou@gmail.com>
Co-authored-by: gagb <gagb@users.noreply.github.com>
Co-authored-by: Qingyun Wu <qingyun0327@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wael Karkoub <wael.karkoub96@gmail.com>
Co-authored-by: Shaokun Zhang <shaokunzhang529@gmail.com>
Co-authored-by: “skzhang1” <“shaokunzhang529@gmail.com”>
Co-authored-by: Jieyu Zhang <jieyuz2@cs.washington.edu>
Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>
Co-authored-by: Davor Runje <davor@airt.ai>
Co-authored-by: Rajan <rajan.chari@yahoo.com>
Co-authored-by: calm <1191465097@qq.com>
Co-authored-by: AnonymousRepoSub <“shaokunzhang529@outlook.com” >
@harrywang
Copy link
Collaborator

@davorrunje thanks a lot for adding the streaming feature. We followed the notebook https://github.com/microsoft/autogen/blob/main/notebook/agentchat_websockets.ipynb to setup a fastapi server and deploy on aws using fargate.

we are able to use the endpoint such as ws://x.x.x.x:8000/autogen locally when testing.
once we push the code to vercel, and use HTTPS to access ws://x.x.x.x:8000/autogen, we get the following error:

Mixed Content: The page at 'https://app.domain.com/autogenchat' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://x.x.x.x:8000/autogen'. This request has been blocked; this endpoint must be available over WSS.

we don't know how to setup WSS - any pointers on this? Thanks a lot.

@tyler-suard-parker
Copy link
Contributor

I could be wrong here, but when you are calling a streaming websockets endpoint I think you should be calling it as wss:// rather than ws://

@ekzhu ekzhu added the streaming Streaming output to websocket label May 10, 2024
@RuthNjeri6
Copy link

@davorrunje Thanks a lot for the streaming feature. I have checked out the notebook that uses FastAPI. I was wondering how the same approach could be used on with a Django server. I have a chatbot that uses autogen with multiple agents including custom agent specific function. The issue is when it comes to setting up the Websocket server given that Django uses channels for this. Please point me to some resources that can get me started.

@davorrunje
Copy link
Collaborator Author

@RuthNjeri6 I am sorry for the late reply, I was travelling for the past four weeks. Do you still need helo with this?

@RuthNjeri6
Copy link

RuthNjeri6 commented Jun 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
streaming Streaming output to websocket
Projects
None yet