From 5e0a05fd269526436e353610160780db7f248dce Mon Sep 17 00:00:00 2001 From: Nick Heiner Date: Mon, 17 Jul 2023 10:30:31 -0400 Subject: [PATCH] Use `openai-edge` instead of `@nick.heiner/openai-edge` (#192) We were using a fork of `openai-edge` to work around this issue: https://github.com/dan-kwiat/openai-edge/issues/6. However, that issue is now resolved. --- packages/ai-jsx/package.json | 4 +-- packages/ai-jsx/src/lib/openai.tsx | 14 +++------ packages/create-react-app-demo/package.json | 2 +- packages/docs/docs/changelog.md | 7 ++++- packages/examples/package.json | 2 +- packages/nextjs-demo/package.json | 2 +- packages/nextjs-experimental/package.json | 2 +- packages/sandboxes/hello-world/package.json | 2 +- packages/tutorial-nextjs/package.json | 4 +-- packages/tutorial/package.json | 2 +- yarn.lock | 34 ++++++++++----------- 11 files changed, 38 insertions(+), 37 deletions(-) diff --git a/packages/ai-jsx/package.json b/packages/ai-jsx/package.json index 830658c02..45a36db7f 100644 --- a/packages/ai-jsx/package.json +++ b/packages/ai-jsx/package.json @@ -4,7 +4,7 @@ "repository": "fixie-ai/ai-jsx", "bugs": "https://github.com/fixie-ai/ai-jsx/issues", "homepage": "https://ai-jsx.com", - "version": "0.5.10", + "version": "0.5.11", "volta": { "extends": "../../package.json" }, @@ -302,7 +302,6 @@ }, "dependencies": { "@anthropic-ai/sdk": "^0.5.0", - "@nick.heiner/openai-edge": "1.0.1-7", "@nick.heiner/wandb-fork": "^0.5.2-5", "axios": "^1.4.0", "cli-highlight": "^2.1.11", @@ -314,6 +313,7 @@ "lodash": "^4.17.21", "ml-distance": "^4.0.1", "openai": "^3.3.0", + "openai-edge": "^1.2.0", "pino": "^8.14.1", "server-only": "^0.0.1", "untruncate-json": "^0.0.1", diff --git a/packages/ai-jsx/src/lib/openai.tsx b/packages/ai-jsx/src/lib/openai.tsx index ed155881f..58268c03b 100644 --- a/packages/ai-jsx/src/lib/openai.tsx +++ b/packages/ai-jsx/src/lib/openai.tsx @@ -16,18 +16,18 @@ import { FunctionResponse, } from '../core/completion.js'; import { Image, ImageGenPropsWithChildren } from '../core/image-gen.js'; -// openai-edge hasn't updated its types to support the new function types yet, -// so we'll import the types from openai until it does. -import { ChatCompletionFunctions, ChatCompletionResponseMessage, ChatCompletionRequestMessage } from 'openai'; import { Configuration, CreateChatCompletionResponse, CreateCompletionResponse, OpenAIApi, + ChatCompletionFunctions, + ChatCompletionResponseMessage, + ChatCompletionRequestMessage, CreateImageRequestSizeEnum, CreateImageRequestResponseFormatEnum, ResponseTypes, -} from '@nick.heiner/openai-edge'; +} from 'openai-edge'; import * as AI from '../index.js'; import { PropsOfComponent, Node } from '../index.js'; import GPT3Tokenizer from 'gpt3-tokenizer'; @@ -385,11 +385,7 @@ export async function* OpenAIChatModel( }; logger.debug({ chatCompletionRequest }, 'Calling createChatCompletion'); - const chatResponse = await openai.createChatCompletion( - // We can remove this once openai-edge updates to reflect the new chat function types. - // @ts-expect-error - chatCompletionRequest - ); + const chatResponse = await openai.createChatCompletion(chatCompletionRequest); await checkOpenAIResponse(chatResponse, logger, 'createChatCompletion'); diff --git a/packages/create-react-app-demo/package.json b/packages/create-react-app-demo/package.json index 58c1d65c3..3cd55f07a 100644 --- a/packages/create-react-app-demo/package.json +++ b/packages/create-react-app-demo/package.json @@ -13,7 +13,7 @@ "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "@types/http-proxy": "^1.17.11", - "ai-jsx": "0.5.10", + "ai-jsx": "workspace:*", "babel-jest": "^27.4.2", "babel-loader": "^8.2.3", "babel-plugin-named-asset-import": "^0.3.8", diff --git a/packages/docs/docs/changelog.md b/packages/docs/docs/changelog.md index d61012dbb..4a8a3c020 100644 --- a/packages/docs/docs/changelog.md +++ b/packages/docs/docs/changelog.md @@ -1,6 +1,11 @@ # Changelog -## 0.5.10 +## 0.5.11 + +- Make JIT UI stream rather than appear all at once. +- Use `openai-edge` instead of `@nick.heiner/openai-edge` + +## [0.5.10](https://github.com/fixie-ai/ai-jsx/commit/e2735fde8c33e3019a074c29824206d9725eed64) - Update logging to log the output of every component. - Update [`UseTools`](./api/modules/batteries_use_tools.md) to use [OpenAI function calls](https://openai.com/blog/function-calling-and-other-api-updates) if you're using a model that supports them. diff --git a/packages/examples/package.json b/packages/examples/package.json index 11cddbb40..9126ed6f2 100644 --- a/packages/examples/package.json +++ b/packages/examples/package.json @@ -60,7 +60,7 @@ "@opentelemetry/sdk-metrics": "^1.13.0", "@opentelemetry/sdk-node": "^0.39.1", "@wandb/sdk": "^0.5.1", - "ai-jsx": "0.5.10", + "ai-jsx": "workspace:*", "axios": "^1.4.0", "csv-stringify": "^6.4.0", "globby": "^13.1.4", diff --git a/packages/nextjs-demo/package.json b/packages/nextjs-demo/package.json index 0bc69d54e..86191ed09 100644 --- a/packages/nextjs-demo/package.json +++ b/packages/nextjs-demo/package.json @@ -19,7 +19,7 @@ "@types/react": "18.2.8", "@types/react-dom": "18.2.4", "ai": "^2.1.8", - "ai-jsx": "0.5.10", + "ai-jsx": "workspace:*", "autoprefixer": "10.4.14", "classnames": "^2.3.2", "eslint": "8.42.0", diff --git a/packages/nextjs-experimental/package.json b/packages/nextjs-experimental/package.json index f4e929963..dd503a77e 100644 --- a/packages/nextjs-experimental/package.json +++ b/packages/nextjs-experimental/package.json @@ -15,7 +15,7 @@ "@types/node": "20.2.5", "@types/react": "18.2.8", "@types/react-dom": "18.2.4", - "ai-jsx": "0.5.10", + "ai-jsx": "workspace:*", "autoprefixer": "10.4.14", "classnames": "^2.3.2", "eslint": "8.42.0", diff --git a/packages/sandboxes/hello-world/package.json b/packages/sandboxes/hello-world/package.json index b2f7f49bd..909bae76c 100644 --- a/packages/sandboxes/hello-world/package.json +++ b/packages/sandboxes/hello-world/package.json @@ -10,7 +10,7 @@ "start": "npm run test && tsx index.tsx" }, "dependencies": { - "ai-jsx": "0.5.10", + "ai-jsx": "workspace:*", "pino": "^8.14.1", "pino-pretty": "^10.0.0" }, diff --git a/packages/tutorial-nextjs/package.json b/packages/tutorial-nextjs/package.json index 106d7d9b6..a0aa57953 100644 --- a/packages/tutorial-nextjs/package.json +++ b/packages/tutorial-nextjs/package.json @@ -9,15 +9,15 @@ "lint": "next lint" }, "dependencies": { - "@nick.heiner/openai-edge": "1.0.1-7", "@types/node": "20.3.1", "@types/react": "18.2.12", "@types/react-dom": "18.2.5", "ai": "^2.1.3", - "ai-jsx": "0.5.10", + "ai-jsx": "workspace:*", "eslint": "8.43.0", "eslint-config-next": "13.4.6", "next": "13.4.6", + "openai-edge": "1.2.0", "react": "18.2.0", "react-dom": "18.2.0", "typescript": "5.1.3" diff --git a/packages/tutorial/package.json b/packages/tutorial/package.json index 4fa76adb4..1ca6443d1 100644 --- a/packages/tutorial/package.json +++ b/packages/tutorial/package.json @@ -36,7 +36,7 @@ }, "dependencies": { "@pinecone-database/pinecone": "^0.1.6", - "ai-jsx": "0.5.10", + "ai-jsx": "workspace:*", "asciichart": "^1.5.25", "axios": "^1.4.0", "enquirer": "^2.3.6", diff --git a/yarn.lock b/yarn.lock index af79c0b39..3025548ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3946,13 +3946,6 @@ __metadata: languageName: node linkType: hard -"@nick.heiner/openai-edge@npm:1.0.1-7": - version: 1.0.1-7 - resolution: "@nick.heiner/openai-edge@npm:1.0.1-7" - checksum: f53e39082901018113353c1c4b8ecddc1465a4355b7c8721a309d9243d58310c78c86af11c30c1ae2a767b6636f2e02cdc78d00144fefa81d7818916253637a1 - languageName: node - linkType: hard - "@nick.heiner/wandb-fork@npm:^0.5.2-5": version: 0.5.2-5 resolution: "@nick.heiner/wandb-fork@npm:0.5.2-5" @@ -7530,7 +7523,7 @@ __metadata: dependencies: "@tsconfig/node18": ^2.0.1 "@types/node": ^20.3.1 - ai-jsx: 0.5.10 + ai-jsx: "workspace:*" pino: ^8.14.1 pino-pretty: ^10.0.0 tsx: ^3.12.7 @@ -7553,13 +7546,12 @@ __metadata: languageName: unknown linkType: soft -"ai-jsx@0.5.10, ai-jsx@workspace:packages/ai-jsx": +"ai-jsx@workspace:*, ai-jsx@workspace:packages/ai-jsx": version: 0.0.0-use.local resolution: "ai-jsx@workspace:packages/ai-jsx" dependencies: "@anthropic-ai/sdk": ^0.5.0 "@jest/globals": ^29.5.0 - "@nick.heiner/openai-edge": 1.0.1-7 "@nick.heiner/wandb-fork": ^0.5.2-5 "@tsconfig/node16": ^1.0.4 "@tsconfig/node18": ^2.0.1 @@ -7591,6 +7583,7 @@ __metadata: ml-distance: ^4.0.1 node-fetch: ^3.3.1 openai: ^3.3.0 + openai-edge: ^1.2.0 pino: ^8.14.1 pino-pretty: ^10.0.0 react: ^18.2.0 @@ -9649,7 +9642,7 @@ __metadata: "@types/react-dom": ^18.2.5 "@typescript-eslint/eslint-plugin": ^5.59.11 "@typescript-eslint/parser": ^5.59.11 - ai-jsx: 0.5.10 + ai-jsx: "workspace:*" babel-jest: ^27.4.2 babel-loader: ^8.2.3 babel-plugin-named-asset-import: ^0.3.8 @@ -12180,7 +12173,7 @@ __metadata: "@typescript-eslint/eslint-plugin": ^5.60.0 "@typescript-eslint/parser": ^5.60.0 "@wandb/sdk": ^0.5.1 - ai-jsx: 0.5.10 + ai-jsx: "workspace:*" axios: ^1.4.0 csv-stringify: ^6.4.0 eslint: ^8.40.0 @@ -17505,7 +17498,7 @@ __metadata: "@typescript-eslint/eslint-plugin": ^5.59.9 "@typescript-eslint/parser": ^5.59.9 ai: ^2.1.8 - ai-jsx: 0.5.10 + ai-jsx: "workspace:*" autoprefixer: 10.4.14 classnames: ^2.3.2 eslint: 8.42.0 @@ -17535,7 +17528,7 @@ __metadata: "@types/react-dom": 18.2.4 "@typescript-eslint/eslint-plugin": ^5.59.9 "@typescript-eslint/parser": ^5.59.9 - ai-jsx: 0.5.10 + ai-jsx: "workspace:*" autoprefixer: 10.4.14 classnames: ^2.3.2 eslint: 8.42.0 @@ -17945,6 +17938,13 @@ __metadata: languageName: node linkType: hard +"openai-edge@npm:1.2.0, openai-edge@npm:^1.2.0": + version: 1.2.0 + resolution: "openai-edge@npm:1.2.0" + checksum: 5fa7962527b4001fe3beb29cb983014b1f7a1051199b4b1df60dc5638b8d31d9f8f8924b7795b997f609cc15cd19f93a64d5e55cd99e5d52a9970acd267e97c9 + languageName: node + linkType: hard + "openai@npm:^3.2.0, openai@npm:^3.3.0": version: 3.3.0 resolution: "openai@npm:3.3.0" @@ -22716,18 +22716,18 @@ __metadata: "@babel/core": ^7.22.5 "@babel/plugin-transform-react-jsx": ^7.22.5 "@next/eslint-plugin-next": ^13.4.6 - "@nick.heiner/openai-edge": 1.0.1-7 "@types/node": 20.3.1 "@types/react": 18.2.12 "@types/react-dom": 18.2.5 "@typescript-eslint/eslint-plugin": ^5.59.9 "@typescript-eslint/parser": ^5.59.9 ai: ^2.1.3 - ai-jsx: 0.5.10 + ai-jsx: "workspace:*" eslint: 8.43.0 eslint-config-next: 13.4.6 eslint-config-nth: ^2.0.1 next: 13.4.6 + openai-edge: 1.2.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 @@ -22748,7 +22748,7 @@ __metadata: "@types/uuid": ^9.0.2 "@typescript-eslint/eslint-plugin": ^5.60.0 "@typescript-eslint/parser": ^5.60.0 - ai-jsx: 0.5.10 + ai-jsx: "workspace:*" asciichart: ^1.5.25 axios: ^1.4.0 enquirer: ^2.3.6