mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Graham Neubig <neubig@gmail.com> Co-authored-by: llamantino <213239228+llamantino@users.noreply.github.com> Co-authored-by: mamoodi <mamoodiha@gmail.com> Co-authored-by: Tim O'Farrell <tofarr@gmail.com> Co-authored-by: Hiep Le <69354317+hieptl@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ryan H. Tran <descience.thh10@gmail.com> Co-authored-by: Neeraj Panwar <49247372+npneeraj@users.noreply.github.com> Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com> Co-authored-by: Insop <1240382+insop@users.noreply.github.com> Co-authored-by: test <test@test.com> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> Co-authored-by: Zhonghao Jiang <zhonghao.J@outlook.com> Co-authored-by: Ray Myers <ray.myers@gmail.com>
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from litellm import ChatCompletionToolParam, ChatCompletionToolParamFunctionChunk
|
|
|
|
from openhands.agenthub.codeact_agent.tools.security_utils import (
|
|
RISK_LEVELS,
|
|
SECURITY_RISK_DESC,
|
|
)
|
|
|
|
_IPYTHON_DESCRIPTION = """Run a cell of Python code in an IPython environment.
|
|
* The assistant should define variables and import packages before using them.
|
|
* The variable defined in the IPython environment will not be available outside the IPython environment (e.g., in terminal).
|
|
"""
|
|
|
|
IPythonTool = ChatCompletionToolParam(
|
|
type='function',
|
|
function=ChatCompletionToolParamFunctionChunk(
|
|
name='execute_ipython_cell',
|
|
description=_IPYTHON_DESCRIPTION,
|
|
parameters={
|
|
'type': 'object',
|
|
'properties': {
|
|
'code': {
|
|
'type': 'string',
|
|
'description': 'The Python code to execute. Supports magic commands like %pip.',
|
|
},
|
|
'security_risk': {
|
|
'type': 'string',
|
|
'description': SECURITY_RISK_DESC,
|
|
'enum': RISK_LEVELS,
|
|
},
|
|
},
|
|
'required': ['code', 'security_risk'],
|
|
},
|
|
),
|
|
)
|