Skip to content

Commit

Permalink
Merge pull request #97 from devxpain-fork/main
Browse files Browse the repository at this point in the history
feat: add numCtx config option for Ollama
  • Loading branch information
tak-bro authored Nov 29, 2024
2 parents 5650410 + e64656a commit f6bbff3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ You can also use your model for free with [Ollama](https://ollama.com/) and it i
ollama run llama3.2 # model you want use. ex) codellama, deepseek-coder
```

3. Set the model and host
3. Set the host, model and numCtx. (The default numCtx value in Ollama is 2048. It is recommended to set it to 4096 or higher.)
```sh
aicommit2 config set OLLAMA.host=<your host>
aicommit2 config set OLLAMA.model=<your model>
aicommit2 config set OLLAMA.numCtx=4096
```

> If you want to use Ollama, you must set **OLLAMA.model**.
Expand Down
1 change: 1 addition & 0 deletions src/services/ai/ollama.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export class OllamaService extends AIService {
],
stream: false,
options: {
num_ctx: this.params.config.numCtx,
temperature: this.params.config.temperature,
top_p: this.params.config.topP,
seed: getRandomNumber(10, 1000),
Expand Down
11 changes: 11 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,17 @@ const modelConfigParsers: Record<ModelName, Record<string, (value: any) => any>>
},
auth: (auth?: string) => auth || '',
key: (key?: string) => key || '',
numCtx: (numCtx?: string) => {
if (!numCtx) {
return 2048;
}

parseAssert('OLLAMA.numCtx', /^\d+$/.test(numCtx), 'Must be an integer');

const parsed = Number(numCtx);
parseAssert('OLLAMA.numCtx', parsed >= 2048, 'Must be greater than 2048');
return parsed;
},
systemPrompt: generalConfigParsers.systemPrompt,
systemPromptPath: generalConfigParsers.systemPromptPath,
codeReviewPromptPath: generalConfigParsers.codeReviewPromptPath,
Expand Down

0 comments on commit f6bbff3

Please sign in to comment.