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
Copy file name to clipboardExpand all lines: docs/helpers/AI.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -14,13 +14,13 @@ title: AI
14
14
AI Helper for CodeceptJS.
15
15
16
16
This helper class provides integration with the AI GPT-3.5 or 4 language model for generating responses to questions or prompts within the context of web pages. It allows you to interact with the GPT-3.5 model to obtain intelligent responses based on HTML fragments or general prompts.
17
-
This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDrvier to ensure the HTML context is available.
17
+
This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDriver to ensure the HTML context is available.
18
18
19
19
Use it only in development mode. It is recommended to run it only inside pause() mode.
20
20
21
21
## Configuration
22
22
23
-
This helper should be configured in codecept.json or codecept.conf.js
23
+
This helper should be configured in codecept.conf.{js|ts}
24
24
25
25
-`chunkSize`: - The maximum number of characters to send to the AI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
* This helper class provides integration with the AI GPT-3.5 or 4 language model for generating responses to questions or prompts within the context of web pages. It allows you to interact with the GPT-3.5 model to obtain intelligent responses based on HTML fragments or general prompts.
17
-
* This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDrvier to ensure the HTML context is available.
21
+
* This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDriver to ensure the HTML context is available.
18
22
*
19
23
* Use it only in development mode. It is recommended to run it only inside pause() mode.
20
24
*
21
25
* ## Configuration
22
26
*
23
-
* This helper should be configured in codecept.json or codecept.conf.js
27
+
* This helper should be configured in codecept.conf.{js|ts}
24
28
*
25
29
* * `chunkSize`: (optional, default: 80000) - The maximum number of characters to send to the AI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
26
30
*/
@@ -33,6 +37,7 @@ class AI extends Helper {
33
37
chunkSize: 80000,
34
38
}
35
39
this.options={ ...this.options, ...config}
40
+
this.aiAssistant.enable(this.config)
36
41
}
37
42
38
43
_beforeSuite(){
@@ -68,8 +73,8 @@ class AI extends Helper {
68
73
69
74
for(constchunkofhtmlChunks){
70
75
constmessages=[
71
-
{role: 'user',content: prompt},
72
-
{role: 'user',content: `Within this HTML: ${minifyHtml(chunk)}`},
76
+
{role: gtpRole.user,content: prompt},
77
+
{role: gtpRole.user,content: `Within this HTML: ${minifyHtml(chunk)}`},
73
78
]
74
79
75
80
if(htmlChunks.length>1)
@@ -104,8 +109,8 @@ class AI extends Helper {
104
109
consthtml=awaitthis.helper.grabHTMLFrom(locator)
105
110
106
111
constmessages=[
107
-
{role: 'user',content: prompt},
108
-
{role: 'user',content: `Within this HTML: ${minifyHtml(html)}`},
112
+
{role: gtpRole.user,content: prompt},
113
+
{role: gtpRole.user,content: `Within this HTML: ${minifyHtml(html)}`},
0 commit comments