DEV Community

Cover image for Ask AI with Ollama, fully local
JSLab
JSLab

Posted on

Ask AI with Ollama, fully local

JSLab feature notes: one docs page, explained. Today: Ask AI with Ollama.

JSLab, a JavaScript & TypeScript scratchpad for macOS, has an AI Chat panel that answers questions about the code in your tab and returns changes as a diff. It works with your own key, or Ollama locally. This note is about the local option.

Setup: three steps, no key

  1. Install Ollama, a separate, free program that runs models on your Mac, and start it.
  2. Pull a model. JSLab's default for Ollama in this version is qwen2.5:7b-instruct:
   ollama pull qwen2.5:7b-instruct
Enter fullscreen mode Exit fullscreen mode
  1. In JSLab, open Settings → AI and set Provider to Ollama (Local).

That's it. The Model field lists the models you've installed (Refresh re-reads them). Leave it blank for the default, or pick another.

What leaves your Mac

Nothing, as long as Ollama is at its standard address, http://localhost:11434. Each message carries JSLab's instructions, the tab's code (up to 100 KB), the conversation so far, your message and, with Send Recent Output on, the last run's output (up to 20 KB). All of it goes to that local address.

Change Ollama Base URL to point at a bigger machine on your network and it goes there instead. Your choice, made explicitly.

Using it

⌃⌘I opens AI Chat in the side bar. Each tab has its own conversation, and it's saved, so it's still there after a relaunch. An empty chat offers starters: Explain this tab, Why does line N fail? after a failed run, and Add types for the name at the caret.

Code blocks in a reply get four buttons: Copy, Insert at Cursor, Replace Editor and Preview Changes. Preview shows the change as an inline diff in the editor, and nothing changes until you Apply one change, Apply all, or Discard.

JSLab's inline diff from Ask AI: "return settings.editor.tabWidth;" marked for removal and "return settings?.editor?.tabWidth ?? 4;" added in green, with Apply and Discard below.

Explain Result

Right-click any output row and choose Explain Result. JSLab asks why that line produced that value:

[1, 2, 10].sort(); // [1, 10, 2]. Why?
Enter fullscreen mode Exit fullscreen mode

A local model is good at exactly this kind of question: small, concrete, with the code and the value right there.

When it can't connect

"Couldn't reach the provider" with Ollama almost always means Ollama isn't running. Start it and click Retry.

JSLab launches Nov 15. The full pages: https://js-lab.app/docs/ask-ai

Top comments (0)