@@ -515,19 +515,63 @@ def get_app_info(self) -> Dict[str, Any]:
515515 """
516516 return self .get ("info" )
517517
518- def get_parameters (self ) -> Dict [str , Any ]:
518+ def get_parameters (self , ** kwargs ) -> Dict [str , Any ]:
519519 """
520- 获取应用参数,包括功能开关、输入参数名称、类型及默认值等。
521-
520+ 获取应用参数,包括功能开关、输入参数配置、文件上传限制等。
521+
522+ 此方法通常用于应用初始化阶段,获取应用的各种配置参数和功能开关状态。
523+
524+ Args:
525+ **kwargs: 额外的请求参数,如timeout、max_retries等
526+
522527 Returns:
523- Dict[str, Any]: 应用参数配置
524-
525-
526-
528+ Dict[str, Any]: 包含应用参数的字典,可能包含以下字段:
529+ - opening_statement (str): 应用开场白文本
530+ - suggested_questions (List[str]): 开场推荐问题列表
531+ - suggested_questions_after_answer (Dict): 回答后推荐问题配置
532+ - enabled (bool): 是否启用此功能
533+ - speech_to_text (Dict): 语音转文本功能配置
534+ - enabled (bool): 是否启用此功能
535+ - retriever_resource (Dict): 引用和归属功能配置
536+ - enabled (bool): 是否启用此功能
537+ - annotation_reply (Dict): 标记回复功能配置
538+ - enabled (bool): 是否启用此功能
539+ - user_input_form (List[Dict]): 用户输入表单配置列表,每项可能包含:
540+ - text-input: 文本输入控件配置
541+ - paragraph: 段落文本输入控件配置
542+ - select: 下拉选择控件配置
543+ - file_upload (Dict): 文件上传相关配置
544+ - image (Dict): 图片上传配置
545+ - enabled (bool): 是否启用图片上传
546+ - number_limits (int): 图片数量限制
547+ - transfer_methods (List[str]): 支持的传输方式
548+ - system_parameters (Dict): 系统级参数
549+ - file_size_limit (int): 文档上传大小限制(MB)
550+ - image_file_size_limit (int): 图片上传大小限制(MB)
551+ - audio_file_size_limit (int): 音频上传大小限制(MB)
552+ - video_file_size_limit (int): 视频上传大小限制(MB)
553+
527554 Raises:
528555 DifyAPIError: 当API请求失败时
529- """
530- return self .get ("parameters" )
556+
557+ Example:
558+ ```python
559+ # 获取应用参数
560+ params = client.get_parameters()
561+
562+ # 检查是否启用了图片上传
563+ if params.get('file_upload', {}).get('image', {}).get('enabled', False):
564+ print("此应用支持图片上传")
565+ print(f"图片数量限制: {params['file_upload']['image']['number_limits']}")
566+
567+ # 获取用户输入表单配置
568+ forms = params.get('user_input_form', [])
569+ for form in forms:
570+ for form_type, config in form.items():
571+ print(f"表单类型: {form_type}, 字段名: {config.get('label')}")
572+ ```
573+ """
574+ return self .get ("parameters" , ** kwargs )
531575
532576 def get_conversations (
533577 self ,
@@ -703,3 +747,68 @@ def __str__(self) -> str:
703747 if self .status_code :
704748 return f"[{ self .status_code } ] { self .message } "
705749 return self .message
750+
751+ def analyze_app_capabilities (client ):
752+ """分析应用的功能和配置"""
753+ # 获取应用参数
754+ params = client .get_parameters ()
755+
756+ # 基本信息
757+ print ("=== 应用功能配置分析 ===" )
758+
759+ # 检查基本功能
760+ features = []
761+ if "opening_statement" in params and params ["opening_statement" ]:
762+ features .append ("开场白" )
763+ if params .get ("suggested_questions" ):
764+ features .append ("推荐问题" )
765+ if params .get ("suggested_questions_after_answer" , {}).get ("enabled" ):
766+ features .append ("回答后推荐问题" )
767+ if params .get ("speech_to_text" , {}).get ("enabled" ):
768+ features .append ("语音转文本" )
769+ if params .get ("retriever_resource" , {}).get ("enabled" ):
770+ features .append ("引用和归属" )
771+ if params .get ("annotation_reply" , {}).get ("enabled" ):
772+ features .append ("标记回复" )
773+
774+ print (f"启用的功能: { ', ' .join (features ) if features else '无特殊功能' } " )
775+
776+ # 检查表单配置
777+ if "user_input_form" in params :
778+ form_types = []
779+ variables = []
780+ for item in params ["user_input_form" ]:
781+ for form_type in item :
782+ form_types .append (form_type )
783+ variables .append (item [form_type ].get ("variable" ))
784+
785+ print (f"\n 表单配置: 共{ len (params ['user_input_form' ])} 个控件" )
786+ print (f"控件类型: { ', ' .join (form_types )} " )
787+ print (f"变量名列表: { ', ' .join (variables )} " )
788+
789+ # 检查文件上传能力
790+ if "file_upload" in params :
791+ upload_types = []
792+ for upload_type , config in params ["file_upload" ].items ():
793+ if config .get ("enabled" ):
794+ upload_types .append (upload_type )
795+
796+ if upload_types :
797+ print (f"\n 支持上传文件类型: { ', ' .join (upload_types )} " )
798+
799+ # 详细的图片上传配置
800+ if "image" in params ["file_upload" ] and params ["file_upload" ]["image" ].get ("enabled" ):
801+ img_config = params ["file_upload" ]["image" ]
802+ print (f"图片上传限制: 最多{ img_config .get ('number_limits' , 0 )} 张" )
803+ print (f"支持的传输方式: { ', ' .join (img_config .get ('transfer_methods' , []))} " )
804+
805+ # 检查系统参数
806+ if "system_parameters" in params :
807+ print ("\n 系统参数限制:" )
808+ for param , value in params ["system_parameters" ].items ():
809+ print (f"- { param } : { value } MB" )
810+
811+ return params
812+
813+ # 使用示例
814+ app_params = analyze_app_capabilities (client )
0 commit comments