lucgagan/auto-playwright

Problems parsing OpenAI Azure API response

Opened this issue · 4 comments

I'm trying to implement some proof-of-concept tests with Auto-Playwright and our company's generative AI chat (based on ChatGPT 3.5), but I'm getting some wierd errors parsing the response.

model: ChatGPT3.5-turbo
api-version: 2024-02-01

When I invoke auto with a simple prompt like Click the "Click me" button, I'm getting a test error because the response does not have a function_call with "result".

Is the latest version of Auto really compatible with Open AI Azure API 2024-02-01?

Sample request:

role: 'user',   
content: 'This is your task: Click the "Click me" button\n' +     '\n' +     
'* When creating CSS selectors, ensure they are unique and specific enough to select only one element, even if there are multiple elements of the same type (like multiple h1 elements).\n' +     
"* Avoid using generic tags like 'h1' alone. Instead, combine them with other attributes or structural relationships to form a unique selector.\n" +     
'* You must not derive data from the page if you are able to do so by using one of the provided functions, e.g. locator_evaluate.\n' +     '\n' +     
'Webpage snapshot:\n' +     
'\n' +     '\n' +     '\n' +     '     Testing \n' +     '    <h1>Hello, Rayrun!</h1>\n' +     '    <form id="search">\n' +     '       Search \n' +     '      <input type="text" name="query" data-testid="search-input" />\n' +     '    </form>\n' +     '    <div id="click-counter">\n' +     '      <p>Click count: <span id="current-count" data-testid="current-count">0</span></p>\n' +     '      <button id="click-button">Click me</button>\n' +     '      \n' +     '    </div>\n' +     '  \n' +     '\n' +     '\n' +     '\n' +     '\n' +     '\n' +     '\n'}

Sample response:

message {   
content: 'To click the button with ID "click-button", you can use the following code:\n' +     
'\n' +     
'```javascript\n' +     'const { locateElement, locator_click } = require("@qawolf/web");\n' +     '\n' +     '// Locate the button element using its ID\n' +     'const buttonElement = await locateElement({ cssSelector: "#click-button" });\n' +     '\n' +     '// Click on the button element\n' +     'await locator_click({ elementId: buttonElement });\n' +     
'```\n' +     
'\n' +     
'This code uses the `locateElement` function to find the button element on the webpage using its ID, and then uses the `locator_click` function to click on the button.',   role: 'assistant'}

⚠ Notice the javascript block instead of the function_call that the code expects.

Has anyone else faced this issue?

Sorry, I am not familiar with Azure API capabilities. It def works with OpenAI. Someone else will need to take to answer this one.

So, this project is not following the implementation from here?
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

The endpoint that I'm trying to use in Auto-Playwright is something like this:
https://<my-resource>.openai.azure.com/openai/deployments/<my-deployment>/chat/completions?api-version=2024-02-01

This is exactly the type of URL that you have on the ReadMe file 🤔

@roberto-mardeni might be a better person to ask, as he contributed the PR that added that logic.

#29

Looks like an encoding issue, will take a look in the coming weeks