@@ -109,6 +109,9 @@ def main(verbose: int, quiet: bool):
109109 type = click .Path (exists = True ),
110110 help = "Path to jar file." ,
111111)
112+ use_llm_option = click .option (
113+ "--use-llm" , is_flag = True , default = False , help = "Use llm-change-agent for processing."
114+ )
112115
113116
114117@main .command ()
@@ -173,6 +176,7 @@ def get_labels(repo: str, token: str):
173176@state_option
174177@jar_path_option
175178@output_option
179+ @use_llm_option
176180def process_issue (
177181 input : str ,
178182 repo : str ,
@@ -184,6 +188,7 @@ def process_issue(
184188 state : str ,
185189 jar_path : str ,
186190 output : str ,
191+ use_llm : bool = False ,
187192):
188193 """Run processes based on issue label.
189194
@@ -205,52 +210,64 @@ def process_issue(
205210 )
206211
207212 else :
208- for issue in get_issues (
213+ issues = get_issues (
209214 repository_name = repo , token = token , label = label , number = number , state = state
210- ):
211- # Make sure ontobot_change_agent needs to be triggered or no.
212- if issue and issue [BODY ]:
213-
214- KGCL_COMMANDS = []
215- if NEW_TERM_LABEL in issue ["labels" ]:
216- formatted_body = "The following input was provided: </br> "
217- KGCL_COMMANDS , body_as_dict , reason = process_new_term_template (
218- issue ["body" ], prefix
219- )
220- if reason is None :
221- formatted_body += _convert_to_markdown (body_as_dict )
222- formatted_body += "</br> The following commands were executed: </br> "
223- else :
224- click .echo (
225- f"""{ issue [TITLE ]} does not need ontobot's attention since { reason } """ , # noqa
226- )
227- break
228-
229- elif re .match (r"(.*)ontobot(.*)apply(.*):(.*)" , issue [BODY ].lower (), re .DOTALL ):
215+ )
216+ ontobot_pattern = re .compile (r"(.*)ontobot(.*)apply(.*):(.*)" , re .DOTALL )
217+
218+ click .echo ("Starting to process issues..." )
219+
220+ for issue in issues :
221+ if not issue or not issue [BODY ]:
222+ click .echo (
223+ f"Issue number:{ number } is either closed, does not exist or has no body."
224+ )
225+ break
226+
227+ click .echo (f"Processing issue: { issue [TITLE ]} " )
228+
229+ KGCL_COMMANDS = []
230+ formatted_body = ""
231+
232+ if NEW_TERM_LABEL in issue ["labels" ]:
233+ click .echo ("New term label found. Processing new term template..." )
234+ formatted_body = "The following input was provided: </br> "
235+ KGCL_COMMANDS , body_as_dict , reason = process_new_term_template (
236+ issue ["body" ], prefix
237+ )
238+ if reason is None :
239+ click .echo ("No reason found to skip. Converting body to markdown..." )
240+ formatted_body += _convert_to_markdown (body_as_dict )
241+ formatted_body += "</br> The following commands were executed: </br> "
242+ else :
243+ click .echo (f"{ issue [TITLE ]} does not need ontobot's attention since { reason } " )
244+ break
245+ elif ontobot_pattern .match (issue [BODY ].lower ()):
246+ click .echo ("Ontobot apply command found. Extracting KGCL commands..." )
247+ formatted_body = "The following commands were executed: </br> "
248+ KGCL_COMMANDS = _get_kgcl_commands (issue [BODY ])
249+
250+ elif use_llm :
251+ click .echo (f"Summoning llm-change-agent for { issue [TITLE ]} " )
252+ with click .Context (execute ) as ctx :
253+ ctx .params ["prompt" ] = issue [BODY ]
254+ ctx .params ["provider" ] = "cborg"
255+ ctx .params ["model" ] = "google/gemini:latest"
256+ response = execute .invoke (ctx )
257+ KGCL_COMMANDS = [
258+ command .replace ('"' , "'" ) for command in ast .literal_eval (response )
259+ ]
260+ if KGCL_COMMANDS :
261+ click .echo (f"llm-change-agent result: { response } " )
230262 formatted_body = "The following commands were executed: </br> "
231- KGCL_COMMANDS = _get_kgcl_commands ( issue [ BODY ] )
263+ click . echo ( formatted_body + " \n " . join ( KGCL_COMMANDS ) )
232264 else :
233- # ! llm-change-agent activate!
234- click .echo (f"Summoning llm-change-agent for { issue [TITLE ]} " )
235- with click .Context (execute ) as ctx :
236- ctx .params ["prompt" ] = issue [BODY ]
237- ctx .params ["provider" ] = "cborg"
238- ctx .params ["model" ] = "google/gemini:latest"
239- response = execute .invoke (ctx )
240- KGCL_COMMANDS = [
241- command .replace ('"' , "'" ) for command in ast .literal_eval (response )
242- ]
243-
244- if len (KGCL_COMMANDS ) > 0 :
245- click .echo (f"llm-change-agent result: { response } " )
246- formatted_body = "The following commands were executed: </br> "
247- else :
248- click .echo (f"""{ issue [TITLE ]} does not need ontobot's attention.""" )
265+ click .echo (f"{ issue [TITLE ]} does not need ontobot's attention." )
249266 else :
250267 click .echo (
251- f"""Issue number:{ number } is either closed, does not exist or has no body."""
268+ f"""{ issue [TITLE ]} does not need ontobot's
269+ attention unless `--use-llm` flag is True."""
252270 )
253- break
254271
255272 new_output = output if output else input
256273
0 commit comments