diff --git a/funcchain/streaming.py b/funcchain/streaming.py index ce470fa..6f2072f 100644 --- a/funcchain/streaming.py +++ b/funcchain/streaming.py @@ -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): @@ -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(