permalink | editLink | sidebar | title |
---|---|---|---|
/helpers/OpenAI |
false |
auto |
OpenAI |
Extends Helper
OpenAI Helper for CodeceptJS.
This helper class provides integration with the OpenAI 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. This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDrvier to ensure the HTML context is available.
This helper should be configured in codecept.json or codecept.conf.js
chunkSize
: - The maximum number of characters to send to the OpenAI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
config
Send a general request to ChatGPT and return response.
prompt
string
Returns Promise<string> A Promise that resolves to the generated response from the GPT model.
Asks the OpenAI GPT language model a question based on the provided prompt within the context of the current page's HTML.
I.askGptOnPage('what does this page do?');
prompt
string The question or prompt to ask the GPT model.
Returns Promise<string> A Promise that resolves to the generated responses from the GPT model, joined by newlines.
Asks the OpenAI GPT-3.5 language model a question based on the provided prompt within the context of a specific HTML fragment on the current page.
I.askGptOnPageFragment('describe features of this screen', '.screen');
prompt
string The question or prompt to ask the GPT-3.5 model.locator
string The locator or selector used to identify the HTML fragment on the page.
Returns Promise<string> A Promise that resolves to the generated response from the GPT model.