refac
This commit is contained in:
@@ -952,6 +952,26 @@ def clean_openai_tool_schema(spec: dict) -> dict:
|
||||
return cleaned_spec
|
||||
|
||||
|
||||
def add_terminal_display_file_inline_param(spec: dict) -> dict:
|
||||
spec = copy.deepcopy(spec)
|
||||
if spec.get('name') != 'display_file':
|
||||
return spec
|
||||
|
||||
spec['description'] = (
|
||||
f"{spec.get('description', '')} "
|
||||
"Set inline=true when the file should be shown inline in the chat message instead of opening the file viewer. "
|
||||
"After calling display_file with inline=true, do not emit Markdown image or link syntax for that file."
|
||||
).strip()
|
||||
parameters = spec.setdefault('parameters', {'type': 'object', 'properties': {}, 'required': []})
|
||||
parameters.setdefault('type', 'object')
|
||||
properties = parameters.setdefault('properties', {})
|
||||
properties['inline'] = {
|
||||
'type': 'boolean',
|
||||
'description': 'Show the file inline in the chat message instead of opening the file viewer.',
|
||||
}
|
||||
return spec
|
||||
|
||||
|
||||
@cache
|
||||
def get_builtin_function_introspection(func: Callable):
|
||||
try:
|
||||
@@ -1408,7 +1428,7 @@ async def get_terminal_tools(
|
||||
tools_dict = {}
|
||||
for spec in specs:
|
||||
function_name = spec['name']
|
||||
tool_spec = clean_openai_tool_schema(spec)
|
||||
tool_spec = clean_openai_tool_schema(add_terminal_display_file_inline_param(spec))
|
||||
|
||||
if function_name == 'run_command' and terminal_cwd:
|
||||
tool_spec['description'] = (
|
||||
@@ -1555,7 +1575,10 @@ async def get_tool_servers_data(servers: list[dict[str, Any]]) -> list[dict[str,
|
||||
response = {
|
||||
'openapi': response,
|
||||
'info': response.get('info', {}),
|
||||
'specs': convert_openapi_to_tool_payload(response),
|
||||
'specs': [
|
||||
add_terminal_display_file_inline_param(spec)
|
||||
for spec in convert_openapi_to_tool_payload(response)
|
||||
],
|
||||
}
|
||||
|
||||
openapi_data = response.get('openapi', {})
|
||||
|
||||
Reference in New Issue
Block a user