| 63 | return "OpenAI API error." |
| 64 | |
| 65 | def extend_workflow(self, task_prompt, current_workflow, step): |
| 66 | messages = self.messages + [{'role': 'user', "content": PLANNING_LLM_PREFIX+'\nThe task is:\n'+task_prompt+PLANNING_LLM_SUFFIX}] |
| 67 | messages.append({'role': 'user', "content": EXTEND_PREFIX+ |
| 68 | 'The current SOP is:\n'+current_workflow+ |
| 69 | '\nThe step needs to be extended is:\n'+step+ |
| 70 | PLANNING_LLM_SUFFIX}) |
| 71 | response, status = self.LLM.run(messages) |
| 72 | if status: |
| 73 | return self._txt2json(response) |
| 74 | else: |
| 75 | return "OpenAI API error." |
| 76 | |
| 77 | def _txt2json(self, workflow_txt): |
| 78 | ''' convert the workflow in natural language to json format ''' |