FlowFuse / node-red-function-gpt

A Node-RED node that adds "Ask ChatGPT" option to a duplicate of the built-in function node.
Apache License 2.0
29 stars 2 forks source link

Bump axios and openai #24

Closed dependabot[bot] closed 9 months ago

dependabot[bot] commented 10 months ago

Removes axios. It's no longer used after updating ancestor dependency openai. These dependencies need to be updated together.

Removes axios

Updates openai from 3.2.1 to 4.17.4

Release notes

Sourced from openai's releases.

v4.17.4

4.17.4 (2023-11-10)

Full Changelog: v4.17.3...v4.17.4

Chores

v4.17.3

4.17.3 (2023-11-09)

Full Changelog: v4.17.2...v4.17.3

v4.17.2

4.17.2 (2023-11-09)

Full Changelog: v4.17.1...v4.17.2

Chores

v4.17.1

4.17.1 (2023-11-09)

Full Changelog: v4.17.0...v4.17.1

Refactors

  • client: deprecate files.retrieveContent in favour of files.content (#474) (7c7bfc2)

v4.17.0

4.17.0 (2023-11-08)

Full Changelog: v4.16.2...v4.17.0

Features

Refactors

  • api: rename FunctionObject to FunctionDefinition (#470) (f3990c7)

v4.16.2

4.16.2 (2023-11-08)

Full Changelog: v4.16.1...v4.16.2

... (truncated)

Changelog

Sourced from openai's changelog.

4.17.4 (2023-11-10)

Full Changelog: v4.17.3...v4.17.4

Chores

4.17.3 (2023-11-09)

Full Changelog: v4.17.2...v4.17.3

4.17.2 (2023-11-09)

Full Changelog: v4.17.1...v4.17.2

Chores

4.17.1 (2023-11-09)

Full Changelog: v4.17.0...v4.17.1

Refactors

  • client: deprecate files.retrieveContent in favour of files.content (#474) (7c7bfc2)

4.17.0 (2023-11-08)

Full Changelog: v4.16.2...v4.17.0

Features

Refactors

  • api: rename FunctionObject to FunctionDefinition (#470) (f3990c7)

4.16.2 (2023-11-08)

Full Changelog: v4.16.1...v4.16.2

Bug Fixes

  • api: accidentally required params, add new models & other fixes (#463) (1cb403e)
  • api: update embedding response object type (#466) (53b7e25)
  • asssitant_deleted -> assistant_deleted (#452) (ef89bd7)

... (truncated)

Commits
  • 12de980 Merge pull request #483 from openai/release-please--branches--master--changes...
  • b8441a7 release: 4.17.4
  • 3013e8c chore(internal): update jest config (#482)
  • d2d0ce5 release: 4.17.3
  • d0e2c77 ci: fix deno version bump (#480)
  • 78ec255 Merge pull request #479 from openai/release-please--branches--master--changes...
  • 488d731 release: 4.17.2
  • 69913f3 chore(internal): bump deno version number (#478)
  • 03d1662 Merge pull request #475 from openai/release-please--branches--master--changes...
  • 0532117 release: 4.17.1
  • Additional commits viewable in compare view
Maintainer changes

This version was pushed to npm by dschnurr-openai, a new releaser for openai since your current version.


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/FlowFuse/node-red-function-gpt/network/alerts).
joepavitt commented 9 months ago

This has breaking changes in it - investigating the problems:

{
    code: "unknown_error"
    error: "unknown_error"
    message: "GPT Failure: 'unknown_error', TypeError: Cannot read properties of null (reading 'askGPT')"
    status: "TypeError: Cannot read properties of null (reading 'askGPT')"
}
joepavitt commented 9 months ago

Changes have been made in how OpenAI's client is configured: https://github.com/openai/openai-node/discussions/217

Updating our code to reflect these changes now

joepavitt commented 9 months ago

Summary of the required changes:

Intantiation

Note: import changes and no longer requiring Configuration() constructor

// Old
import { Configuration, OpenAIApi } from "openai";

const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

// New
import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY // This is also the default, can be omitted
});

Chat Completion

Note: difference in function call, as well as the response format no longer nesting inside .data

// Old
const chatCompletion = await openai.createChatCompletion({
  model: "gpt-3.5-turbo",
  messages: [{role: "user", content: "Hello world"}],
});
console.log(chatCompletion.data.choices[0].message);

// New
const chatCompletion = await openai.chat.completions.create({
  model: "gpt-3.5-turbo",
  messages: [{"role": "user", "content": "Hello!"}],
});
console.log(chatCompletion.choices[0].message);