Skip to content

Commit

Permalink
Added setting for ollama context window size
Browse files Browse the repository at this point in the history
  • Loading branch information
AxelUser committed Oct 4, 2024
1 parent 46133e8 commit 264ee6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/complete/completers/ollama/model_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const settings_schema = z.object({
user_prompt: z.string(),
temperature: z.number().optional(),
prompt_length: z.number().optional(),
context_window_size: z.number().min(1).optional(),
});

export type Settings = z.infer<typeof settings_schema>;
Expand Down Expand Up @@ -84,6 +85,25 @@ export function SettingsUI({
}
/>
</SettingsItem>
<SettingsItem name="Context Window Size">
<input
type="number"
min={1}
value={
parsed_settings.context_window_size === undefined
? ""
: parsed_settings.context_window_size
}
onChange={(e) =>
saveSettings(
JSON.stringify({
...parsed_settings,
context_window_size: parseInt(e.target.value),
})
)
}
/>
</SettingsItem>
</>
);
}
3 changes: 3 additions & 0 deletions src/complete/completers/ollama/ollama.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ export default class OllamaModel implements Model {
stream: true,
options: {
temp: model_settings.temperature,
...(model_settings.context_window_size && {
num_ctx: model_settings.context_window_size,
}),
},
});
request.write(body);
Expand Down

0 comments on commit 264ee6b

Please sign in to comment.