@ -21,10 +21,7 @@ class ApiBasedToolSchemaParser:
extra_info = extra_info if extra_info is not None else { }
extra_info = extra_info if extra_info is not None else { }
# set description to extra_info
# set description to extra_info
if ' description ' in openapi [ ' info ' ] :
extra_info [ ' description ' ] = openapi [ ' info ' ] . get ( ' description ' , ' ' )
extra_info [ ' description ' ] = openapi [ ' info ' ] [ ' description ' ]
else :
extra_info [ ' description ' ] = ' '
if len ( openapi [ ' servers ' ] ) == 0 :
if len ( openapi [ ' servers ' ] ) == 0 :
raise ToolProviderNotFoundError ( ' No server found in the openapi yaml. ' )
raise ToolProviderNotFoundError ( ' No server found in the openapi yaml. ' )
@ -95,8 +92,8 @@ class ApiBasedToolSchemaParser:
# parse body parameters
# parse body parameters
if ' schema ' in interface [ ' operation ' ] [ ' requestBody ' ] [ ' content ' ] [ content_type ] :
if ' schema ' in interface [ ' operation ' ] [ ' requestBody ' ] [ ' content ' ] [ content_type ] :
body_schema = interface [ ' operation ' ] [ ' requestBody ' ] [ ' content ' ] [ content_type ] [ ' schema ' ]
body_schema = interface [ ' operation ' ] [ ' requestBody ' ] [ ' content ' ] [ content_type ] [ ' schema ' ]
required = body_schema [ ' required ' ] if ' required ' in body_schema else [ ]
required = body_schema . get ( ' required ' , [ ] )
properties = body_schema [ ' properties ' ] if ' properties ' in body_schema else { }
properties = body_schema . get ( ' properties ' , { } )
for name , property in properties . items ( ) :
for name , property in properties . items ( ) :
tool = ToolParameter (
tool = ToolParameter (
name = name ,
name = name ,
@ -105,14 +102,14 @@ class ApiBasedToolSchemaParser:
zh_Hans = name
zh_Hans = name
) ,
) ,
human_description = I18nObject (
human_description = I18nObject (
en_US = property [ ' description ' ] if ' description ' in property else ' ' ,
en_US = property . get ( ' description ' , ' ' ) ,
zh_Hans = property [ ' description ' ] if ' description ' in property else ' '
zh_Hans = property . get ( ' description ' , ' ' )
) ,
) ,
type = ToolParameter . ToolParameterType . STRING ,
type = ToolParameter . ToolParameterType . STRING ,
required = name in required ,
required = name in required ,
form = ToolParameter . ToolParameterForm . LLM ,
form = ToolParameter . ToolParameterForm . LLM ,
llm_description = property [ ' description ' ] if ' description ' in property else ' ' ,
llm_description = property . get ( ' description ' , ' ' ) ,
default = property [ ' default ' ] if ' default ' in property else None ,
default = property . get ( ' default ' , None ) ,
)
)
# check if there is a type
# check if there is a type
@ -149,7 +146,7 @@ class ApiBasedToolSchemaParser:
server_url = server_url + interface [ ' path ' ] ,
server_url = server_url + interface [ ' path ' ] ,
method = interface [ ' method ' ] ,
method = interface [ ' method ' ] ,
summary = interface [ ' operation ' ] [ ' description ' ] if ' description ' in interface [ ' operation ' ] else
summary = interface [ ' operation ' ] [ ' description ' ] if ' description ' in interface [ ' operation ' ] else
interface [ ' operation ' ] [ ' summary ' ] if ' summary ' in interface [ ' operation ' ] else None ,
interface [ ' operation ' ] . get ( ' summary ' , None ) ,
operation_id = interface [ ' operation ' ] [ ' operationId ' ] ,
operation_id = interface [ ' operation ' ] [ ' operationId ' ] ,
parameters = parameters ,
parameters = parameters ,
author = ' ' ,
author = ' ' ,