MCPcopy Create free account
hub / github.com/InternScience/InternAgent / run

Method run

internagent/experiments_utils_iflow.py:95–142  ·  view source on GitHub ↗

Run iFlow Code with the given prompt Args: prompt: The prompt to send to iFlow cwd: The working directory for iFlow to operate in Returns: The stdout output from iFlow

(self, prompt, cwd=None)

Source from the content-addressed store, hash-verified

93 self.model = model
94
95 def run(self, prompt, cwd=None):
96 """
97 Run iFlow Code with the given prompt
98
99 Args:
100 prompt: The prompt to send to iFlow
101 cwd: The working directory for iFlow to operate in
102
103 Returns:
104 The stdout output from iFlow
105 """
106 # Set proxy environment variables
107 env = os.environ.copy()
108 for key, value in self.proxy_settings.items():
109 env[key] = value
110
111 # Enhanced logging - Log start time and command
112 timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
113 log_message = f"[{timestamp}] Running iFlow CLI with prompt: {prompt}..."
114 print(log_message)
115
116 # Run iFlow with appropriate parameters
117 # Capture both stdout and stderr so we can log them properly
118 result = subprocess.run(
119 ['iflow', '--prompt', prompt], # '--model', self.model,
120 cwd=cwd,
121 capture_output=True,
122 text=True,
123 env=env
124 )
125
126 # Enhanced logging - Log completion and output
127 timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
128 log_message = f"[{timestamp}] iFlow command completed with return code: {result.returncode}"
129 print(log_message)
130
131 # Log output summary
132 if result.stdout:
133 output_summary = f"iFlow output : {result.stdout}..."
134 print(output_summary)
135
136 # If there was an error, log that too
137 if result.returncode != 0 or result.stderr:
138 error_message = f"iFlow CLI error (return code {result.returncode}): {result.stderr}"
139 print(error_message)
140
141 # Return the stdout result
142 return result.stdout
143
144
145# RUN EXPERIMENT

Callers 5

perform_experimentsFunction · 0.95
_draftMethod · 0.45
_improveMethod · 0.45
_draftMethod · 0.45
_improveMethod · 0.45

Calls 2

copyMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected