File tree Expand file tree Collapse file tree 3 files changed +44
-9
lines changed Expand file tree Collapse file tree 3 files changed +44
-9
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,23 @@ export class OpenResourcesController {
5959 resourceData ,
6060 ) ;
6161
62- if ( ! newResource . name || newResource . name . trim ( ) === '' ) {
63- await this . wizardTaskService . createGenerateTitleTask (
64- userId ,
65- apiKey . namespaceId ,
66- { resource_id : newResource . id } ,
67- { text : data . content } ,
68- ) ;
62+ if ( newResource . content && newResource . content . trim ( ) !== '' ) {
63+ if ( ! newResource . name || newResource . name . trim ( ) === '' ) {
64+ await this . wizardTaskService . createGenerateTitleTask (
65+ userId ,
66+ apiKey . namespaceId ,
67+ { resource_id : newResource . id } ,
68+ { text : data . content } ,
69+ ) ;
70+ }
71+ if ( ! newResource . tagIds ) {
72+ await this . wizardTaskService . createExtractTagsTask (
73+ userId ,
74+ newResource . id ,
75+ apiKey . namespaceId ,
76+ newResource . content ,
77+ ) ;
78+ }
6979 }
7080
7181 return { id : newResource . id , name : newResource . name } ;
Original file line number Diff line number Diff line change @@ -66,7 +66,32 @@ export class WizardTaskService {
6666 ) ;
6767 }
6868
69- async createExtractTagsTask ( parentTask : Task , repo ?: Repository < Task > ) {
69+ async createExtractTagsTask (
70+ userId : string ,
71+ resourceId : string ,
72+ namespaceId : string ,
73+ text : string ,
74+ repo ?: Repository < Task > ,
75+ ) {
76+ const lang = await this . getUserLanguage ( userId ) ;
77+ return this . create (
78+ {
79+ function : 'extract_tags' ,
80+ input : { text, lang } ,
81+ namespaceId,
82+ payload : {
83+ resource_id : resourceId ,
84+ } ,
85+ userId,
86+ } ,
87+ repo ,
88+ ) ;
89+ }
90+
91+ async createExtractTagsTaskFromTask (
92+ parentTask : Task ,
93+ repo ?: Repository < Task > ,
94+ ) {
7095 const lang = await this . getUserLanguage ( parentTask . userId ) ;
7196 return this . create (
7297 {
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ export class WizardService {
216216 private async triggerExtractTags ( parentTask : Task ) : Promise < void > {
217217 try {
218218 const extractTagsTask =
219- await this . wizardTaskService . createExtractTagsTask ( parentTask ) ;
219+ await this . wizardTaskService . createExtractTagsTaskFromTask ( parentTask ) ;
220220
221221 this . logger . debug (
222222 `Triggered extract_tags task ${ extractTagsTask . id } for parent task ${ parentTask . id } ` ,
You can’t perform that action at this time.
0 commit comments