Skip to content

Commit

Permalink
chore: update ontyping threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
arshad-yaseen committed Feb 17, 2025
1 parent c1bdeb1 commit 49b2c83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
8 changes: 4 additions & 4 deletions docs/configuration/register-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `trigger` option determines when the completion service provides code comple

```javascript
registerCompletion(monaco, editor, {
trigger: 'onTyping', // Only recommended for low-latency and low-cost models
trigger: 'onTyping',
});
```

Expand All @@ -27,13 +27,13 @@ registerCompletion(monaco, editor, {
::: info
For the best experience with `onTyping` mode:

- Use fast, cost-effective models like Groq's `llama-3-70b` or OpenAI's `gpt-4o-mini` for real-time completions
- Use super fast, cost-effective models like Groq's `llama-3-70b` for real-time completions
- For higher accuracy needs, consider using `onIdle` mode with models like `claude-3-5-sonnet`, `claude-3-5-haiku`, etc.
- The `onTyping` mode makes more API calls to provide instant suggestions, so choose your model accordingly
- The `onTyping` mode makes more API calls in the background to provide instant suggestions, so choose your model accordingly
:::

::: tip
We recommend using `onTyping` mode with Groq's `llama-3-70b` for super fast, realtime completions while you type.
Use `onTyping` mode with Groq's `llama-3-70b` for super fast, realtime completions while you type.
:::

## Manually Trigger Completions
Expand Down
23 changes: 9 additions & 14 deletions packages/monacopilot/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {createInlineCompletionResult} from './utils/inline-completion';

// [base delay, typing threshold]
const TYPING_DEBOUNCE_PARAMS = {
[TriggerType.OnTyping]: [600, 120],
[TriggerType.OnTyping]: [500, 100],
[TriggerType.OnIdle]: [600, 400],
[TriggerType.OnDemand]: [0, 0],
};
Expand Down Expand Up @@ -95,30 +95,25 @@ export const processInlineCompletions = async ({
.build();

const completionRange = new CompletionRange(monaco);
const completionInsertionRange =
completionRange.computeInsertionRange(
pos,
formattedCompletion,
mdl,
);

const cacheRange = completionRange.computeCacheRange(
pos,
formattedCompletion,
);

if (enableCaching) {
completionCache.add({
completion: formattedCompletion,
range: cacheRange,
range: completionRange.computeCacheRange(
pos,
formattedCompletion,
),
textBeforeCursor: getTextBeforeCursor(pos, mdl),
});
}

return createInlineCompletionResult([
{
insertText: formattedCompletion,
range: completionInsertionRange,
range: completionRange.computeCacheRange(
pos,
formattedCompletion,
),
},
]);
}
Expand Down

0 comments on commit 49b2c83

Please sign in to comment.