Skip to content

Commit

Permalink
feat: support for gpt-4o
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed May 14, 2024
1 parent 2a0302e commit be3f743
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ more:

**Hosted Models**

- OpenAI Models (GPT-3.5-turbo, GPT-4, GPT-4-turbo)
- OpenAI Models (GPT-3.5-turbo, GPT-4, GPT-4-turbo, GPT-4o)
- Anthropic Models (Claude, Claude Instant)

**Open Source Models**
Expand Down
2 changes: 1 addition & 1 deletion kani/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.0.1"
4 changes: 4 additions & 0 deletions kani/engines/openai/engine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
import warnings
from typing import AsyncIterable

from kani.ai_function import AIFunction
Expand All @@ -22,6 +23,8 @@
("gpt-3.5-turbo-instruct", 4096),
("gpt-3.5-turbo-0613", 4096),
("gpt-3.5-turbo", 16385),
# gpt-4o
("gpt-4o", 128000),
# gpt-4-turbo models aren't prefixed differently...
# TODO make the default gpt-4 128k and keep the pre-turbo ones at 8k after gpt-4 defaults to 128k
("gpt-4-1106", 128000),
Expand Down Expand Up @@ -101,6 +104,7 @@ def _load_tokenizer(self):
try:
self.tokenizer = tiktoken.encoding_for_model(self.model)
except KeyError:
warnings.warn(f"Could not find a tokenizer for the {self.model} model. You may need to update tiktoken.")
self.tokenizer = tiktoken.get_encoding("cl100k_base")

def message_len(self, message: ChatMessage) -> int:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cpp = [

openai = [
"openai>=1.26.0,<2.0.0",
"tiktoken>=0.4.0,<1.0.0",
"tiktoken>=0.7.0,<1.0.0",
]

anthropic = [
Expand Down

0 comments on commit be3f743

Please sign in to comment.