Skip to content

Commit

Permalink
🚚 Move token count import
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Nov 26, 2023
1 parent 9760b34 commit 13bd34f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/funcchain/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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 @@ -30,6 +29,7 @@ async def on_chat_model_start(
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
# from .utils import count_tokens
# for lists in messages:
# for message in lists:
# if message.content:
Expand Down Expand Up @@ -84,6 +84,7 @@ def stream_to(
>>> with stream_to(print):
... # your chain calls here
"""
# TODO: set streaming to true specifically in this context
if fn is print and kwargs == {}:
kwargs = {"end": "", "flush": True}
cb = AsyncStreamHandler(fn, kwargs)
Expand Down

0 comments on commit 13bd34f

Please sign in to comment.