Skip to content

Commit

Permalink
Add new OpenAI models (#542)
Browse files Browse the repository at this point in the history
And document a script to generate the list of chat models.
  • Loading branch information
petersalas committed Apr 10, 2024
1 parent feecd64 commit 7d7ca59
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion 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.30.0",
"version": "0.30.1",
"volta": {
"extends": "../../package.json"
},
Expand Down
37 changes: 17 additions & 20 deletions packages/ai-jsx/src/lib/openai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,26 @@ import { getEncoding } from 'js-tiktoken';
import _ from 'lodash';

// https://platform.openai.com/docs/models/model-endpoint-compatibility
export type ValidCompletionModel =
| 'text-davinci-003'
| 'text-davinci-002'
| 'text-curie-001'
| 'text-babbage-001'
| 'text-ada-001'
| 'gpt-3.5-turbo-instruct';
export type ValidCompletionModel = 'davinci-002' | 'babbage-002' | 'gpt-3.5-turbo-instruct';

// curl 'https://api.openai.com/v1/models' -H "Authorization: Bearer $OPENAI_API_KEY" | jq -r '.data[] | .id' | sort | awk '/^gpt/ && !/vision/ && !/instruct/ { print "| \"" $0 "\"" }'
export type ValidChatModel =
| 'gpt-4'
| 'gpt-4-0314' // discontinue on 06/13/2024
| 'gpt-4-0613'
| 'gpt-4-32k'
| 'gpt-4-32k-0314' // discontinue on 06/13/2024
| 'gpt-4-32k-0613'
| 'gpt-4-1106-preview'
| 'gpt-4-0125-preview'
| 'gpt-4-turbo-preview'
| 'gpt-3.5-turbo'
| 'gpt-3.5-turbo-0301' // discontinue on 06/13/2024
| 'gpt-3.5-turbo-0125'
| 'gpt-3.5-turbo-0301'
| 'gpt-3.5-turbo-0613'
| 'gpt-3.5-turbo-1106'
| 'gpt-3.5-turbo-16k'
| 'gpt-3.5-turbo-16k-0613'
| 'gpt-3.5-turbo-1106';
| 'gpt-4'
| 'gpt-4-0125-preview'
| 'gpt-4-0613'
| 'gpt-4-1106-preview'
| 'gpt-4-32k'
| 'gpt-4-32k-0613'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-turbo-preview';

/**
* An OpenAI client that talks to the Azure OpenAI service.
Expand Down Expand Up @@ -224,16 +220,16 @@ function tokenLimitForChatModel(

switch (model) {
case 'gpt-4':
case 'gpt-4-0314':
case 'gpt-4-0613':
return 8192 - functionEstimate - TOKENS_CONSUMED_BY_REPLY_PREFIX;
case 'gpt-4-32k':
case 'gpt-4-32k-0314':
case 'gpt-4-32k-0613':
return 32768 - functionEstimate - TOKENS_CONSUMED_BY_REPLY_PREFIX;
case 'gpt-4-1106-preview':
case 'gpt-4-0125-preview':
case 'gpt-4-turbo-preview':
case 'gpt-4-turbo-2024-04-09':
case 'gpt-4-turbo':
return 128_000 - functionEstimate - TOKENS_CONSUMED_BY_REPLY_PREFIX;
case 'gpt-3.5-turbo-0301':
case 'gpt-3.5-turbo-0613':
Expand All @@ -242,6 +238,7 @@ function tokenLimitForChatModel(
case 'gpt-3.5-turbo-16k':
case 'gpt-3.5-turbo-16k-0613':
case 'gpt-3.5-turbo-1106':
case 'gpt-3.5-turbo-0125':
return 16384 - functionEstimate - TOKENS_CONSUMED_BY_REPLY_PREFIX;
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
6 changes: 5 additions & 1 deletion packages/docs/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## 0.30.0
## 0.30.1

- Add new OpenAI models

## [0.30.0](https://github.com/fixie-ai/ai-jsx/tree/feecd641159e0ede554d6890a550dd172d8e24db)

- Added support for Claude 3 and messages API in `AnthropicChatModel`
- Relaxed function calling check for `OpenAIChatModel`
Expand Down
2 changes: 1 addition & 1 deletion packages/fixie-sdk/src/request-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function FixieRequestWrapper({
})
}
chatModel="gpt-3.5-turbo"
completionModel="text-davinci-003"
completionModel="gpt-3.5-turbo-instruct"
>
{wrappedNode}
</OpenAI>
Expand Down

0 comments on commit 7d7ca59

Please sign in to comment.