diff --git a/README.md b/README.md index 3d6440b..02e3516 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ You can also run it with local model through ollama: ```sh git add -AI_PROVIDER='ollama' opencommit +OCO_AI_PROVIDER='ollama' opencommit ``` ### Flags diff --git a/out/cli.cjs b/out/cli.cjs index ef00030..0e0cbde 100755 --- a/out/cli.cjs +++ b/out/cli.cjs @@ -16384,7 +16384,7 @@ function G3(t, e2) { // package.json var package_default = { name: "opencommit", - version: "3.0.10", + version: "3.0.11", description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}", keywords: [ "git", @@ -21991,12 +21991,11 @@ var api = new OpenAi(); var OllamaAi = class { async generateCommitMessage(messages) { const model = "mistral"; - let prompt = messages.map((x4) => x4.content).join("\n"); - prompt += "Summarize above git diff in 10 words or less"; - const url3 = "http://localhost:11434/api/generate"; + const url3 = "http://localhost:11434/api/chat"; const p4 = { model, - prompt, + messages, + options: { temperature: 0, top_p: 0.1 }, stream: false }; try { @@ -22005,8 +22004,8 @@ var OllamaAi = class { "Content-Type": "application/json" } }); - const answer = response.data?.response; - return answer; + const message = response.data.message; + return message?.content; } catch (err) { const message = err.response?.data?.error ?? err.message; throw new Error("local model issues. details: " + message); @@ -22661,7 +22660,7 @@ var hookCommand = G3( return ce(`${source_default.green("\u2714")} Hook is removed`); } throw new Error( - `Unsupported mode: ${mode2}. Supported modes are: 'set' or 'unset'` + `Unsupported mode: ${mode2}. Supported modes are: 'set' or 'unset', do: \`oco hook set\`` ); } catch (error) { ce(`${source_default.red("\u2716")} ${error}`); diff --git a/out/github-action.cjs b/out/github-action.cjs index 9ee7c66..3c6febe 100644 --- a/out/github-action.cjs +++ b/out/github-action.cjs @@ -27486,12 +27486,11 @@ var api = new OpenAi(); var OllamaAi = class { async generateCommitMessage(messages) { const model = "mistral"; - let prompt = messages.map((x2) => x2.content).join("\n"); - prompt += "Summarize above git diff in 10 words or less"; - const url2 = "http://localhost:11434/api/generate"; + const url2 = "http://localhost:11434/api/chat"; const p2 = { model, - prompt, + messages, + options: { temperature: 0, top_p: 0.1 }, stream: false }; try { @@ -27500,8 +27499,8 @@ var OllamaAi = class { "Content-Type": "application/json" } }); - const answer = response.data?.response; - return answer; + const message = response.data.message; + return message?.content; } catch (err) { const message = err.response?.data?.error ?? err.message; throw new Error("local model issues. details: " + message); diff --git a/package-lock.json b/package-lock.json index d5c031d..1a26a7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "opencommit", - "version": "3.0.10", + "version": "3.0.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "opencommit", - "version": "3.0.10", + "version": "3.0.11", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", diff --git a/package.json b/package.json index d2d61b5..0b2fe31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opencommit", - "version": "3.0.10", + "version": "3.0.11", "description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫", "keywords": [ "git", diff --git a/src/engine/ollama.ts b/src/engine/ollama.ts index 2ca324b..f431ee1 100644 --- a/src/engine/ollama.ts +++ b/src/engine/ollama.ts @@ -8,14 +8,14 @@ export class OllamaAi implements AiEngine { ): Promise { const model = 'mistral'; // todo: allow other models - let prompt = messages.map((x) => x.content).join('\n'); - //hoftix: local models are not so clever so im changing the prompt a bit... - prompt += 'Summarize above git diff in 10 words or less'; + //console.log(messages); + //process.exit() - const url = 'http://localhost:11434/api/generate'; + const url = 'http://localhost:11434/api/chat'; const p = { model, - prompt, + messages, + options: {temperature: 0, top_p: 0.1}, stream: false }; try { @@ -24,8 +24,10 @@ export class OllamaAi implements AiEngine { 'Content-Type': 'application/json' } }); - const answer = response.data?.response; - return answer; + + const message = response.data.message; + + return message?.content; } catch (err: any) { const message = err.response?.data?.error ?? err.message; throw new Error('local model issues. details: ' + message);