Skip to content

Commit

Permalink
Use openai-edge instead of @nick.heiner/openai-edge (#192)
Browse files Browse the repository at this point in the history
We were using a fork of `openai-edge` to work
around this issue: dan-kwiat/openai-edge#6.
However, that issue is now resolved.
  • Loading branch information
NickHeiner authored Jul 17, 2023
1 parent 5919534 commit 5e0a05f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 37 deletions.
4 changes: 2 additions & 2 deletions packages/ai-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 5 additions & 9 deletions packages/ai-jsx/src/lib/openai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion packages/create-react-app-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion packages/docs/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs-experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/sandboxes/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/tutorial-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

3 comments on commit 5e0a05f

@vercel
Copy link

@vercel vercel bot commented on 5e0a05f Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ai-jsx-docs – ./packages/docs

ai-jsx-docs-git-main-fixie-ai.vercel.app
ai-jsx-docs-fixie-ai.vercel.app
docs.ai-jsx.com
ai-jsx-docs.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 5e0a05f Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ai-jsx-nextjs-demo – ./packages/nextjs-demo

ai-jsx-nextjs-demo.vercel.app
ai-jsx-nextjs-demo-git-main-fixie-ai.vercel.app
ai-jsx-nextjs-demo-fixie-ai.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 5e0a05f Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ai-jsx-tutorial-nextjs – ./packages/tutorial-nextjs

ai-jsx-tutorial-nextjs-fixie-ai.vercel.app
ai-jsx-tutorial-nextjs.vercel.app
ai-jsx-tutorial-nextjs-git-main-fixie-ai.vercel.app

Please sign in to comment.