autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[Bug]: GET request for files using wrong path in autogenstudio

Open tjb4578 opened this issue 2 years ago • 3 comments

Describe the bug

After executing the sine wave example, the sine_wave.png file does not display. I then tried my own custom example and the same thing happened. The terminal shows that the GET request for the file ended in a 404.

INFO:     127.0.0.1:53348 - "GET /api/files/user/user/198fb9b77fb10d10bae092eea5789295/sine_wave.png HTTP/1.1" 404 Not Found

Here is the actual path to the file:

\files\user\198fb9b77fb10d10bae092eea5789295\sine_wave.png

I'm not sure where the second user is coming from in the GET request. It looks like it might be a concatenation issue. I'm running this on Windows 11 with Mistral Instruct 7B running on LM Studio. I tweaked the default system message slightly to remove the TERMINATE command, as this was causing autogen to terminate before the task was completed successfully. Not sure if that would have any bearing on this though.

Steps to reproduce

No response

Expected Behavior

The GET request should use the correct URI and return a 200.

Screenshots and logs

Screenshot 2024-01-16 222236

Additional Information

Autogen version: 0.0.27a0 Operating System: Windows 11 Python Version: 3.10.6

tjb4578 avatar Jan 17 '24 03:01 tjb4578

Same on Windows 10 with standard installation using anaconda, no change of the default setup, just tried the same use case with exactly the same result as reported by tjb4578.

Additional Information

autogenstudio 0.0.27a0 Windows 10 conda 23.7.4 with python 3.11.7

a-w-b avatar Jan 17 '24 11:01 a-w-b

Hi all,

Thanks for triaging this.

Like you mention, I believe this is a windows-related issue where some code that works correctly on linux resolves incorrectly on windows. Specifically, this function is what determines the url of files that have been updated when autogenstudio runs (this list of files are sent to the front end to be rendered). There is change that the it resolves incorrectly on windows.

I'll take a look later today and report on what I find.

victordibia avatar Jan 17 '24 15:01 victordibia

(Hopefully someone finds this useful) I managed to patch this by simply making a soft symbolic link loop to correct the behaver. (didn't feel like compiling a fix from source so a no-code solution is as follows) launch an administration CMD mklink /D "YOURPYTHONFOLDER(E.G. Anaconda\envs\YOUR ENVIROMENT e.g. (ag)\Lib\site-packages\autogenstudio\web\files\user\user" "YOURPYTHONFOLDER(E.G. Anaconda\envs\YOUR ENVIROMENT e.g. (ag)\Lib\site-packages\autogenstudio\web\files\user" this creates a simple loop where the /user/user folder points to the /user/ folder. ^_^

Incidentally I would recommend solving the OS path issues by implementing the 'pathlib' library. for example Windows uses "" instead of "/" which can be a major issue on cross platform use but pathlib just deals with that.

from what i can see the point of failure in the function is line 184 :: uid = dest_dir.split("/")[-1] just replace with dest_dir_as_path = pathlib.Path(dest_dir) uid = dest_dir_as_path.parent.name and remember to import the library at the top import pathlib

References: pathlib - https://www.freecodecamp.org/news/how-to-use-pathlib-module-in-python/#:~:text=Each%20operating%20system%20has%20different,systems%20to%20expand%20your%20code. symbolic links - https://www.howtogeek.com/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

Starskimmer avatar Jan 17 '24 22:01 Starskimmer

@Starskimmer ,

Thanks for the note. I think you are right. Adding a fix . Will get my paws on a windows machine at some point and test this out.

victordibia avatar Jan 18 '24 05:01 victordibia

This has been addressed and tested to work on windows. Closing out for now. Feel free to reopen if still seeing a related issue.

victordibia avatar Jan 26 '24 20:01 victordibia