You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix(api): fix issue loading Azure OpenAI configuration
Because of asynchronous operations, loading *_cmd options from
configuration was not working properly. It was only working using the
environment variables.
Also add a missing options to set API type (api_type_cmd) from vim
config files instead of having to set a environment variable.
* style: fix linter findings and update README documentation
- Format README.md file to comply with regular MD guidelines (linter findings)
- Add information about new configuration options to configure Azure
deployment programmatically.
* style(api): fix stylua style findings
---------
Co-authored-by: Alejandro Claro <alejandro.claro@smartmatic.com>
-**Interactive Q&A**: Engage in interactive question-and-answer sessions with the powerful gpt model (ChatGPT) using an intuitive interface.
13
-
-**Persona-based Conversations**: Explore various perspectives and have conversations with different personas by selecting prompts from Awesome ChatGPT Prompts.
14
-
-**Code Editing Assistance**: Enhance your coding experience with an interactive editing window powered by the gpt model, offering instructions tailored for coding tasks.
15
-
-**Code Completion**: Enjoy the convenience of code completion similar to GitHub Copilot, leveraging the capabilities of the gpt model to suggest code snippets and completions based on context and programming patterns.
16
-
-**Customizable Actions**: Execute a range of actions utilizing the gpt model, such as grammar correction, translation, keyword generation, docstring creation, test addition, code optimization, summarization, bug fixing, code explanation, Roxygen editing, and code readability analysis. Additionally, you can define your own custom actions using a JSON file.
17
13
18
-
For a comprehensive understanding of the extension's functionality, you can watch a plugin showcase [video](https://www.youtube.com/watch?v=7k0KZsheLP4)
14
+
-**Interactive Q&A**: Engage in interactive question-and-answer sessions with
15
+
the powerful gpt model (ChatGPT) using an intuitive interface.
16
+
17
+
-**Persona-based Conversations**: Explore various perspectives and have
18
+
conversations with different personas by selecting prompts from Awesome ChatGPT
19
+
Prompts.
20
+
21
+
-**Code Editing Assistance**: Enhance your coding experience with an interactive
22
+
editing window powered by the gpt model, offering instructions tailored for
23
+
coding tasks.
24
+
25
+
-**Code Completion**: Enjoy the convenience of code completion similar to GitHub
26
+
Copilot, leveraging the capabilities of the gpt model to suggest code snippets
27
+
and completions based on context and programming patterns.
28
+
29
+
-**Customizable Actions**: Execute a range of actions utilizing the gpt model,
30
+
such as grammar correction, translation, keyword generation, docstring creation,
31
+
test addition, code optimization, summarization, bug fixing, code explanation,
32
+
Roxygen editing, and code readability analysis. Additionally, you can define
33
+
your own custom actions using a JSON file.
34
+
35
+
For a comprehensive understanding of the extension's functionality, you can watch
36
+
a plugin showcase [video](https://www.youtube.com/watch?v=7k0KZsheLP4)
19
37
20
38
## Installation
21
39
22
40
- Make sure you have `curl` installed.
41
+
23
42
- Get an API key from OpenAI, which you can [obtain here](https://beta.openai.com/account/api-keys). (NOTE: a ChatGPT Plus subscription doesn't currently include the required API credits. You'll have to buy API credits [separately](https://platform.openai.com/account/billing/overview).)
24
43
25
44
The OpenAI API key can be provided in one of the following two ways:
26
45
27
46
1. In the configuration option `api_key_cmd`, provide the path and arguments to
28
47
an executable that returns the API key via stdout.
48
+
29
49
1. Setting it via an environment variable called `$OPENAI_API_KEY`.
30
50
31
51
Custom OpenAI API host with the configuration option `api_host_cmd` or
@@ -34,6 +54,7 @@ OpenAI directly
34
54
35
55
Custom cURL parameters can be passed using the configuration option `extra_curl_params`.
36
56
It can be useful if you need to include additional headers for requests:
57
+
37
58
```lua
38
59
{
39
60
...,
@@ -44,12 +65,45 @@ It can be useful if you need to include additional headers for requests:
44
65
}
45
66
```
46
67
47
-
For Azure deployments, you also need to set environment variables
48
-
`$OPENAI_API_TYPE` to `azure`, `$OPENAI_API_BASE` to your own resource URL,
49
-
e.g. `https://{your-resource-name}.openai.azure.com`, and `$OPENAI_API_AZURE_ENGINE`
50
-
to your deployment ID. Optionally, if you need a different API version,
51
-
set `$OPENAI_API_AZURE_VERSION` as well. Note that edit models have been deprecated
52
-
so they might not work.
68
+
For Azure deployments, you need to specify the URL base, the engine, and the API
69
+
type. You can accomplish this in one of two ways:
70
+
71
+
1. Use the configuration options `api_type_cmd`, `azure_api_base`,
72
+
`azure_api_engine_cmd`, and `azure_api_version_cmd`. Each of these should be
73
+
an executable command that returns the corresponding value.
Note that the `api_key_cmd` arguments are split by whitespace. If you need whitespace inside an argument (for example to reference a path with spaces), you can wrap it in a separate script.
179
+
Note that the `api_key_cmd` arguments are split by whitespace. If you need
180
+
whitespace inside an argument (for example to reference a path with spaces),
181
+
you can wrap it in a separate script.
123
182
124
183
## Usage
125
184
126
185
Plugin exposes following commands:
127
186
128
-
#### `ChatGPT`
187
+
### `ChatGPT`
188
+
129
189
`ChatGPT` command which opens interactive window using the `gpt-3.5-turbo`
130
190
model.
131
191
(also known as `ChatGPT`)
132
192
133
-
#### `ChatGPTActAs`
134
-
`ChatGPTActAs` command which opens a prompt selection from [Awesome ChatGPT Prompts](https://github.com/f/awesome-chatgpt-prompts) to be used with the `gpt-3.5-turbo` model.
193
+
### `ChatGPTActAs`
194
+
195
+
`ChatGPTActAs` command which opens a prompt selection from
`ChatGPTEditWithInstructions` command which opens interactive window to edit selected text or whole window using the `code-davinci-edit-001` model (GPT 3.5 fine-tuned for coding).
201
+
### `ChatGPTEditWithInstructions`
202
+
203
+
`ChatGPTEditWithInstructions` command which opens interactive window to edit
204
+
selected text or whole window using the `code-davinci-edit-001` model (GPT 3.5
205
+
fine-tuned for coding).
140
206
141
207
You can map it using the Lua API, e.g. using `which-key.nvim`:
208
+
142
209
```lua
143
210
localchatgpt=require("chatgpt")
144
211
wk.register({
@@ -163,7 +230,10 @@ wk.register({
163
230
164
231
#### `ChatGPTRun`
165
232
166
-
`ChatGPTRun [action]` command which runs specific actions -- see [`actions.json`](./lua/chatgpt/flows/actions/actions.json) file for a detailed list. Available actions are:
233
+
`ChatGPTRun [action]` command which runs specific actions -- See
234
+
[`actions.json`](./lua/chatgpt/flows/actions/actions.json) file for a detailed
235
+
list. Available actions are:
236
+
167
237
1.`grammar_correction`
168
238
2.`translate`
169
239
3.`keywords`
@@ -181,6 +251,7 @@ All the above actions are using `gpt-3.5-turbo` model.
181
251
It is possible to define custom actions with a JSON file. See [`actions.json`](./lua/chatgpt/flows/actions/actions.json) for an example. The path of custom actions can be set in the config (see `actions_paths` field in the config example above).
182
252
183
253
An example of custom action may look like this: (`#` marks comments)
254
+
184
255
```python
185
256
{
186
257
"action_name": {
@@ -205,6 +276,7 @@ An example of custom action may look like this: (`#` marks comments)
205
276
}
206
277
}
207
278
```
279
+
208
280
The `edit` strategy consists in showing the output side by side with the input and
209
281
available for further editing requests.
210
282
For now, `edit` strategy is implemented for `chat` type only.
@@ -214,8 +286,10 @@ The `display` strategy shows the output in a float window.
214
286
`append` and `replace` modify the text directly in the buffer.
215
287
216
288
### Interactive popup
289
+
217
290
When using `ChatGPT` and `ChatGPTEditWithInstructions`, the following
218
291
keybindings are available:
292
+
219
293
-`<C-Enter>`[Both] to submit.
220
294
-`<C-y>`[Both] to copy/yank last answer.
221
295
-`<C-o>`[Both] Toggle settings window.
@@ -239,7 +313,9 @@ When the setting window is opened (with `<C-o>`), settings can be modified by
239
313
pressing `Enter` on the related config. Settings are saved across sections
240
314
241
315
### Whichkey plugin mappings
242
-
Add these to your [whichkey](https://github.com/folke/which-key.nvim) plugin mappings for convenient binds
316
+
317
+
Add these to your [whichkey](https://github.com/folke/which-key.nvim) plugin
0 commit comments