Skip to content

Commit 234f0a4

Browse files
[Client] Add num_prompt_tokens to the client's CompletionOutputs (#467)
* add prompt token, untested * comment * remove stop_str stuff, it doesn't do anything with the public api, and it breaks on certain frameworks when hosted locally
1 parent d0d7c05 commit 234f0a4

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

clients/python/llmengine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.0.0b26"
15+
__version__ = "0.0.0b27"
1616

1717
import os
1818
from typing import Sequence

clients/python/llmengine/data_types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ class CompletionOutput(BaseModel):
305305
text: str
306306
"""The text of the completion."""
307307

308+
# We're not guaranteed to have `num_prompt_tokens` in the response in all cases, so to be safe, set a default.
309+
# If we send request to api.spellbook.scale.com, we don't get this back.
310+
num_prompt_tokens: Optional[int] = None
311+
"""Number of tokens in the prompt."""
312+
308313
num_completion_tokens: int
309314
"""Number of tokens in the completion."""
310315

@@ -353,6 +358,10 @@ class CompletionStreamOutput(BaseModel):
353358
finished: bool
354359
"""Whether the completion is finished."""
355360

361+
# We're not guaranteed to have `num_prompt_tokens` in the response in all cases, so to be safe, set a default.
362+
num_prompt_tokens: Optional[int] = None
363+
"""Number of tokens in the prompt."""
364+
356365
num_completion_tokens: Optional[int] = None
357366
"""Number of tokens in the completion."""
358367

clients/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "scale-llm-engine"
3-
version = "0.0.0.beta26"
3+
version = "0.0.0.beta27"
44
description = "Scale LLM Engine Python client"
55
license = "Apache-2.0"
66
authors = ["Phil Chen <phil.chen@scale.com>"]

clients/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
setup(
44
name="scale-llm-engine",
55
python_requires=">=3.7",
6-
version="0.0.0.beta26",
6+
version="0.0.0.beta27",
77
packages=find_packages(),
88
)

0 commit comments

Comments
 (0)