monacopilot 0.9.14 → 0.9.16

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.
Files changed (2) hide show
  1. package/README.md +169 -7
  2. package/package.json +1 -2
package/README.md CHANGED
@@ -1,17 +1,179 @@
1
+ ![Hero Image](https://i.postimg.cc/PrsQ1KLb/Frame-1.png)
2
+
1
3
  # Monacopilot
2
4
 
3
- [Monaco Editor](https://microsoft.github.io/monaco-editor/) with AI auto-completion, inspired by [GitHub Copilot](https://github.com/features/copilot/).
5
+ **Monacopilot** integrates AI auto-completion into the Monaco Editor, inspired by GitHub Copilot.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Examples](#examples)
10
+ - [Installation](#installation)
11
+ - [Usage](#usage)
12
+ - [Configuration Options](#configuration-options)
13
+ - [External Context](#external-context)
14
+ - [Changing the Provider and Model](#changing-the-provider-and-model)
15
+ - [Filename](#filename)
16
+ - [Completions for Specific Technologies](#completions-for-specific-technologies)
17
+ - [Cost Overview](#cost-overview)
18
+ - [FAQ](#faq)
19
+ - [Contributing](#contributing)
20
+
21
+ ## Demo
22
+
23
+ https://github.com/user-attachments/assets/4af4e24a-1b05-4bee-84aa-1521ad7098cd
24
+
25
+ ## Examples
26
+
27
+ Here are some examples of how to use Monacopilot in different project setups:
28
+
29
+ - [Next.js App Router](https://github.com/arshad-yaseen/monacopilot/tree/main/examples/nextjs/app-router)
30
+ - [Next.js Pages Router](https://github.com/arshad-yaseen/monacopilot/tree/main/examples/nextjs/pages-router)
31
+
32
+ ## Installation
33
+
34
+ To install Monacopilot, run:
35
+
36
+ ```bash
37
+ npm install monacopilot
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ #### Setting Up the API Key
43
+
44
+ Start by obtaining an API key from the [Groq console](https://console.groq.com/keys). Once you have your API key, define it as an environment variable in your project:
45
+
46
+ ```bash
47
+ # .env.local
48
+ GROQ_API_KEY=your-api-key
49
+ ```
50
+
51
+ #### API Handler
52
+
53
+ Set up an API handler to manage auto-completion requests. An example using Express.js:
54
+
55
+ ```javascript
56
+ const express = require('express');
57
+ const {Copilot} = require('monacopilot');
58
+
59
+ const app = express();
60
+ const port = process.env.PORT || 3000;
61
+ const copilot = new Copilot(process.env.GROQ_API_KEY);
62
+
63
+ app.use(express.json());
64
+
65
+ app.post('/copilot', async (req, res) => {
66
+ const completion = await copilot.complete(req.body);
67
+ res.status(200).json(completion);
68
+ });
69
+
70
+ app.listen(port);
71
+ ```
72
+
73
+ #### Register Copilot with the Monaco Editor
74
+
75
+ Next, register Copilot with the Monaco editor.
76
+
77
+ ```javascript
78
+ import * as monaco from 'monaco-editor';
79
+ import {registerCopilot} from 'monacopilot';
80
+
81
+ const editor = monaco.editor.create(document.getElementById('container'), {
82
+ language: 'javascript',
83
+ });
4
84
 
5
- ## Documentation
85
+ registerCopilot(monaco, editor, {
86
+ endpoint: 'https://api.example.com/copilot',
87
+ language: 'javascript',
88
+ });
89
+ ```
6
90
 
7
- [https://monacopilot.vercel.app/docs](https://monacopilot.vercel.app/docs)
91
+ ## Configuration Options
92
+
93
+ ### External Context
94
+
95
+ Enhance the accuracy and relevance of Copilot's completions by providing additional code context from your workspace.
96
+
97
+ ```javascript
98
+ registerCopilot(monaco, editor, {
99
+ // ...other options
100
+ externalContext: [
101
+ {
102
+ path: './utils.js',
103
+ content:
104
+ 'export const reverse = (str) => str.split("").reverse().join("")',
105
+ },
106
+ ],
107
+ });
108
+ ```
109
+
110
+ By providing external context, Copilot can offer more intelligent suggestions. For example, if you start typing `const isPalindrome = `, Copilot may suggest using the `reverse` function from `utils.js`.
111
+
112
+ ### Changing the Provider and Model
113
+
114
+ You can specify a different provider and model for completions by setting the `provider` and `model` parameters in the `Copilot` instance.
115
+
116
+ ```javascript
117
+ const copilot = new Copilot(process.env.OPENAI_API_KEY, {
118
+ provider: 'openai',
119
+ model: 'gpt-4o',
120
+ });
121
+ ```
122
+
123
+ The default provider is `groq` and the default model is `llama-3-70b`.
124
+
125
+ | Provider | Model | Description | Avg. Response Time |
126
+ | -------- | ----------- | ------------------------------------------------- | ------------------ |
127
+ | Groq | llama-3-70b | Fast and efficient, suitable for most tasks | <0.5s |
128
+ | OpenAI | gpt-4o-mini | Mini version of gpt-4o, cheaper | 1.5-3s |
129
+ | OpenAI | gpt-4o | Highly intelligent, ideal for complex completions | 1-2s |
130
+
131
+ ### Filename
132
+
133
+ Specify the name of the file being edited to receive more contextually relevant completions.
134
+
135
+ ```javascript
136
+ registerCopilot(monaco, editor, {
137
+ // ...other options
138
+ filename: 'utils.js', // e.g., "index.js", "utils/objects.js"
139
+ });
140
+ ```
141
+
142
+ Now, the completions will be more relevant to utilities.
143
+
144
+ ### Completions for Specific Technologies
145
+
146
+ Enable completions tailored to specific technologies by using the `technologies` option.
147
+
148
+ ```javascript
149
+ registerCopilot(monaco, editor, {
150
+ // ...other options
151
+ technologies: ['react', 'next.js', 'tailwindcss'],
152
+ });
153
+ ```
154
+
155
+ This configuration will provide completions relevant to React, Next.js, and Tailwind CSS.
156
+
157
+ ## Cost Overview
158
+
159
+ The cost of completions is very affordable. See the table below for an estimate of the costs you will need to pay for completions.
160
+
161
+ | Provider | Model | Avg. Cost per 1000 Code Completions |
162
+ | -------- | ----------- | ----------------------------------- |
163
+ | Groq | llama-3-70b | $0.939 |
164
+ | OpenAI | gpt-4o-mini | $0.821 |
165
+ | OpenAI | gpt-4o | $3.46 |
166
+
167
+ > **Note:** Currently, Groq does not implement billing, allowing free usage of their API. During this free period, you will experience minimal rate limiting and some latency in completions. You can opt for Groq's enterprise plan to benefit from increased rate limits and get quick completions without visible latency.
168
+
169
+ ## FAQ
170
+
171
+ ### Is AI Auto Completion Free?
172
+
173
+ You use your own Groq or OpenAI API key for AI auto-completion. The cost of completions is very affordable, and we implement various methods to minimize these costs as much as possible. Costs vary depending on the model you use; see this [cost overview](#cost-overview) for an idea of the cost.
8
174
 
9
175
  ## Contributing
10
176
 
11
177
  For guidelines on contributing, Please read the [contributing guide](https://github.com/arshad-yaseen/monacopilot/blob/main/CONTRIBUTING.md).
12
178
 
13
179
  We welcome contributions from the community to enhance Monacopilot's capabilities and make it even more powerful ❤️
14
-
15
- ## Security
16
-
17
- MonacoPilot does not store or use your code; it only provides AI completions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monacopilot",
3
- "version": "0.9.14",
3
+ "version": "0.9.16",
4
4
  "description": "AI auto-completion for Monaco Editor",
5
5
  "main": "./build/index.js",
6
6
  "module": "./build/index.mjs",
@@ -12,7 +12,6 @@
12
12
  "build": "tsup src/index.ts",
13
13
  "dev": "tsup src/index.ts --watch",
14
14
  "dev:test": "pnpm -C test dev",
15
- "dev:docs": "pnpm -C docs dev",
16
15
  "type-check": "tsc --noEmit",
17
16
  "lint": "eslint . --ext .ts,.tsx --fix",
18
17
  "lint:test": "pnpm -C test lint",