Skip to content

Commit

Permalink
Unify settings a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
rizerphe committed May 4, 2023
1 parent 9f150c7 commit a84173a
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 72 deletions.
7 changes: 2 additions & 5 deletions src/complete/completers/ai21/provider_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,8 @@ export function SettingsUI({
name="API key"
description={
<>
Your{" "}
<a href="https://studio.ai21.com/account">
AI21 API key
</a>
Your AI21{" "}
<a href="https://studio.ai21.com/account">API key</a>
</>
}
>
Expand Down Expand Up @@ -290,7 +288,6 @@ export function SettingsUI({
<a href="https://docs.ai21.com/reference/j2-complete-ref">
here
</a>
.
</>
}
/>
Expand Down
12 changes: 11 additions & 1 deletion src/complete/completers/chatgpt/provider_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ export function SettingsUI({
saveSettings: (settings: string) => void;
}) {
return (
<SettingsItem name="API key">
<SettingsItem
name="API key"
description={
<>
Your OpenAI{" "}
<a href="https://platform.openai.com/account/api-keys">
API key
</a>
</>
}
>
<input
type="text"
value={parse_settings(settings).api_key}
Expand Down
1 change: 0 additions & 1 deletion src/complete/completers/gooseai/provider_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export function SettingsUI({
<a href="https://goose.ai/dashboard/apikeys">
goose.ai API key
</a>
.
</>
}
>
Expand Down
12 changes: 11 additions & 1 deletion src/complete/completers/openai/provider_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ export function SettingsUI({
saveSettings: (settings: string) => void;
}) {
return (
<SettingsItem name="API key">
<SettingsItem
name="API key"
description={
<>
Your OpenAI{" "}
<a href="https://platform.openai.com/account/api-keys">
API key
</a>
</>
}
>
<input
type="text"
value={parse_settings(settings).api_key}
Expand Down
173 changes: 109 additions & 64 deletions src/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,16 @@ function AcceptSettingsComponent({

return (
<>
<SettingsItem name="Delay">
<SettingsItem
name="Delay"
description={
<>
The plugin will wait this long before getting a
completion. The lower the delay, the faster the
completions, but the more they cost.
</>
}
>
<input
type="number"
value={delay}
Expand All @@ -297,7 +306,15 @@ function AcceptSettingsComponent({
/>
<span>ms</span>
</SettingsItem>
<SettingsItem name="Use a CodeMiror Keybind">
<SettingsItem
name="Use a CodeMiror Keybind"
description={
<>
Allows you to use simpler keybinds like <code>Tab</code>{" "}
but might not work with other plugins.
</>
}
>
<div
className={
"checkbox-container" +
Expand All @@ -309,7 +326,16 @@ function AcceptSettingsComponent({
/>
</SettingsItem>
{keybind === null ? null : (
<SettingsItem name="CodeMiror Keybind">
<SettingsItem
name="CodeMiror Keybind"
description={
<>
<a href="https://codemirror.net/docs/ref/#h_key_bindings">
Keybind format
</a>
</>
}
>
<input
type="text"
value={keybind || ""}
Expand All @@ -319,67 +345,77 @@ function AcceptSettingsComponent({
/>
</SettingsItem>
)}
<SettingsItem name="Accept">
<button
onClick={() =>
setAcceptSettings({
splitter_regex: " ",
display_splitter_regex: "\\.",
completion_completeness_regex: ".*(?!p{L})[^d]$",
min_accept_length: 4,
min_display_length: 50,
retrigger_threshold: 48,
})
}
>
One word at a time
</button>
<button
onClick={() =>
setAcceptSettings({
splitter_regex: "\\.",
display_splitter_regex: "\\.",
completion_completeness_regex: ".*[^d]$",
min_accept_length: 4,
min_display_length: 50,
retrigger_threshold: 128,
})
}
>
One sentence at a time
</button>
<button
onClick={() =>
setAcceptSettings({
splitter_regex: "\n",
display_splitter_regex: "\n",
completion_completeness_regex: ".*$",
min_accept_length: 4,
min_display_length: 50,
retrigger_threshold: 128,
})
}
>
One line at a time
</button>
<button
onClick={() =>
setAcceptSettings({
splitter_regex: "$",
display_splitter_regex: "$",
completion_completeness_regex: ".*",
min_accept_length: 0,
min_display_length: 0,
retrigger_threshold: 128,
})
}
>
Whole completion
</button>
<SettingsItem
name="Accept"
description={
<div style={{ minWidth: "max-content" }}>
<div>These are presets.</div>
<div onClick={() => setExpanded(!expanded)}>
{expanded ? "▾" : "▸"} Advanced controls
</div>
</div>
}
>
<div className="ai-complete-accept-presets">
<button
onClick={() =>
setAcceptSettings({
splitter_regex: " ",
display_splitter_regex: "\\.",
completion_completeness_regex:
".*(?!p{L})[^d]$",
min_accept_length: 4,
min_display_length: 50,
retrigger_threshold: 48,
})
}
>
One word at a time
</button>
<button
onClick={() =>
setAcceptSettings({
splitter_regex: "\\.",
display_splitter_regex: "\\.",
completion_completeness_regex: ".*[^d]$",
min_accept_length: 4,
min_display_length: 50,
retrigger_threshold: 128,
})
}
>
One sentence at a time
</button>
<button
onClick={() =>
setAcceptSettings({
splitter_regex: "\n",
display_splitter_regex: "\n",
completion_completeness_regex: ".*$",
min_accept_length: 4,
min_display_length: 50,
retrigger_threshold: 128,
})
}
>
One line at a time
</button>
<button
onClick={() =>
setAcceptSettings({
splitter_regex: "$",
display_splitter_regex: "$",
completion_completeness_regex: ".*",
min_accept_length: 0,
min_display_length: 0,
retrigger_threshold: 128,
})
}
>
Whole completion
</button>
</div>
</SettingsItem>
<span onClick={() => setExpanded(!expanded)}>
{expanded ? "▾" : "▸"} Advanced
</span>
{expanded && (
<div className="ai-complete-advanced-settings">
<SettingsItem
Expand Down Expand Up @@ -505,7 +541,16 @@ export default function SettingsComponent({
return (
<>
<>
<SettingsItem name="Enable by default">
<SettingsItem
name="Enable by default"
description={
<>
If the plugin isn't enabled by default, use Ctrl+P
and search for Toggle Completion. You can also add a
shortcut to it
</>
}
>
<div
className={
"checkbox-container" +
Expand Down

0 comments on commit a84173a

Please sign in to comment.