0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ローカルでコード補助ツールcontinueを試してみる

Posted at

はじめに

VSCodeの拡張機能continueを使うとコード補完やコード修正してくれるようなので、試してみました。
全てローカルで動かしたかったので、手持ちのMacBookでやってみましたが、動作が遅くて実用的ではありませんでした。ollamaを動かすサーバを別で用意したほうが良さそうです。

目的

  • VSCodeでコード補完などができるツールを試したい
  • ローカル環境で完結する

環境

  • MacBook Pro
    • プロセッサ:1.4 GHz クアッドコアIntel Core i5
    • メモリ:16 GB
  • continue 1.0.8
  • ollama ollama 0.3.12

continueを試してみた

設定

VSCodeの拡張機能からcontinueをインストールする。
公式に書いてあるように、continueのウィンドウがVSCodeの右側に表示されるようにする。
https://docs.continue.dev/getting-started/install

今回はローカルのみで使用を考えているため、以下の画面で「Or, remain local」をクリックする。

スクリーンショット 2025-05-06 17.39.24.png

画面に表示された通りに、モデルのインストールを行い、「Connect」をクリックする。
スクリーンショット 2025-05-05 12.07.16.png

configファイルを開く

settingからconfigファイルを開けず、開き方がよくわからなかったが、以下で開けた。自分でモデルを追加したい場合は、これを編集する。

デフォルトでは"~/.continue/config.yaml"に保存されている。

chat画面からプルダウンを開き、「+Add Chat model」をクリックする。

以下の画面が開くので、右下の「config file」をクリックする。

config.yamlが開く。先ほどインストールしたモデルの設定が書かれている。

name: Local Assistant
version: 1.0.0
schema: v1
models:
  - name: Llama 3.1 8B
    provider: ollama
    model: llama3.1:8b
    roles:
      - chat
      - edit
      - apply
  - name: Qwen2.5-Coder 1.5B
    provider: ollama
    model: qwen2.5-coder:1.5b-base
    roles:
      - autocomplete
  - name: Nomic Embed
    provider: ollama
    model: nomic-embed-text:latest
    roles:
      - embed
  - name: Autodetect
    provider: ollama
    model: AUTODETECT
context:
  - provider: code
  - provider: docs
  - provider: diff
  - provider: terminal
  - provider: problems
  - provider: folder
  - provider: codebase

tutorialをやってみた

githubに公開されているcontinue_tutorial.pyを試してみた。chat, edit, autocompleteの機能を簡単に試すことができる。私のMacBookではいずれの処理も1分程度かかっていた。。。
https://github.com/continuedev/continue/blob/main/extensions/vscode/continue_tutorial.py

chat

continue_tutorial.pyのコード

## Highlight the code below
## Press [Cmd/Ctrl + L] to add to Chat
## Try asking Continue "what sorting algorithm is this?"
def sorting_algorithm(x):
    for i in range(len(x)):
        for j in range(len(x) - 1):
            if x[j] > x[j + 1]:
                x[j], x[j + 1] = x[j + 1], x[j]
    return x

書いてある通りにコードを選択してCmd+Lするとchat欄にコードが貼り付けられた。"what sorting algorithm is this?"と聞くと、以下のように回答が返ってきた。

スクリーンショット 2025-05-05 12.44.38.png

edit

continue_tutorial.pyのコード

## Highlight the code below
## Press [Cmd/Ctrl + I] to Edit
## Try asking Continue to "make this more readable"
def sorting_algorithm(x):
    for i in range(len(x)):
        for j in range(len(x) - 1):
            if x[j] > x[j + 1]:
                x[j], x[j + 1] = x[j + 1], x[j]
    return x

書いてある通りにコードを選択してCmd+Iするとchat欄にコードが貼り付けられた。"make this more readable"と編集依頼すると、continue_tutorial.pyファイル上に修正案が表示された。Acceptを押すだけで修正案が反映される。修正案が出てくるまで1分くらいかかった。

スクリーンショット 2025-05-05 14.28.26.png

"docstringを日本語で書いてください。"と依頼したところ、以下のように日本語で書いてくれた。

スクリーンショット 2025-05-06 18.23.39.png

autocomplete

continue_tutorial.pyのコード

## Place cursor after `sorting_algorithm...` below and press [Enter]
## Press [Tab] to accept the Autocomplete suggestion

# Basic assertion for sorting_algorithm...

書いてある通りに、sorting_algorithm...の下の行にカーソルを移動して、少し待つと以下のようにコード案が出てきた。私がやったところ、sorting_algorithm関数のテスト関数が出てきた。数行出てくる -> Accept -> また数行出てくる といったように少しずつコードが補完された。

スクリーンショット 2025-05-05 14.47.27.png

スクリーンショット 2025-05-05 14.45.28.png

おわりに

chatGPTにコード書かせる -> コピペもいいけど、continueを使うと全部VSCode上でできるので良いと思います。もっとモデルが早く動かせる環境だったら、便利だと思いました。
まだあまり使っていませんが、単体テストのコードとか補完してくれたらとても便利です。

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?