Skip to content

Commit 56a54c1

Browse files
authored
Fixed ChatGPT docs
1 parent 606733a commit 56a54c1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/ai.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CodeceptJS AI can do the following:
2828

2929
![](/img/fill_form.gif)
3030

31-
### How it works
31+
## How it works
3232

3333
As we can't send a browser window with ChatGPT we are not be able to fully share the context. But we can chare HTML of the current page, which is quite enough to analyze and identify if a page contains an element which can be used in a test.
3434

@@ -40,7 +40,7 @@ Even though, the HTML is still quite big and may exceed the token limit. So we r
4040
4141

4242

43-
### Set up AI Provider
43+
## Set up AI Provider
4444

4545
To enable AI features in CodeceptJS you should pick an AI provider and add `ai` section to `codecept.conf` file. This section should contain `request` function which will take a prompt from CodeceptJS, send it to AI provider and return a result.
4646

@@ -85,12 +85,13 @@ ai: {
8585
request: async (messages) => {
8686
const OpenAI = require('openai');
8787
const openai = new OpenAI({ apiKey: process.env['OPENAI_API_KEY'] })
88-
const response = await openai.chat.completions.create({
88+
89+
const completion = await openai.chat.completions.create({
8990
model: 'gpt-3.5-turbo-0125',
9091
messages,
9192
});
92-
// return only text content
93-
return response?.data?.choices[0]?.message?.content;
93+
94+
return completion?.choices[0]?.message?.content;
9495
}
9596
}
9697
```

0 commit comments

Comments
 (0)