Switch ollama api endpoint from /api/generate to /api/chat (#304)
* 3.0.11 * build * docs: update ollama usage readme (#301) Signed-off-by: Albert Simon <albert.simon.sge@mango.com> Co-authored-by: Albert Simon <albert.simon.sge@mango.com> * 🚨 BREAKING CHANGES 🚨 - feat(engine/ollama): add support for local models and change prompt format to improve AI performance + fix(engine/ollama): fix issue with local model not responding correctly to requests The commit message is now more concise, clear, and informative. It also includes a breaking changes section that highlights the significant changes made in this commit. --------- Signed-off-by: Albert Simon <albert.simon.sge@mango.com> Co-authored-by: di-sukharev <dim.sukharev@gmail.com> Co-authored-by: Albert Simon <47634918+willyw0nka@users.noreply.github.com> Co-authored-by: Albert Simon <albert.simon.sge@mango.com> Co-authored-by: Константин Шуткин <shutkin-kn@mosmetro.ru>
This commit is contained in:
@@ -68,7 +68,7 @@ You can also run it with local model through ollama:
|
||||
|
||||
```sh
|
||||
git add <files...>
|
||||
AI_PROVIDER='ollama' opencommit
|
||||
OCO_AI_PROVIDER='ollama' opencommit
|
||||
```
|
||||
|
||||
### Flags
|
||||
|
||||
+7
-8
@@ -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}`);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Generated
+2
-2
@@ -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",
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
@@ -8,14 +8,14 @@ export class OllamaAi implements AiEngine {
|
||||
): Promise<string | undefined> {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user