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: add missing o1 models #121

Merged
merged 2 commits into from
Oct 3, 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
7 changes: 7 additions & 0 deletions .changeset/cuddly-dolphins-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tiktoken": patch
"js-tiktoken": patch
"@dqbd/tiktoken": patch
---

Add o1 class of models
10 changes: 9 additions & 1 deletion js/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,15 @@ export function getEncodingNameForModel(model: TiktokenModel) {
case "gpt-4o-2024-05-13":
case "gpt-4o-2024-08-06":
case "gpt-4o-mini-2024-07-18":
case "gpt-4o-mini": {
case "gpt-4o-mini":
case "o1-mini":
case "o1-preview":
case "o1-preview-2024-09-12":
case "o1-mini-2024-09-12":
case "chatgpt-4o-latest":
case "gpt-4o-realtime":
case "gpt-4o-realtime-preview-2024-10-01":
{
return "o200k_base";
}
default:
Expand Down
9 changes: 8 additions & 1 deletion tiktoken/model_to_encoding.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,12 @@
"gpt-4o-2024-05-13": "o200k_base",
"gpt-4o-2024-08-06":"o200k_base",
"gpt-4o-mini-2024-07-18": "o200k_base",
"gpt-4o-mini": "o200k_base"
"gpt-4o-mini": "o200k_base",
"o1-mini": "o200k_base",
"o1-preview": "o200k_base",
"o1-preview-2024-09-12": "o200k_base",
"o1-mini-2024-09-12": "o200k_base",
"chatgpt-4o-latest": "o200k_base",
"gpt-4o-realtime": "o200k_base",
"gpt-4o-realtime-preview-2024-10-01": "o200k_base"
}
14 changes: 14 additions & 0 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@ export type TiktokenModel =
| "gpt-4o-2024-08-06"
| "gpt-4o-mini-2024-07-18"
| "gpt-4o-mini"
| "o1-mini"
| "o1-preview"
| "o1-preview-2024-09-12"
| "o1-mini-2024-09-12"
| "chatgpt-4o-latest"
| "gpt-4o-realtime"
| "gpt-4o-realtime-preview-2024-10-01"

/**
* @param {TiktokenModel} encoding
Expand Down Expand Up @@ -499,6 +506,13 @@ pub fn encoding_for_model(
"gpt-4o-2024-08-06" => Ok("o200k_base"),
"gpt-4o-mini-2024-07-18" => Ok("o200k_base"),
"gpt-4o-mini" => Ok("o200k_base"),
"o1-mini" => Ok("o200k_base"),
"o1-preview" => Ok("o200k_base"),
"o1-preview-2024-09-12" => Ok("o200k_base"),
"o1-mini-2024-09-12" => Ok("o200k_base"),
"chatgpt-4o-latest" => Ok("o200k_base"),
"gpt-4o-realtime" => Ok("o200k_base"),
"gpt-4o-realtime-preview-2024-10-01" => Ok("o200k_base"),
model => Err(JsError::new(
format!("Invalid model: {}", model.to_string()).as_str(),
)),
Expand Down
Loading