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

Blank lines when writing code #4434

Open
4 tasks done
AndyMik90 opened this issue May 15, 2024 · 2 comments
Open
4 tasks done

Blank lines when writing code #4434

AndyMik90 opened this issue May 15, 2024 · 2 comments
Labels
🐞 bug Something isn't working

Comments

@AndyMik90
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.8

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

Make Gpt-4o or similar LLM's write long code. It looks like it just pushes a lot of blank lines when it reaches the context window?

✔️ Expected Behavior

Either stop at the context window or finish writing the code.

❌ Actual Behavior

a lot of blank lines (see video)

Coding.in.Dify.mp4
Copy link

dosubot bot commented May 15, 2024

To address the issue of unnecessary blank lines when using Gpt-4o or similar LLMs for writing long pieces of code, especially at the context window limit, consider adjusting the response_format parameter in your API call. Opting for a json_object format for responses might help in structuring the output more effectively, which could reduce the occurrence of blank lines. This format allows for parsing and formatting on the client side, giving you control over the output presentation, including handling blank lines.

Here's how you might adjust your API call:

response_format: json_object

Afterwards, on the client side, parse this JSON object and format it into your desired code output, managing blank lines as needed. This approach requires additional client-side handling to parse the JSON object and format it into code, but it offers more control over the output.

Regarding the context window limit, the Gpt-4o model in Dify version 0.6.8 has a token limit of 128,000. This limit is the maximum amount of information the model can consider for generating a response at any given time. The insertion of blank lines when this limit is reached is not explicitly documented, but adjusting the response format as suggested might mitigate the issue.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@dosubot dosubot bot added the 🐞 bug Something isn't working label May 15, 2024
@iamjoel
Copy link
Collaborator

iamjoel commented May 16, 2024

I use the gpt-4o but i can't reproduce the issue. Can you support more detail to reproduce?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants