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

Prefix is not removed from inline completions when streaming #841

Closed
krassowski opened this issue Jun 19, 2024 · 1 comment · Fixed by #879
Closed

Prefix is not removed from inline completions when streaming #841

krassowski opened this issue Jun 19, 2024 · 1 comment · Fixed by #879
Labels
bug Something isn't working project:completion

Comments

@krassowski
Copy link
Member

krassowski commented Jun 19, 2024

Description

Using GPT 4 from Open AI:

No streaming:

Screenshot from 2024-06-19 16-05-04

Streaming:

Screenshot from 2024-06-19 16-05-23

Reproduce

  1. In inline completer settings change "streaming" to "Always"
  2. Attempt to type something
  3. See the prefix repeated

Expected behavior

No prefix.

Context

2.17.0

@krassowski krassowski added the bug Something isn't working label Jun 19, 2024
@krassowski
Copy link
Member Author

For bulk completion the post-processing method is always applied:

async def generate_inline_completions(
self, request: InlineCompletionRequest
) -> InlineCompletionReply:
chain = self._create_completion_chain()
model_arguments = completion.template_inputs_from_request(request)
suggestion = await chain.ainvoke(input=model_arguments)
suggestion = completion.post_process_suggestion(suggestion, request)

For streaming it is applied conditionally:

async for fragment in chain.astream(input=model_arguments):
suggestion += fragment
if suggestion.startswith("```"):
if "\n" not in suggestion:
# we are not ready to apply post-processing
continue
else:
suggestion = completion.post_process_suggestion(suggestion, request)
elif suggestion.rstrip().endswith("```"):
suggestion = completion.post_process_suggestion(suggestion, request)

Some more refined logic is needed so that the prefix which may be added after opening ``` is also trimmed. It needs to keep track if trimming was performed to avoid removing the prefix-like string second time.

@JasonWeill JasonWeill changed the title Prefix is not removed from incline completions when streaming Prefix is not removed from inline completions when streaming Jun 19, 2024
@dlqqq dlqqq closed this as completed in #879 Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working project:completion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants