Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
"\n",
"The following Python methods are available:\n",
"\n",
"~~~python\n",
"```python\n",
"def convert(amount, currency, new_currency):\n",
" \"\"\"Convert the currency with the latest exchange rate\n",
Expand All @@ -205,6 +206,7 @@
" new_currency: The currency to convert to\n",
" \"\"\"\n",
"```\n",
"~~~\n",
"\n",
"User: What is $200,000 in EUR?<end_of_turn>\n",
"<start_of_turn>model\n",
Expand Down Expand Up @@ -281,11 +283,10 @@
" \"\"\"\n",
" Executes Python code and captures any stdout output.\n",
"\n",
" \u26a0\ufe0f SECURITY WARNING \u26a0\ufe0f\n",
"\n",
" This function uses eval() and exec() which can execute arbitrary code.\n",
" NEVER use this function with untrusted code in production environments.\n",
" Always validate and sanitize code from LLMs before execution.\n",
" Consider using a sandboxed environment or code analysis tools.\n",
"\n",
" Args:\n",
" code_string (str): The code to execute (expression or statements).\n",
Expand Down Expand Up @@ -336,6 +337,7 @@
"\n",
"The following Python methods are available:\n",
"\n",
"~~~python\n",
"```python\n",
"def convert(amount, currency, new_currency):\n",
" \"\"\"Convert the currency with the latest exchange rate\n",
Expand All @@ -346,6 +348,7 @@
" new_currency: The currency to convert to\n",
" \"\"\"\n",
"```\n",
"~~~\n",
"\n",
"User: What is $200,000 in EUR?<end_of_turn>\n",
"<start_of_turn>model\n",
Expand Down Expand Up @@ -407,6 +410,7 @@
"\n",
"The following Python methods are available:\n",
"\n",
"~~~python\n",
"```python\n",
"def convert(amount, currency, new_currency):\n",
" \"\"\"Convert the currency with the latest exchange rate\n",
Expand All @@ -417,6 +421,7 @@
" new_currency: The currency to convert to\n",
" \"\"\"\n",
"```\n",
"~~~\n",
"\n",
"User: {user_message}<end_of_turn>\n",
"<start_of_turn>model\n",
Expand Down
8 changes: 7 additions & 1 deletion guides/keras_hub/function_calling_with_keras_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def convert(amount, currency, new_currency):

The following Python methods are available:

~~~python
```python
def convert(amount, currency, new_currency):
"""Convert the currency with the latest exchange rate
Expand All @@ -138,6 +139,7 @@ def convert(amount, currency, new_currency):
new_currency: The currency to convert to
"""
```
~~~

User: What is $200,000 in EUR?<end_of_turn>
<start_of_turn>model
Expand Down Expand Up @@ -181,7 +183,7 @@ def capture_code_output(code_string, globals_dict=None, locals_dict=None):
"""
Executes Python code and captures any stdout output.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The security warning for capture_code_output appears to have been weakened. This line likely contained a ⚠️ SECURITY WARNING ⚠️ header, which is critical for a function that uses eval() and exec(). Please restore the prominent warning to ensure users are fully aware of the security risks. The full warning should also recommend using a sandboxed environment.

Suggested change
⚠️ SECURITY WARNING ⚠️

This function uses eval() and exec() which can execute arbitrary code.
NEVER use this function with untrusted code in production environments.
Always validate and sanitize code from LLMs before execution.
Expand Down Expand Up @@ -235,6 +237,7 @@ def capture_code_output(code_string, globals_dict=None, locals_dict=None):

The following Python methods are available:

~~~python
```python
def convert(amount, currency, new_currency):
"""Convert the currency with the latest exchange rate
Expand All @@ -245,6 +248,7 @@ def convert(amount, currency, new_currency):
new_currency: The currency to convert to
"""
```
~~~

User: What is $200,000 in EUR?<end_of_turn>
<start_of_turn>model
Expand Down Expand Up @@ -292,6 +296,7 @@ def automated_tool_calling_example():

The following Python methods are available:

~~~python
```python
def convert(amount, currency, new_currency):
"""Convert the currency with the latest exchange rate
Expand All @@ -302,6 +307,7 @@ def convert(amount, currency, new_currency):
new_currency: The currency to convert to
"""
```
~~~

User: {user_message}<end_of_turn>
<start_of_turn>model
Expand Down
Loading