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

Auto completion adding unexpected new empty lines when suggestion is accepted #3567

Open
3 tasks done
PowerfulGhost opened this issue Dec 30, 2024 · 0 comments
Open
3 tasks done
Assignees
Labels
area:autocomplete Relates to the auto complete feature ide:vscode Relates specifically to VS Code extension kind:bug Indicates an unexpected problem or unintended behavior "needs-triage"

Comments

@PowerfulGhost
Copy link

Before submitting your bug report

Relevant environment info

- OS: Windows 10
- Continue version: 0.8.66
- IDE version: Vscode 1.96.2
- Model: Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest
- config.json:
  
{
  "models": [
    {
      "title": "qwen2.5-coder-7b",
      "provider": "ollama",
      "model": "qwen2.5-coder:latest",
      "apiBase": "http://127.0.0.1:16384"
    }
  ],
  "tabAutocompleteModel": {
    "title": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
    "provider": "ollama",
    "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
    "apiBase": "http://127.0.0.1:16384"
  },
  "tabAutocompleteOptions": {
    "multilineCompletions": "never",
    "disableInFiles": [
      "*.json"
    ],
    "useCache": true,
    "transform": true,
    "template": "<|fim_prefix|>{{{ prefix }}}<|fim_suffix|>{{{ suffix }}}<|fim_middle|>",
    "maxPromptTokens": 1024
  },
  "customCommands": [
    {
      "name": "test",
      "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
      "description": "Write unit tests for highlighted code"
    }
  ],
  "contextProviders": [
    {
      "name": "code",
      "params": {}
    },
    {
      "name": "docs",
      "params": {}
    },
    {
      "name": "diff",
      "params": {}
    },
    {
      "name": "terminal",
      "params": {}
    },
    {
      "name": "problems",
      "params": {}
    },
    {
      "name": "folder",
      "params": {}
    },
    {
      "name": "codebase",
      "params": {}
    }
  ],
  "slashCommands": [
    {
      "name": "share",
      "description": "Export the current chat session to markdown"
    },
    {
      "name": "cmd",
      "description": "Generate a shell command"
    },
    {
      "name": "commit",
      "description": "Generate a git commit message"
    }
  ]
}

Description

When accepting suggestion from auto completion, unexpected new line is added to the code, even the multilineCompletions is set to "never".

This bug seems only occurs when llm generates indents at next line.

I believe this bug does not exists in 0.8.56.

sc-1
sc-2
sc-3

To reproduce

  1. Set multilineCompletions to "never".
  2. Make llm to generate a completion with indent at the beginning of next line (may need few trial due to randomness of llm).
  3. You should see the suggestion, along with an unexpected empty new line (without line number before it) right below the cursor's line.
  4. Accept the suggestion.
  5. The suggestion and the empty new line are added to the code.

Log output

==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    ""
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time(<|fim_suffix|>):

    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time:<|fim_suffix|>

    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
Completion:
ABC):
    @abstractmethod
    async def update(self, updater: "StateUpdater"):
        pass

class StateUpdater:
    pass

class Clock(Time):
    async def update(self, updater: "StateUpdater"):
        print("Clock updated")

class WeatherStation

==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time<|fim_suffix|>:

    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
Completion:


==========================================================================
==========================================================================
Completion:
r:
    def __init__(self):
        self.timeout = None

    def set_timeout(self, timeout):
        self.timeout = timeout

    def clear_timeout(self):
        self.timeout = None

class StateUpdater:
    def __init__(self):
        self.state = {}

    def update_state(self, key, value):
        self.state[key] = value

class MyTimer(Timer):

    async def update(self, updater: "StateUpdater"):
        if self.timeout is not None:
            await updater.update_state("timeout", self.timeout)

# 241230/main.py
from test import MyTimer, StateUpdater

async def main():
    timer = MyTimer()
    timer.set_timeout(5)
    updater = StateUpdater()

    await timer.update(updater)

    print(updater.state)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

# 241230/requirements.txt
asyncio==3.8.5


==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time:

    <|fim_suffix|>
<|fim_middle|>==========================================================================
==========================================================================
Completion:
def __init__(self, hour=0, minute=0, second=0):
        self.hour = hour
        self.minute = minute
        self.second = second

    def set_time(self, hour, minute, second):
        self.hour = hour
        self.minute = minute
        self.second = second

    def get_time(self):
        return f"{self.hour:02}:{self.minute:02}:{self.second:02}"

# Example usage:
time1 = Time(9, 30, 45)
print(time1.get_time())  # Output: 09:30:45

time1.set_time(14, 15, 30)
print(time1.get_time())  # Output: 14:15:30


==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time:
    <|fim_suffix|>

    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time:

    <|fim_suffix|>

    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
Completion:
def __init__(self):
        self.hour = 0
        self.minute = 0
        self.second = 0

    def set_time(self, hour: int, minute: int, second: int):
        self.hour = hour
        self.minute = minute
        self.second

==========================================================================
==========================================================================
Completion:
def __init__(self):
        self.hour = 0
        self.minute = 0
        self.second = 0

    def set_time(self, hour: int, minute: int, second: int):
        self.hour = hour
        self.minute = minute
        self.second = second

    async def tick(self):
        pass

class StateUpdater:

    def __init__(self):
        self.time = Time()

    async def update(self, time: Time):
        pass

