Skip to content

Commit

Permalink
🧮 Add token counting comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Nov 20, 2023
1 parent 4a5f2b6 commit 95020a7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions funcchain/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Generator, AsyncGenerator, Callable, Coroutine, Awaitable, Any
from langchain.callbacks.base import AsyncCallbackHandler
from langchain.schema.messages import BaseMessage
# from .utils import count_tokens


class AsyncStreamHandler(AsyncCallbackHandler):
Expand All @@ -27,6 +28,14 @@ async def on_chat_model_start(
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
# for lists in messages:
# for message in lists:
# if message.content:
# if isinstance(message.content, str):
# self.tokens += count_tokens(message.content)
# elif isinstance(message.content, list):
# print("token_counting", message.content)
# # self.tokens += count_tokens(message)
pass

async def on_llm_new_token(
Expand Down

0 comments on commit 95020a7

Please sign in to comment.