Skip to content

Commit 12aad2e

Browse files
authored
Merge pull request #7702 from uinstinct/ollama-memory-contextlength
fix: ollama detect context length automatically
1 parent 61b525e commit 12aad2e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

core/llm/llms/Ollama.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ class Ollama extends BaseLLM implements ModelInstaller {
269269
return this.modelMap[this.model] ?? this.model;
270270
}
271271

272+
get contextLength() {
273+
const DEFAULT_OLLAMA_CONTEXT_LENGTH = 8192; // twice of https://github.com/ollama/ollama/blob/29ddfc2cab7f5a83a96c3133094f67b22e4f27d1/envconfig/config.go#L185
274+
return this._contextLength ?? DEFAULT_OLLAMA_CONTEXT_LENGTH;
275+
}
276+
272277
private _getModelFileParams(
273278
options: CompletionOptions,
274279
): OllamaModelFileParams {

packages/llm-info/src/providers/os.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export const OsLlms: Omit<LlmInfo, "provider">[] = [
44
{
55
model: "starcoder2:3b",
66
displayName: "StarCoder 2 3B",
7+
contextLength: 8192,
78
},
89
];

0 commit comments

Comments
 (0)