class Clock(StateUpdater):

    def __init__(self):
        super().__init__()
        self.time.set_time(12, 30, 0)

    async def tick(self):
        await self.update(self.time)
        if self.time.second == 59:
            self.time.second = 0
            if self.time.minute == 59:
                self.time.minute = 0
                if self.time.hour == 23:
                    self.time.hour = 0
                else:
                    self.time.hour += 1
            else:
                self.time.minute += 1
        else:
            self.time.second += 1

    async def update(self, time: Time):
        print(f"Current time is {time.hour}:{time.minute}:{time.second}")

class Alarm(StateUpdater):

    def __init__(self):
        super().__init__()
        self.alarm_time = Time()

    async def set_alarm(self, hour: int, minute: int, second: int):
        self.alarm_time.set_time(hour, minute, second)

    async def check_alarm(self):
        if self.time.hour == self.alarm_time.hour and \
           self.time.minute == self.alarm_time.minute and \
           self.time.second == self.alarm_time.second:
            print("Alarm!")

class Weather(StateUpdater):

    def __init__(self):
        super().__init__()
        self.temperature = 0
        self.humidity = 0

    async def update(self, temperature: int, humidity: int):
        self.temperature = temperature
        self.humidity = humidity
        print(f"Current weather is {self.temperature}°C and {self.humidity}% humidity")

class WeatherStation(StateUpdater):

    def __init__(self):
        super().__init__()
        self.weather = Weather()

    async def update(self, temperature: int, humidity: int):
        await self.weather.update(temperature, humidity)

class SmartHome:

    def __init__(self):
        self.clock = Clock()
        self.alarm = Alarm()
        self.weather_station = WeatherStation()

    async def tick(self):
        await self.clock.tick()
        await self.alarm.check_alarm()
        await self.weather_station.update(25, 60)

async def main():
    smart_home = SmartHome()
    while True:
        await smart_home.tick()
        await asyncio.sleep(1)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())


==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time:

<|fim_suffix|>

    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
Completion:
    def __init__(self):
        self.hour = 0
        self.minute = 0
        self.second = 0

    def set_time(self, hour: int, minute: int, second: int):
        self.hour = hour
        self.minute = minute
        self.second = second

    def get_time(self) -> str:
        return f"{self.hour:02}:{self.minute:02}:{self.second:02}"

class StateUpdater:

    async def update(self, state: "State"):
        pass

class State:

    def __init__(self):
        self.time = Time()

    async def update_time(self, hour: int, minute: int, second: int):
        self.time.set_time(hour, minute, second)

    async def get_time_string(self) -> str:
        return self.time.get_time()

==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time:

    def __init__(self):
        self.hour = 0
        self.minute = 0
        self.second = 0
        <|fim_suffix|>




    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "model": "Rombos-Coder-V2.5-Qwen-7b-Q4_K_L:latest",
  "maxTokens": 4096,
  "temperature": 0.01,
  "stop": [
    "/src/",
    "#- coding: utf-8",
    "```"
  ],
  "raw": true
}

##### Prompt #####
<|fim_prefix|>
# 241230/test.py
class Time:

    def __init__(self):
        self.hour = 0
        self.minute = 0
        self.second = 0
        self.time_str = ""
        <|fim_suffix|>





    async def update(self, updater: "StateUpdater"):
        pass<|fim_middle|>==========================================================================
==========================================================================
Completion:
self.time_str = ""

    def set_time(self, hour: int, minute: int, second: int):
        self.hour = hour
        self.minute = minute
        self.second = second
        self.update_time_str()

    def update_time_str(self):
        self.time_str = f"{self.hour:02}:{self.minute:02}:{self.second:02}"

    def get_time_str(self) -> str:
        return self.time_str



==========================================================================
==========================================================================
Completion:
self.state = None

    def set_time(self, hour: int, minute: int, second: int):
        self.hour = hour
        self.minute = minute
        self.second = second
        self.time_str = f"{hour:02}:{minute:02}:{second:02}"

    def get_time(self) -> str:
        return self.time_str

    async def update(self, updater: "StateUpdater"):
        pass

class StateUpdater:

    def __init__(self):
        self.state = None

    def set_state(self, state: Time):
        self.state = state

    def get_state(self) -> Time:
        return self.state

# 241230/main.py
import asyncio
from test import Time, StateUpdater

async def main():
    time_obj = Time()
    updater = StateUpdater()

    # Set initial time
    time_obj.set_time(12, 30, 45)
    updater.set_state(time_obj)

    # Update the state with new time
    await asyncio.sleep(5)  # Simulate some delay
    time_obj.set_time(14, 45, 30)
    updater.set_state(time_obj)

    # Get and print the updated time
    current_time = updater.get_state().get_time()
    print("Current Time:", current_time)

if __name__ == "__main__":
    asyncio.run(main())
@dosubot dosubot bot added area:autocomplete Relates to the auto complete feature ide:vscode Relates specifically to VS Code extension kind:bug Indicates an unexpected problem or unintended behavior labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:autocomplete Relates to the auto complete feature ide:vscode Relates specifically to VS Code extension kind:bug Indicates an unexpected problem or unintended behavior "needs-triage"
Projects
None yet
Development

No branches or pull requests

2 participants