ollama-holes-plugin 0.1.5.2 → 0.1.5.3
raw patch · 4 files changed
+53/−39 lines, 4 filesdep −exceptionsPVP ok
version bump matches the API change (PVP)
Dependencies removed: exceptions
API changes (from Hackage documentation)
Files
- CHANGELOG.md +8/−0
- README.md +37/−33
- ollama-holes-plugin.cabal +5/−4
- src/GHC/Plugin/OllamaHoles.hs +3/−2
CHANGELOG.md view
@@ -1,5 +1,13 @@ # Revision history for OllamaHoles +## 0.1.5.3 -- 2024-05-02++* CI: Add GitHub Actions workflow for building and testing+* CI: Build for all supported GHC versions, only run tests on GHC 9.12+* Improvement: Update prompt and default model+* Update documentation+* Dependency: Remove unused exceptions dependency+ ## 0.1.5.2 -- 2024-05-01 * Bugfix: rework hole-fit validation, zonk the type and pass it on.
README.md view
@@ -7,11 +7,13 @@ Before using this plugin, make sure you have the Ollama CLI installed and the model you want to use is available. You can install the Ollama CLI by following the instructions at [https://ollama.com/download](https://ollama.com/download),-and you can install the default model (gemma3:27b) by running `ollama pull gemma3:27b`.+and you can install the default model (qwen3) by running `ollama pull qwen3`. Note that the speed and quality of the hole-fits generated by the plugin depends on the model you use, and the default model requires a GPU to run efficiently.-For a smaller model, we suggest `gemma3:4b-it-qat`, or `deepcoder:1.5b`.+For a smaller model, we suggest `gemma3:4b-it-qat`, `phi4-mini-reasoning` or `deepcoder:1.5b`,+or one of the smaller `qwen3` models, such as `qwen3:1.7b` or `qwen3:4b` or even `qwen3:0.6b`,+though results may vary. This plugin is also availble on Hackage [https://hackage.haskell.org/package/ollama-holes-plugin](https://hackage.haskell.org/package/ollama-holes-plugin) @@ -20,13 +22,10 @@ ```haskell {-# OPTIONS_GHC -fplugin=GHC.Plugin.OllamaHoles #-}-{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:model=gemma3:27b #-}-{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:n=5 #-} module Main where -import Data.List-+import qualified Data.List as L main :: IO () main = do let k = (_b :: [Int] -> [String])@@ -38,7 +37,7 @@ ```text-Main.hs:12:20: error: [GHC-88464]+Main.hs:8:20: error: [GHC-88464] • Found hole: _b :: [Int] -> [String] Or perhaps ‘_b’ is mis-spelled, or not in scope • In the expression: _b :: [Int] -> [String]@@ -47,17 +46,17 @@ do let k = (_b :: [Int] -> [String]) print (k [1, 2, ....]) • Relevant bindings include- k :: [Int] -> [String] (bound at Main.hs:12:15)- main :: IO () (bound at Main.hs:12:1)+ k :: [Int] -> [String] (bound at Main.hs:8:15)+ main :: IO () (bound at Main.hs:8:1) Valid hole fits include map show- Prelude.map show+ pure . show+ fmap show+ L.map show (\xs -> map show xs)- (\xs -> [show x | x <- xs])- (\xs -> concatMap (return . show) xs)- |-12 | main = do let k = (_b :: [Int] -> [String])- | ^^+ |+8 | main = do let k = (_b :: [Int] -> [String])+ | ^^ ``` @@ -73,28 +72,28 @@ ```haskell {-# LANGUAGE DataKinds #-} {-# OPTIONS_GHC -fplugin=GHC.Plugin.OllamaHoles #-}-{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:model=gemma3:27b-it-qat #-}-{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:n=5 #-}-{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:debug #-}+-- Use a bigger model tomake it better at following instructions+{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:model=qwen3:14b #-}+{-# OPTIONS_GHC -fplugin-opt=GHC.Plugin.OllamaHoles:n=10 #-} module Main where import qualified Data.List as L--import GHC.TypeError import Data.Proxy+import GHC.TypeError main :: IO ()-main = do let _guide = Proxy :: Proxy (Text "The function should sort the list and then show each element")- let k = (_b :: [Int] -> [String])- print (k [1,2,3])- +main = do+ let _guide = Proxy :: Proxy (Text "The function should sort the list and then show each element")+ let k = (_b :: [Int] -> [String])+ print (k [1, 2, 3])+ ``` We get: ```text-Main.hs:16:20: error: [GHC-88464]+Main.hs:15:12: error: [GHC-88464] • Found hole: _b :: [Int] -> [String] Or perhaps ‘_b’ is mis-spelled, or not in scope • In the expression: _b :: [Int] -> [String]@@ -104,18 +103,23 @@ let k = (_b :: [Int] -> [String]) print (k [1, 2, ....]) • Relevant bindings include- k :: [Int] -> [String] (bound at Main.hs:16:15)+ k :: [Int] -> [String] (bound at Main.hs:15:7) _guide :: Proxy (Text "The function should sort the list and then show each element")- (bound at Main.hs:15:15)- main :: IO () (bound at Main.hs:15:1)+ (bound at Main.hs:14:7)+ main :: IO () (bound at Main.hs:13:1) Valid hole fits include+ map show . L.sort+ \xs -> map show (L.sort xs) L.map show . L.sort+ \xs -> L.map show (L.sort xs)+ \xs -> [show x | x <- L.sort xs]+ \xs -> L.sort xs >>= \x -> [show x]+ (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits) |-16 | let k = (_b :: [Int] -> [String])- | ^^-+15 | let k = (_b :: [Int] -> [String])+ | ^^ ``` ## Including Documentation@@ -139,11 +143,11 @@ ## Installation 1. Install [Ollama](https://ollama.com/download)-2. Install the `gemma3:27b` model (or any other model you prefer) using the following command:+2. Install the `qwen3` model (or any other model you prefer) using the following command: ```bash -ollama pull gemma3:27b+ollama pull qwen3 ``` 3. Clone this repository and navigate to the directory, and build the project using:
ollama-holes-plugin.cabal view
@@ -20,7 +20,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.5.2+version: 0.1.5.3 -- A short (one-line) description of the package. synopsis: A typed-hole plugin that uses LLMs to generate valid hole-fits@@ -62,7 +62,7 @@ For the Ollama backend, make sure you have the Ollama CLI installed and the model you want to use is available. You can install the Ollama CLI by following the instructions at https://ollama.com/download,- and you can install the default model (gemma3:27b) by running `ollama pull gemma3:27b`.+ and you can install the default model (qwen3) by running `ollama pull qwen3`. For the OpenAI backend, you'll need to set the OPENAI_API_KEY environment variable with your API key. @@ -70,7 +70,9 @@ Note that the speed and quality of the hole-fits generated by the plugin depends on the model you use, and the default model requires a GPU to run efficiently.- For a smaller model, we suggest `gemma3:4b-it-qat`, or `deepcoder:1.5b`.+ For a smaller model, we suggest `gemma3:4b-it-qat`, `phi4-mini-reasoning` or `deepcoder:1.5b`,+ or one of the smaller `qwen3` models, such as `qwen3:1.7b` or `qwen3:4b` or even `qwen3:0.6b`,+ though results may vary. @@ -133,7 +135,6 @@ req ^>= 3.13, modern-uri ^>= 0.3, aeson ^>= 2.2,- exceptions ^>= 0.10, containers >= 0.6 && < 0.8
src/GHC/Plugin/OllamaHoles.hs view
@@ -68,6 +68,7 @@ <> "Pay special attention to the type of the hole, specifically whether it is a function.\n" <> "Make sure you synthesize an expression that matches the type of the hole.\n" <> "Output ONLY the raw Haskell expression(s), one per line.\n"+ <> "Do not try to bind the hole variable, e.g. `_b = ...`. Produce only the expression.\n" <> "Do not include explanations, introductions, or any surrounding text.\n" <> "If you are using a function from scope, make sure to use the qualified name from the list of things in scope.\n" <> "Output a maximum of {numexpr} expresssions.\n"@@ -281,7 +282,7 @@ defaultFlags :: Flags defaultFlags = Flags- { model_name = "gemma3:27b-it-qat"+ { model_name = "qwen3:latest" , backend_name = "ollama" , num_expr = 5 , debug = False@@ -329,7 +330,7 @@ -- | Parse command line options parseFlags :: [CommandLineOption] -> Flags-parseFlags = parseFlags' defaultFlags+parseFlags = parseFlags' defaultFlags . reverse -- reverse so outside options come first where parseFlags' :: Flags -> [CommandLineOption] -> Flags parseFlags' flags [] = flags