Coverage for aipyapp/display/base.py: 0%

1#!/usr/bin/env python

2# -*- coding: utf-8 -*-

3

4 from typing import Any, Protocol

5

6 from .. import Event, Plugin, PluginType

7

8 class DisplayProtocol(Protocol):

9 """显示效果插件协议"""

10 def save(self, path: str, clear: bool = False, code_format: str = None):

11 """保存输出"""

12 pass

13

14 def print(self, message: str, style: str = None):

15 """显示消息"""

16 pass

17

18 def input(self, prompt: str) -> str:

19 """获取用户输入"""

20 pass

21

22 def confirm(self, prompt, default="n", auto=None):

23 """确认操作"""

24 pass

25

26 def on_exception(self, event: Event):

27 """异常事件处理"""

28 pass

29

30 def on_task_start(self, event: Event):

31 """任务开始事件处理"""

32 pass

33

34 def on_response_complete(self, event: Event):

35 """LLM 响应完成事件处理"""

36 pass

37

38 def on_call_function(self, event: Event):

39 """函数调用事件处理"""

40 pass

41

42 def on_exec_result(self, event: Event):

43 """代码执行结果事件处理"""

44 pass

45

46 def on_task_end(self, event: Event):

47 """任务结束事件处理"""

48 pass

49

50 def on_query_start(self, event: Event):

51 """查询开始事件处理"""

52 pass

53

54 def on_round_start(self, event: Event):

55 """回合开始事件处理"""

56 pass

57

58 def on_round_end(self, event: Event):

59 """回合结束事件处理"""

60 pass

61

62 def on_stream_start(self, event: Event):

63 """流式开始事件处理"""

64 pass

65

66 def on_stream_end(self, event: Event):

67 """流式结束事件处理"""

68 pass

69

70 def on_stream(self, event: Event):

71 """LLM 流式响应事件处理"""

72 pass

73

74 def on_parse_reply(self, event: Event):

75 """消息解析结果事件处理"""

76 pass

77

78 def on_exec(self, event: Event):

79 """代码执行开始事件处理"""

80 pass

81

82 def on_mcp_result(self, event: Event):

83 """MCP 工具调用结果事件处理"""

84 pass

85

86 def on_mcp_call(self, event: Event):

87 """工具调用事件处理"""

88 pass

89

90 def on_upload_result(self, event: Event):

91 """云端上传结果事件处理"""

92 pass

93

94 def on_runtime_message(self, event: Event):

95 """Runtime消息事件处理"""

96 pass

97

98 def on_runtime_input(self, event: Event):

99 """Runtime输入事件处理"""

100 pass

101

102 def on_show_image(self, event: Event):

103 """显示图片事件处理"""

104 pass

105

106 class DisplayPlugin(DisplayProtocol, Plugin):

107 """显示效果插件基类"""

108 def __init__(self, console: Any, quiet: bool = False):

109 super().__init__()

110 self.console = console

111 self.quiet = quiet

112

113 def init(self):

114 """初始化显示效果插件"""

115 pass

116

117 @classmethod

118 def get_type(cls) -> PluginType:

119 """Get plugin type

120

121 Returns:

122 Plugin type

123 """

124 return PluginType.DISPLAY

125

126 def save(self, path: str, clear: bool = False, code_format: str = None):

127 """保存输出"""

128 pass

129

130 def print(self, message: str, style: str = None):

131 """显示消息"""

132 pass

133

134 def input(self, prompt: str) -> str:

135 """获取用户输入"""

136 pass

137

138 def confirm(self, prompt, default="n", auto=None):

139 """确认操作"""

140 pass