|
11 | 11 | InputRequiredEvent, |
12 | 12 | JsonPickleSerializer, |
13 | 13 | ) |
| 14 | +from llama_index.core.workflow.errors import WorkflowTimeoutError |
14 | 15 | from llama_index.core.workflow.handler import WorkflowHandler |
15 | 16 | from openinference.instrumentation.llama_index import ( |
16 | 17 | LlamaIndexInstrumentor, |
@@ -114,15 +115,33 @@ async def execute(self) -> Optional[UiPathRuntimeResult]: |
114 | 115 | if resume_trigger is None: |
115 | 116 | try: |
116 | 117 | output = await handler |
| 118 | + # catch any script exceptions |
| 119 | + except Exception as e: |
| 120 | + raise UiPathLlamaIndexRuntimeError( |
| 121 | + "AGENT_EXECUTION_FAILURE", |
| 122 | + "There was an exception while executing the agent ", |
| 123 | + str(e), |
| 124 | + UiPathErrorCategory.USER, |
| 125 | + ) from e |
| 126 | + try: |
117 | 127 | serialized_output = self._serialize_object(output) |
118 | 128 | # create simple kvp from string |
119 | 129 | if type(serialized_output) is str: |
120 | 130 | serialized_output = {"result": serialized_output} |
| 131 | + |
121 | 132 | print(serialized_output) |
122 | 133 | self.context.result = UiPathRuntimeResult( |
123 | 134 | output=serialized_output, |
124 | 135 | status=UiPathRuntimeStatus.SUCCESSFUL, |
125 | 136 | ) |
| 137 | + # check if workflow failed because of timeout constraints |
| 138 | + except WorkflowTimeoutError as e: |
| 139 | + raise UiPathLlamaIndexRuntimeError( |
| 140 | + "TIMEOUT_ERROR", |
| 141 | + "Workflow timed out", |
| 142 | + str(e), |
| 143 | + UiPathErrorCategory.USER, |
| 144 | + ) from e |
126 | 145 | except Exception as e: |
127 | 146 | raise UiPathLlamaIndexRuntimeError( |
128 | 147 | "SERIALIZE_OUTPUT_ERROR", |
|
0 commit comments