@@ -168,10 +168,54 @@ def execute(self) -> Literal["fail", "success"]:
168
168
169
169
170
170
class SummarizeTask (Task ):
171
+ __DEFAULT_OUTPUT_PATH = "./"
172
+
173
+ __DEFAULT_WORKFLOW_SYSTEM_PROMPT = """
174
+ Your task is to help user to analysis the output of qlib, your information including the strategy's backtest index
175
+ and runtime log. You may receive some scripts of the code as well, you can use them to analysis the output.
176
+ If there are any abnormal areas in the log or scripts, please also point them out.
177
+
178
+ Example output 1:
179
+ The backtest indexes show that your strategy's max draw down is a bit large,
180
+ You can try diversifying your positions across different assets.
181
+ """
182
+ __DEFAULT_WORKFLOW_USER_PROMPT = "Here is my information: '{{information}}'\n {{user_prompt}}"
183
+ __DEFAULT_USER_PROMPT = "Please summarize them and give me some advice."
184
+
185
+ def __init__ (self ):
186
+ super ().__init__ ()
187
+
171
188
def execution (self ) -> Any :
172
- output_path = ''
189
+ user_prompt = self ._context_manager .get_context ("user_prompt" )
190
+ user_prompt = user_prompt if user_prompt is not None else self .__DEFAULT_USER_PROMPT
191
+ system_prompt = self .__DEFAULT_WORKFLOW_SYSTEM_PROMPT
192
+ output_path = self ._context_manager .get_context ("output_path" )
193
+ output_path = output_path if output_path is not None else self .__DEFAULT_OUTPUT_PATH
194
+ information = self .parse2txt (output_path )
173
195
174
- def parse2txt (self , path ) -> List :
196
+ prompt_workflow_selection = Template (self .__DEFAULT_WORKFLOW_USER_PROMPT ).render (information = information ,
197
+ user_prompt = user_prompt )
198
+ messages = [
199
+ {
200
+ "role" : "system" ,
201
+ "content" : system_prompt ,
202
+ },
203
+ {
204
+ "role" : "user" ,
205
+ "content" : prompt_workflow_selection ,
206
+ },
207
+ ]
208
+ response = try_create_chat_completion (messages = messages )
209
+ return response
210
+
211
+ def summarize (self ) -> str :
212
+ return ''
213
+
214
+ def interact (self ) -> Any :
215
+ return
216
+
217
+ @staticmethod
218
+ def parse2txt (path ) -> List :
175
219
file_list = []
176
220
path = Path .cwd ().joinpath (path )
177
221
for root , dirs , files in os .walk (path ):
@@ -189,4 +233,3 @@ def parse2txt(self, path) -> List:
189
233
print (content )
190
234
result .append ({'postfix' : postfix , 'content' : content })
191
235
return result
192
-
0 commit comments