monacopilot 0.18.4 → 0.18.5
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 +9 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ const editor = monaco.editor.create(document.getElementById('container'), {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
registerCompletion(monaco, editor, {
|
|
42
|
-
endpoint: '
|
|
42
|
+
endpoint: 'https://api.example.com/code-completion', // Your API endpoint for handling completion requests
|
|
43
43
|
language: 'javascript',
|
|
44
44
|
});
|
|
45
45
|
```
|
|
@@ -47,17 +47,18 @@ registerCompletion(monaco, editor, {
|
|
|
47
47
|
3. **Create your completion API handler**
|
|
48
48
|
|
|
49
49
|
```javascript
|
|
50
|
-
// Create an API handler for the
|
|
50
|
+
// Create an API handler for the endpoint (e.g. /code-completion) you provided in the `registerCompletion` function
|
|
51
51
|
// to handle completion requests from the editor
|
|
52
52
|
|
|
53
53
|
import {Copilot} from 'monacopilot';
|
|
54
54
|
|
|
55
55
|
const copilot = new Copilot(OPENAI_API_KEY, {
|
|
56
|
-
provider: 'openai', // or 'anthropic', 'google', etc
|
|
56
|
+
provider: 'openai', // or 'anthropic', 'google', etc.,
|
|
57
|
+
model: 'gpt-4o', // or 'claude-3-5-haiku', 'gpt-4o-mini', etc.
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
// Handle completion requests
|
|
60
|
-
app.post('/
|
|
61
|
+
app.post('/code-completion', async (req, res) => {
|
|
61
62
|
const {completion, error, raw} = await copilot.complete({body: req.body});
|
|
62
63
|
|
|
63
64
|
// Optional: Use raw response for analytics or token counting
|
|
@@ -264,7 +265,7 @@ registerCompletion(monaco, editor, {
|
|
|
264
265
|
```
|
|
265
266
|
|
|
266
267
|
> [!NOTE]
|
|
267
|
-
> If you're using `
|
|
268
|
+
> 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
269
|
|
|
269
270
|
### Caching Completions
|
|
270
271
|
|
|
@@ -488,9 +489,9 @@ registerCompletion(monaco, editor, {
|
|
|
488
489
|
You can specify a different provider and model by setting the `provider` and `model` parameters in the `Copilot` instance.
|
|
489
490
|
|
|
490
491
|
```javascript
|
|
491
|
-
const copilot = new Copilot(process.env.
|
|
492
|
-
provider: '
|
|
493
|
-
model: '
|
|
492
|
+
const copilot = new Copilot(process.env.ANTHROPIC_API_KEY, {
|
|
493
|
+
provider: 'anthropic',
|
|
494
|
+
model: 'claude-3-5-haiku',
|
|
494
495
|
});
|
|
495
496
|
```
|
|
496
497
|
|