Skip to content

Commit

Permalink
feat: added o1-preview and o1-mini chat completion models (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbukeRepo authored Oct 9, 2024
1 parent bf4b459 commit 41673af
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
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

0 comments on commit 41673af

Please sign in to comment.