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

Class IFlowCodeRunner

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

iFlow Code Runner class to handle interactions with iFlow CLI

Source from the content-addressed store, hash-verified

76
77
78class IFlowCodeRunner:
79 """iFlow Code Runner class to handle interactions with iFlow CLI"""
80
81 def __init__(self, proxy_settings=None, model='iflow-default'):
82 """
83 Initialize the iFlow Code Runner
84
85 Args:
86 proxy_settings: Optional dictionary with HTTP_PROXY and HTTPS_PROXY settings
87 model: Model name to use (default: iflow-default)
88 """
89 self.proxy_settings = proxy_settings or {
90 'HTTP_PROXY': 'http://127.0.0.1:7890',
91 'HTTPS_PROXY': 'http://127.0.0.1:7890'
92 }
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

Callers 2

__init__Method · 0.90
perform_experimentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected