File tree Expand file tree Collapse file tree
src/praisonai/praisonai/ui/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import asyncio
33from pathlib import Path
44import difflib
5+ import platform
56from typing import Dict , Any
67from litellm import acompletion
78import json
@@ -119,10 +120,24 @@ async def read_file(self, file_path):
119120 except :
120121 return None
121122
123+ def get_shell_command (self , command : str ) -> str :
124+ """
125+ Convert command to be cross-platform compatible.
126+ On Windows, use cmd /c for shell commands.
127+ On Unix-like systems, use the command as-is.
128+ """
129+ if platform .system () == "Windows" :
130+ # For Windows, escape quotes and wrap command in cmd /c
131+ escaped_command = command .replace ('"' , '\\ "' )
132+ return f'cmd /c "{ escaped_command } "'
133+ return command
134+
122135 async def execute_command (self , command : str ):
123136 try :
137+ # Make command cross-platform compatible
138+ shell_command = self .get_shell_command (command )
124139 process = await asyncio .create_subprocess_shell (
125- command ,
140+ shell_command ,
126141 stdout = asyncio .subprocess .PIPE ,
127142 stderr = asyncio .subprocess .PIPE ,
128143 cwd = self .cwd
You can’t perform that action at this time.
0 commit comments