Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long prompts give FileNotFoundError #1131

Open
costabm opened this issue Feb 11, 2025 · 1 comment
Open

Long prompts give FileNotFoundError #1131

costabm opened this issue Feb 11, 2025 · 1 comment

Comments

@costabm
Copy link

costabm commented Feb 11, 2025

Short prompts work well, but with a longer prompt such as:

"When designing long-span road bridges to dynamic loads such as wind or waves, it might be relevant to establish design limits on the vertical and horizontal accelerations of the bridge, to keep traffic safe under a typical 1-year return period storm. Help me find several references of key bridges where such acceleration limits have been established in the design stage, whether in terms of RMS or 1-hour extreme values. It needs to be road bridges, not pedestrian nor rail."

I get:

File "C:\Users\user\PycharmProjects\gpt-researcher\backend\server\server_utils.py", line 28, in init
with open(self.log_file, 'w') as f:
^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'outputs\task_1739276129_When designing long-span road bridges to dynamic loads such as wind or waves it might be relevant to establish design limits on the vertical and horizontal accelerations of the bridge to keep traffic safe under a t.json'
INFO: connection closed

My guess of the problem is that it seems that it tries to create a .json file with the full prompt in the file name, which my Windows won't allow.

@costabm costabm changed the title Long prompts give Exception Long prompts give FileNotFoundError Feb 11, 2025
@ElishaKay
Copy link
Collaborator

ElishaKay commented Feb 17, 2025

Welcome @costabm

Try this: within backend/server/server_utils.py, edit the sanitize_filename function

def sanitize_filename(filename: str) -> str:
    # Remove any non-alphanumeric characters (except underscores and spaces)
    filename = re.sub(r'[^\w\s-]', '', filename)
    
    # Replace spaces with underscores
    filename = re.sub(r'\s+', '_', filename)
    
    # Truncate to a reasonable length (e.g., 50 characters) while keeping the start
    max_length = 50
    if len(filename) > max_length:
        filename = filename[:max_length]
    
    return filename.strip('_')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants