Skip to content

Commit 3d03909

Browse files
authored
Merge pull request #741 from parea-ai/fix-get-tokens-no-model
fix: get tokens if no model is provided
2 parents 07c817a + 1d054e3 commit 3d03909

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

parea/evals/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ def run_evals_synchronous(trace_id: str, log: Log, eval_funcs: List[EvalFuncTupl
169169
def get_tokens(model: str, text: str) -> List[int]:
170170
if not text:
171171
return []
172+
fallback_model = "cl100k_base"
172173
try:
173-
encoding = tiktoken.encoding_for_model(model)
174+
encoding = tiktoken.encoding_for_model(model or fallback_model)
174175
except KeyError:
175-
encoding = tiktoken.get_encoding("cl100k_base")
176+
encoding = tiktoken.get_encoding(fallback_model)
176177
try:
177178
return encoding.encode(text)
178179
except Exception as e:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"
66
[tool.poetry]
77
name = "parea-ai"
88
packages = [{ include = "parea" }]
9-
version = "0.2.129"
9+
version = "0.2.130"
1010
description = "Parea python sdk"
1111
readme = "README.md"
1212
authors = ["joel-parea-ai <[email protected]>"]

0 commit comments

Comments
 (0)