Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added o1-preview and o1-mini chat completion models #56

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/GptEncoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ export class GptEncoding {
}

encode(lineToEncode: string, encodeOptions?: EncodeOptions): number[] {
// const encodedTokens: number[] = []
// for (const tokens of this.encodeGenerator(lineToEncode, encodeOptions)) {
// encodedTokens.push(...tokens)
// }
// return encodedTokens
const specialTokenConfig = encodeOptions
? this.processSpecialTokens(encodeOptions)
: this.defaultSpecialTokenConfig
Expand Down
2 changes: 2 additions & 0 deletions src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const encodingNames = [
] as const

const chatEnabledModelsMap = {
'o1-preview': o200k_base,
'o1-mini': o200k_base,
'gpt-4': cl100k_base,
'gpt-4-0314': cl100k_base,
'gpt-4-0613': cl100k_base,
Expand Down
29 changes: 29 additions & 0 deletions src/model/o1-mini.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable import/extensions */
import encoder from '../encodings/o200k_base.js'
import { GptEncoding } from '../GptEncoding.js'

export * from '../specialTokens.js'
// prettier-ignore
const api = GptEncoding.getEncodingApiForModel('o1-mini', () => encoder)
const {
decode,
decodeAsyncGenerator,
decodeGenerator,
encode,
encodeGenerator,
isWithinTokenLimit,
encodeChat,
encodeChatGenerator,
} = api
export {
decode,
decodeAsyncGenerator,
decodeGenerator,
encode,
encodeChat,
encodeChatGenerator,
encodeGenerator,
isWithinTokenLimit,
}
// eslint-disable-next-line import/no-default-export
export default api
29 changes: 29 additions & 0 deletions src/model/o1-preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable import/extensions */
import encoder from '../encodings/o200k_base.js'
import { GptEncoding } from '../GptEncoding.js'

export * from '../specialTokens.js'
// prettier-ignore
const api = GptEncoding.getEncodingApiForModel('o1-preview', () => encoder)
const {
decode,
decodeAsyncGenerator,
decodeGenerator,
encode,
encodeGenerator,
isWithinTokenLimit,
encodeChat,
encodeChatGenerator,
} = api
export {
decode,
decodeAsyncGenerator,
decodeGenerator,
encode,
encodeChat,
encodeChatGenerator,
encodeGenerator,
isWithinTokenLimit,
}
// eslint-disable-next-line import/no-default-export
export default api
Loading