What are you trying to achieve?
I want to use the I.askGptOnPage() or I.askGptOnPageFragment() function to get a response based on the html code passed to the gpt endpoint.
What do you get instead?
No usable response since the html code was not sent properly:
[{role: 'user',content: 'Is the text "The world’s leading AI-powered developer platform" displayed on the page?'},{role: 'user',content: 'Within this HTML: [object Promise]'}]
npx codeceptjs run --verbose --ai
***************************************
nodeInfo: 22.7.0
osInfo: macOS 15.1
cpuInfo: (8) x64 Apple M1
chromeInfo: 128.0.6613.84
edgeInfo: Not Found
firefoxInfo: undefined
safariInfo: 18.0
If you need more detailed info, just run this: npx codeceptjs info
***************************************
CodeceptJS v3.6.5 #StandWithUkraine
Using test root "/Users/tom/workspaces/WebstormProjects/test"
Helpers: Playwright, AI
Plugins: screenshotOnFail, tryTo, retryFailedStep, retryTo, eachElement
askgpt --
[1] Starting recording promises
Timeouts: › [Session] Starting singleton browser session
test askGptOnPage
I ask gpt on page "Is the text "The world’s leading AI-powered developer platform" displayed on the page?"
⠋ Processing AI request...[
{
role: 'user',
content: 'Is the text "The world’s leading AI-powered developer platform" displayed on the page?'
},
{ role: 'user', content: 'Within this HTML: [object Promise]' }
]
(node:71080) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
It looks like you've pasted an object reference or the text "[object Promise]" instead of the actual HTML code.To determine if the text "The world’s leading AI-powered developer platform" is displayed on a web page, you need to check the HTML content of that web page.Please provide the actual HTML code or a relevant portion of it so I can help you check if that specific text is present. ✔ OK in 1919ms OK | 1 passed // 3sAI assistant took 2s and used ~1K input tokens. Tokens limit: 10KFeature('askgpt');Scenario('test askGptOnPage',({ I })=>{I.askGptOnPage('Is the text "The world’s leading AI-powered developer platform" displayed on the page?');});Details
- CodeceptJS version: 3.6.5
- NodeJS Version: 22.7.0
- Operating System: macOS 15.1
- @playwright/test: 1.46.1
- Configuration file:
require('dotenv').config();const{ setHeadlessWhen, setCommonPlugins }=require('@codeceptjs/configure');// turn on headless mode when running with HEADLESS=true environment variable// export HEADLESS=true && npx codeceptjs runsetHeadlessWhen(process.env.HEADLESS);// enable all common plugins https://github.com/codeceptjs/configure#setcommonpluginssetCommonPlugins();/** @type {CodeceptJS.MainConfig} */exports.config={tests: './*_test.js',output: './output',helpers: {Playwright: {browser: 'chromium',url: 'https://www.github.com',show: true},AI: {}},include: {I: './steps_file.js'},name: 'test',ai: {maxTokens: 10000,request: async(messages)=>{const{ AzureOpenAI }=require("openai");constdeployment=process.env.AZURE_DEPLOYMENT_ID;constendpoint=process.env.AI_API_ENDPOINTconstapiKey=process.env.AZURE_API_KEY;constapiVersion="2024-07-01-preview";constoptions={ apiKey, endpoint, apiVersion, deployment }constclient=newAzureOpenAI(options);console.log(messages);const{ choices }=awaitclient.chat.completions.create({
messages,model: '',max_tokens: 100});returnchoices[0]?.message?.content;}}}
What are you trying to achieve?
I want to use the
I.askGptOnPage()orI.askGptOnPageFragment()function to get a response based on the html code passed to the gpt endpoint.What do you get instead?
No usable response since the html code was not sent properly:
Details