Nymbo commited on
Commit
9f1e882
·
verified ·
1 Parent(s): 36e1ba2

Update Modules/Code_Interpreter.py

Browse files
Files changed (1) hide show
  1. Modules/Code_Interpreter.py +10 -7
Modules/Code_Interpreter.py CHANGED
@@ -5,10 +5,19 @@ from io import StringIO
5
  from typing import Annotated
6
 
7
  import gradio as gr
 
8
 
9
  from app import _log_call_end, _log_call_start, _truncate_for_log
10
 
 
 
 
 
11
 
 
 
 
 
12
  def Code_Interpreter(code: Annotated[str, "Python source code to run; stdout is captured and returned."]) -> str:
13
  _log_call_start("Code_Interpreter", code=_truncate_for_log(code or "", 300))
14
  if code is None:
@@ -35,13 +44,7 @@ def build_interface() -> gr.Interface:
35
  outputs=gr.Textbox(label="Output", lines=5, max_lines=20),
36
  title="Code Interpreter",
37
  description="<div style=\"text-align:center\">Execute Python code and see the output.</div>",
38
- api_description=(
39
- "Execute arbitrary Python code and return captured stdout or an error message. "
40
- "Supports any valid Python code including imports, variables, functions, loops, and calculations. "
41
- "Examples: 'print(2+2)', 'import math; print(math.sqrt(16))', 'for i in range(3): print(i)'. "
42
- "Parameters: code (str - Python source code to execute). "
43
- "Returns: Combined stdout output or exception text if execution fails."
44
- ),
45
  flagging_mode="never",
46
  )
47
 
 
5
  from typing import Annotated
6
 
7
  import gradio as gr
8
+ from ._docstrings import autodoc
9
 
10
  from app import _log_call_end, _log_call_start, _truncate_for_log
11
 
12
+ # Single source of truth for the LLM-facing tool description
13
+ TOOL_SUMMARY = (
14
+ "Execute Python code; returns captured stdout or the exception text."
15
+ )
16
 
17
+
18
+ @autodoc(
19
+ summary=TOOL_SUMMARY,
20
+ )
21
  def Code_Interpreter(code: Annotated[str, "Python source code to run; stdout is captured and returned."]) -> str:
22
  _log_call_start("Code_Interpreter", code=_truncate_for_log(code or "", 300))
23
  if code is None:
 
44
  outputs=gr.Textbox(label="Output", lines=5, max_lines=20),
45
  title="Code Interpreter",
46
  description="<div style=\"text-align:center\">Execute Python code and see the output.</div>",
47
+ api_description=TOOL_SUMMARY,
 
 
 
 
 
 
48
  flagging_mode="never",
49
  )
50