monacopilot 0.18.4 → 0.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,25 +39,28 @@ const editor = monaco.editor.create(document.getElementById('container'), {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
registerCompletion(monaco, editor, {
|
|
42
|
-
endpoint: '/api/complete',
|
|
43
42
|
language: 'javascript',
|
|
43
|
+
// Your API endpoint for handling completion requests
|
|
44
|
+
endpoint: 'https://api.example.com/code-completion',
|
|
44
45
|
});
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
3. **Create your completion API handler**
|
|
48
49
|
|
|
49
50
|
```javascript
|
|
50
|
-
// Create an API handler for the
|
|
51
|
+
// Create an API handler for the endpoint (e.g. /code-completion) you provided
|
|
52
|
+
// in the `registerCompletion` function
|
|
51
53
|
// to handle completion requests from the editor
|
|
52
54
|
|
|
53
55
|
import {Copilot} from 'monacopilot';
|
|
54
56
|
|
|
55
57
|
const copilot = new Copilot(OPENAI_API_KEY, {
|
|
56
|
-
provider: 'openai',
|
|
58
|
+
provider: 'openai',
|
|
59
|
+
model: 'gpt-4o',
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
// Handle completion requests
|
|
60
|
-
app.post('/
|
|
63
|
+
app.post('/code-completion', async (req, res) => {
|
|
61
64
|
const {completion, error, raw} = await copilot.complete({body: req.body});
|
|
62
65
|
|
|
63
66
|
// Optional: Use raw response for analytics or token counting
|
|
@@ -264,7 +267,7 @@ registerCompletion(monaco, editor, {
|
|
|
264
267
|
```
|
|
265
268
|
|
|
266
269
|
> [!NOTE]
|
|
267
|
-
> If you're using `
|
|
270
|
+
> If you're using `groq` as your provider, it's recommended to set `maxContextLines` to `60` or less due to its low rate limits and lack of pay-as-you-go pricing. However, Groq is expected to offer pay-as-you-go pricing in the near future.
|
|
268
271
|
|
|
269
272
|
### Caching Completions
|
|
270
273
|
|
|
@@ -488,9 +491,9 @@ registerCompletion(monaco, editor, {
|
|
|
488
491
|
You can specify a different provider and model by setting the `provider` and `model` parameters in the `Copilot` instance.
|
|
489
492
|
|
|
490
493
|
```javascript
|
|
491
|
-
const copilot = new Copilot(process.env.
|
|
492
|
-
provider: '
|
|
493
|
-
model: '
|
|
494
|
+
const copilot = new Copilot(process.env.ANTHROPIC_API_KEY, {
|
|
495
|
+
provider: 'anthropic',
|
|
496
|
+
model: 'claude-3-5-haiku',
|
|
494
497
|
});
|
|
495
498
|
```
|
|
496
499
|
|