nbaldwin commited on
Commit
ddf8801
·
1 Parent(s): 43e0ed4

added feedback for if code runs or not

Browse files
InterpreterAtomicFlow.py CHANGED
@@ -31,6 +31,7 @@ class InterpreterAtomicFlow(AtomicFlow):
31
 
32
  *Output Interface*:
33
  - `interpreter_output`: output of the code interpreter
 
34
 
35
  *Configuration Parameters*:
36
  - None
@@ -102,6 +103,7 @@ class InterpreterAtomicFlow(AtomicFlow):
102
  def _call(self):
103
  """ This method runs the code interpreter and returns the output. (runs the code interpreter and returns the output.)
104
  """
 
105
  output = ""
106
  try:
107
  code_interpreter = self._code_interpreters[self.flow_state["language"]]
@@ -115,7 +117,8 @@ class InterpreterAtomicFlow(AtomicFlow):
115
  except:
116
  output = traceback.format_exc()
117
  output = output.strip()
118
- return output
 
119
 
120
  def run(
121
  self,
@@ -128,9 +131,16 @@ class InterpreterAtomicFlow(AtomicFlow):
128
  self._check_input(input_data)
129
  self._process_input_data(input_data)
130
 
 
 
 
 
 
 
 
131
  reply = self.package_output_message(
132
  input_message=input_message,
133
- response = {"interpreter_output": self._call()}
134
  )
135
 
136
  self.send_message(reply)
 
31
 
32
  *Output Interface*:
33
  - `interpreter_output`: output of the code interpreter
34
+ - `code_runs`: whether the code runs successfully or not
35
 
36
  *Configuration Parameters*:
37
  - None
 
103
  def _call(self):
104
  """ This method runs the code interpreter and returns the output. (runs the code interpreter and returns the output.)
105
  """
106
+ code_runs = True
107
  output = ""
108
  try:
109
  code_interpreter = self._code_interpreters[self.flow_state["language"]]
 
117
  except:
118
  output = traceback.format_exc()
119
  output = output.strip()
120
+ code_runs = False
121
+ return output, code_runs
122
 
123
  def run(
124
  self,
 
131
  self._check_input(input_data)
132
  self._process_input_data(input_data)
133
 
134
+ output = self._call()
135
+
136
+ response = {
137
+ "interpreter_output": output[0],
138
+ "code_runs": output[1]
139
+ }
140
+
141
  reply = self.package_output_message(
142
  input_message=input_message,
143
+ response = response
144
  )
145
 
146
  self.send_message(reply)
InterpreterAtomicFlow.yaml CHANGED
@@ -1,4 +1,12 @@
1
  name: "InterpreterAtomicFlow"
2
  description: "A flow that compiles and runs codes"
3
  _target_: flow_modules.aiflows.InterpreterFlowModule.InterpreterAtomicFlow.instantiate_from_default_config
4
- max_output: 2000
 
 
 
 
 
 
 
 
 
1
  name: "InterpreterAtomicFlow"
2
  description: "A flow that compiles and runs codes"
3
  _target_: flow_modules.aiflows.InterpreterFlowModule.InterpreterAtomicFlow.instantiate_from_default_config
4
+ max_output: 2000
5
+
6
+ input_interface:
7
+ - "language"
8
+ - "code"
9
+
10
+ output_interface:
11
+ - interpreter_output
12
+ - code_runs