Commit Graph

23 Commits

Author SHA1 Message Date
NanthagopalEswaran ded8e1b280
Fix #2845 - LocalCommandLineCodeExecutor is not working with virtual environments (#2926)
* Used absolute path of virtual environment bin path in local command executors

* Checked if the expected venv is used or not

* Added code comments for documentation

* fix: format issue - shutil lib

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: Li Jiang <bnujli@gmail.com>
2024-06-19 13:39:23 +00:00
R. Singh 60c665871a
Feature: Add ability to use a separate python environment in local executor (#2615)
* Add ability to use virtual environments in local executor

* Copy environment variables from parent environment

* Fix mypy errors and formatting

* Account for venv on Windows

* Use a virtual environment context object instead of path

* Add utility method to create a virtual environment

* Remove assertion using `_venv_path`

* Add tests for `create_virtual_env`

* Modify test code and add output assertion

* Modify test code and assertion

* Execute activation script before actual command on windows

* Add docs for using a virtual env
2024-05-11 06:25:20 +00:00
asandez1 5fdaf1a8c0
Docker multilanguage executor saver with policy (#2522)
* feat: update executor saver policy

* feat: languages

* feat: add test _cmd

* fix: try catch

* fix: log

* fix: test docker mock

* fix: invalid path test

* fix: invalid path message

* fix: invalid path message

* fix: is_docker test

* fix: delete old test

* fix: cmd lang
2024-05-01 21:14:09 +00:00
Wael Karkoub a9171211c7
Streamline Testing with `pytest-cov` and `pytest` Defaults (#2490)
* done

* update docs

* try fix

* update workflows

* undo minor fix

* resolve comments

* adds back pytest-asyncio

* minor fix

* add branch coverage

* restore pip install e.

* test with coverage

* fix mypy

* fix coverage + docker + windows combo

* fix bash command

* formatter

* formatter

* one last fix

* I lied, last fix

* fix

* fix retrieve chat test

* fix windows paths

* change cache seed

* down grade openai version

* fix openai mypy

* better error type

* fix image gen cache test

* fix

* experimenting

* fix lmm

* skip cosmos test

* remove cosmos db

* unused imports

* handle more cosmosdb skips

* fix flaky test
2024-04-29 00:27:34 +00:00
asandez1 31fe75ad0e
Add support for HTML, CSS and Javascript in LocalCommandLineCodeExecutor with Mapping executor/saver #2303 (#2464)
* Add support for HTML, CSS and Javascript in LocalCommandLineCodeExecutor

* init branch

* init branch

* feat: test code execution added

* fix: test update

* fix: test

* fix: policy test

* feat: default policy

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-04-24 01:21:24 +00:00
Josh Trim d473dee664
Add "py" as lang in conversable agent (#1062) (#2144)
* Add "py" as lang in conversable agent (#1062)

* Add conditions to allow for python executable variants (#1062)

* reverted import (#1062)

* Parameterized tests, moved Python variants to a constant (#1062)

* Moved Python variants to a constant (#1062)

* Update autogen/code_utils.py (#1062)

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

* Update autogen/coding/local_commandline_code_executor.py (#1062)

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

* Added PYTHON_VARIANTS as imported constant (#1062)

* ran pre-commit-check  (#1062)

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-04-12 15:14:51 +00:00
Li Jiang 42b27b9a9d
Add isort (#2265)
* Add isort

* Apply isort on py files

* Fix circular import

* Fix format for notebooks

* Fix format

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2024-04-05 02:26:06 +00:00
Jack Gerrits c3193f847b
Allow custom name for functions module (#2241)
* Allow custom name for functions module

* update tests

* reorder
2024-04-02 06:21:31 +00:00
Jack Gerrits 7b5fd51e2e
Support string based UDFs (#2195) 2024-03-30 15:15:39 +00:00
Chi Wang e6237d44a1
simplify getting-started; update news (#2175)
* simplify getting-started; update news

* bug fix
2024-03-28 03:43:01 +00:00
Jack Gerrits 5ef2dfc104
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>
2024-03-27 23:45:17 +00:00
Wael Karkoub 331818300d
Silences Pip Install Messages in Code Executors (#2105)
* fix

* adds tests

* check if windows

* adds windows shells

* modifies exit code

* fix powershell

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-03-21 20:08:50 +00:00
Jack Gerrits d583c8088e
Update local cli executor to use same filename strategy as docker (#1981)
* consistent file saving across cli executors

* test fixes

* feedback

* make path

* formatting

* run timeout test on windows

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2024-03-12 21:57:32 +00:00
Jack Gerrits b1c44deb0c
Remove system message from code executors (#1933)
* Remove system message functionality from code executors

* remove from protocol

* fix tests, pre-commit

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2024-03-12 19:04:43 +00:00
Jack Gerrits e9219fefc0
Implement docker based command line code executor (#1856)
* implement docker based command line code executor

* undo import

* test skips

* format

* fix type issue

* skip docker tests

* fix paths

* add docs

* Update __init__.py

* class name

* precommit

* undo twoagent change

* use relative to directly

* Update, fixes, etc.

* update doc

* Update docstring

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-03-07 18:11:52 +00:00
Jack Gerrits 685164f83a
Executor timeout should preserve kernel state (#1885) 2024-03-06 18:24:33 +00:00
Jack Gerrits d9078210e7
Change name from LocalCommandlineCodeExecutor to LocalCommandLineCodeExecutor (#1873)
* Change name from LocalCommandlineCodeExecutor to LocalCommandLineCodeExecutor

* formatting

* name

* name

* CommandLineCodeResult rename too

* formatting
2024-03-06 15:41:19 +00:00
Jack Gerrits 76ef0789c0
Implement docker based jupyter executor (#1794)
* Implement docker based jupyter client

* formatting

* skip docker tests when asked

* feedback

* add log

* update build

* formatting

* structural changes

* update setup.py

* update tests

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2024-02-29 14:54:11 +00:00
Jack Gerrits fbc2f6e911
Use jupyer-kernel-gateway for ipython executor (#1748)
* checkpoint async based

* Implement jupyter client and use jupyer gateway

* update deps

* address comments

* add missing parenthesis

* Update build.yml

* CI fixes

* change requirement name

* debug

* print stderr

* dont seek

* show token

* mitigaton for windows bug

* use hex token to avoid - in token

* formatting

* put back in place original while the windows bug exists

* lint

* Update autogen/coding/jupyter_code_executor.py

* Update jupyter_code_executor.py

* Update test_embedded_ipython_code_executor.py

* Update setup.py

* Update build.yml

* fix nameerror

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-02-23 19:09:59 +00:00
Aaron e50d5a1747
Command line code sanitation (#1627)
* UPDATE - add commandline sanitation class, update local_commandline_code_executor.py and renamed test for code_utils.py

* FIX - precommit run

* UPDATE - moved sanitation function to LocalCommandlineCodeExecutor, moved testo to test_commandline_code_executor.py

* UPDATE - added docstring notice to sanitize_code

* Update autogen/coding/local_commandline_code_executor.py

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

* FIX - regular expression

* FIX - function invocation in tests

* UPDATE - pre-commit run

* FIX - pre-commit run -_-

---------

Co-authored-by: Ward <award40@LAMU0CLP74YXVX6.uhc.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-02-18 16:41:36 +00:00
Gunnar Kudrjavets f68c09b035
Validate the OpenAI API key format (#1635)
* Validate the OpenAI API key format

Increase the amount of internal validation for OpenAI API keys. The intent is
to shorten the debugging loop in case of typos. The changes do *not* add
validation for Azure OpenAI API keys.

* Add the validation in `__init__` of `OpenAIClient`.

* Introduce the `MOCK_OPEN_AI_API_KEY` constant for testing.

*  Add unit test coverage for the `is_valid_api_key` function.

* Validate the OpenAI API key format

Increase the amount of internal validation for OpenAI API keys. The intent is
to shorten the debugging loop in case of typos. The changes do *not* add
validation for Azure OpenAI API keys.

* Add the validation in `__init__` of `OpenAIClient`.

* Introduce the `MOCK_OPEN_AI_API_KEY` constant for testing.

*Add unit test coverage for the `is_valid_api_key` function.

* Log a warning when register a default client fails.

* Validate the OpenAI API key format

Increase the amount of internal validation for OpenAI API keys. The intent is
to shorten the debugging loop in case of typos. The changes do *not* add
validation for Azure OpenAI API keys.

* Add the validation in `__init__` of `OpenAIClient`. We'll log a
  warning when the OpenAI API key isn't valid.

* Introduce the `MOCK_OPEN_AI_API_KEY` constant for testing.

* Add unit test coverage for the `is_valid_api_key` function.

* Check for OpenAI base_url before API key validation

---------

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2024-02-14 18:51:38 +00:00
Qingyun Wu 899b250c08
Adding callable summary_method support and enhancements to initiate_chats (#1628)
* initiate_chats enhancements

* callable summary_method

* summary method

* summary method default

* docstr

* add timeout to slient pip install test

* consolidate_chat_info

* a_initiate_chat

* AssertionError test

* update tests

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-02-12 02:25:09 +00:00
Eric Zhu 609ba7c649
Code executors (#1405)
* code executor

* test

* revert to main conversable agent

* prepare for pr

* kernel

* run open ai tests only when it's out of draft status

* update workflow file

* revert workflow changes

* ipython executor

* check kernel installed; fix tests

* fix tests

* fix tests

* update system prompt

* Update notebook, more tests

* notebook

* raise instead of return None

* allow user provided code executor.

* fixing types

* wip

* refactoring

* polishing

* fixed failing tests

* resolved merge conflict

* fixing failing test

* wip

* local command line executor and embedded ipython executor

* revert notebook

* fix format

* fix merged error

* fix lmm test

* fix lmm test

* move warning

* name and description should be part of the agent protocol, reset is not as it is only used for ConversableAgent; removing accidentally commited file

* version for dependency

* Update autogen/agentchat/conversable_agent.py

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

* ordering of protocol

* description

* fix tests

* make ipython executor dependency optional

* update document optional dependencies

* Remove exclude from Agent protocol

* Make ConversableAgent consistent with Agent

* fix tests

* add doc string

* add doc string

* fix notebook

* fix interface

* merge and update agents

* disable config usage in reply function

* description field setter

* customize system message update

* update doc

---------

Co-authored-by: Davor Runje <davor@airt.ai>
Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com>
Co-authored-by: Aaron <aaronlaptop12@hotmail.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
2024-02-10 04:52:16 +00:00