2
2
3
3
namespace LlmLaraHub \LlmDriver \Functions ;
4
4
5
- use App \Domains \Messages \RoleEnum ;
6
5
use App \Domains \Prompts \ReportBuildingFindRequirementsPrompt ;
7
- use App \Domains \Prompts \ReportingSummaryPrompt ;
8
6
use App \Domains \Reporting \ReportTypeEnum ;
9
7
use App \Domains \Reporting \StatusEnum ;
10
8
use App \Jobs \MakeReportSectionsJob ;
9
+ use App \Jobs \ReportingToolSummarizeReportJob ;
11
10
use App \Jobs \ReportMakeEntriesJob ;
12
11
use App \Models \Message ;
13
12
use App \Models \Report ;
14
13
use Illuminate \Bus \Batch ;
15
14
use Illuminate \Support \Collection ;
16
15
use Illuminate \Support \Facades \Bus ;
17
16
use Illuminate \Support \Facades \Log ;
18
- use LlmLaraHub \LlmDriver \LlmDriverFacade ;
19
- use LlmLaraHub \LlmDriver \Responses \CompletionResponse ;
20
17
use LlmLaraHub \LlmDriver \Responses \FunctionResponse ;
21
18
use LlmLaraHub \LlmDriver \ToolsHelper ;
22
19
@@ -32,8 +29,6 @@ class ReportingTool extends FunctionContract
32
29
33
30
protected array $ results = [];
34
31
35
- protected array $ promptHistory = [];
36
-
37
32
protected array $ sectionJobs = [];
38
33
39
34
public function handle (
@@ -74,45 +69,26 @@ public function handle(
74
69
])->name (sprintf ('Reporting Entities Report Id %s ' , $ report ->id ))
75
70
->allowFailures ()
76
71
->finally (function (Batch $ batch ) use ($ report ) {
77
- $ report ->update ([
78
- 'status_entries_generation ' => StatusEnum::Complete,
79
- ]);
72
+ Bus::batch ([
73
+ new ReportingToolSummarizeReportJob ($ report ),
74
+ ])->name (sprintf ('Reporting Tool Summarize Report Id %s ' , $ report ->id ))
75
+ ->allowFailures ()
76
+ ->dispatch ();
80
77
})
81
78
->dispatch ();
82
79
83
80
})
84
81
->dispatch ();
85
82
86
- notify_ui ($ message ->getChat (), 'Building Summary ' );
87
-
88
- $ response = $ this ->summarizeReport ($ report );
89
-
90
83
$ report ->update ([
91
84
'status_sections_generation ' => StatusEnum::Running,
92
85
]);
93
86
94
- $ assistantMessage = $ message ->getChat ()->addInput (
95
- message: $ response ->content ,
96
- role: RoleEnum::Assistant,
97
- systemPrompt: $ message ->getChat ()->getChatable ()->systemPrompt (),
98
- show_in_thread: true ,
99
- meta_data: $ message ->meta_data ,
100
- tools: $ message ->tools
101
- );
102
-
103
- $ this ->savePromptHistory ($ assistantMessage ,
104
- implode ("\n" , $ this ->promptHistory ));
105
-
106
- $ report ->message_id = $ assistantMessage ->id ;
107
- $ report ->save ();
108
-
109
- notify_ui ($ message ->getChat (), 'Building Solutions list ' );
110
- notify_ui_report ($ report , 'Building Solutions list ' );
111
- notify_ui_complete ($ report ->getChat ());
87
+ notify_ui ($ report ->getChat (), 'Running ' );
112
88
113
89
return FunctionResponse::from ([
114
- 'content ' => $ response -> content ,
115
- 'prompt ' => implode ( ' \n ' , $ this -> promptHistory ) ,
90
+ 'content ' => ' Building report and Sections and then summarizing ' ,
91
+ 'prompt ' => '' ,
116
92
'requires_followup ' => false ,
117
93
'documentChunks ' => collect ([]),
118
94
'save_to_message ' => false ,
@@ -159,23 +135,6 @@ protected function buildUpSections(Collection $documents, Report $report, Messag
159
135
}
160
136
}
161
137
162
- protected function summarizeReport (Report $ report ): CompletionResponse
163
- {
164
- $ sectionContent = $ report ->refresh ()->sections ->pluck ('content ' )->toArray ();
165
- $ sectionContent = implode ("\n" , $ sectionContent );
166
-
167
- $ prompt = ReportingSummaryPrompt::prompt ($ sectionContent );
168
-
169
- $ this ->promptHistory = [$ prompt ];
170
-
171
- /** @var CompletionResponse $response */
172
- $ response = LlmDriverFacade::driver (
173
- $ report ->getChatable ()->getDriver ()
174
- )->completion ($ prompt );
175
-
176
- return $ response ;
177
- }
178
-
179
138
/**
180
139
* @return PropertyDto[]
181
140
*/
0 commit comments