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

fix: artifacts content indentation #951

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

juanmcampos
Copy link

This fixes an issue with indentation of the files content.

It works with python, etc

this is an example of how indentation is broken
image

this is how it gets fixed
Captura de pantalla 2024-12-30 a la(s) 5 32 23 p m

@thecodacus
Copy link
Collaborator

thecodacus commented Jan 1, 2025

hey thanks for this PR.
i am skeptical on manual indentation fix. not a big deal for typescript or javascript but critical for python.

need to test this with python code. does this work if the indentation is already correct?

@juanmcampos
Copy link
Author

juanmcampos commented Jan 1, 2025

Hey thank your for the review.

This happens with any generated code not just python.

It should work for any code not just python just mentioned as I read someone had the same problem, what I found out it's related to the artifact indentation.

Code here // <- generated code keeps indentation from the llm

The PR has a fix that takes into account the indentation in general so for code that is not it should work as it leaves the code as is.

@wonderwhy-er
Copy link
Collaborator

As far as Python goes, we do not have support for python anyways no?

@wonderwhy-er wonderwhy-er reopened this Jan 3, 2025
@wonderwhy-er
Copy link
Collaborator

sorry miss clicked on close

@juanmcampos
Copy link
Author

As far as Python goes, we do not have support for python anyways no?

I tested a small pyhton code and it generates the code and runs basic code, it fails sometimes with non basic stuff but that should be an issue webcontainers so its unrelated.

However this PR is not for python, the issue with indentation can be replicated with any code being html, css, jsx, etc

Notice the first line is trimmed properly but from second line any code gets the indentation from the bolt's arctifact markup

image

@thecodacus
Copy link
Collaborator

I will test this PR with different model outputs and see if it works for all

@leex279 leex279 requested review from leex279 and thecodacus January 18, 2025 23:33
@thecodacus
Copy link
Collaborator

I wanted to have a different approach on this. the root cause of llm putting an extra indentation on files was due to system prompt having such indentation in its examples. I have modified the examples best represent the expected outputs
let me know if this fixes the issue #1139
rather than having hardcoded solution its better to encourage the llm to produce correct format

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

Successfully merging this pull request may close these issues.

3 participants