From b3f6ef62e01c84389e09ae5221f2d8af85f98320 Mon Sep 17 00:00:00 2001 From: jonny <32085184+jonnyjohnson1@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:21:49 -0500 Subject: [PATCH] + if check before content.split() --- topos/api/websocket_handlers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/topos/api/websocket_handlers.py b/topos/api/websocket_handlers.py index 305999e..30cc778 100644 --- a/topos/api/websocket_handlers.py +++ b/topos/api/websocket_handlers.py @@ -189,7 +189,8 @@ async def chat(websocket: WebSocket): tokens_per_second = total_tokens / elapsed_time ttl_num_toks = 0 for i in simp_msg_history: - ttl_num_toks += len(i['content'].split()) + if isinstance(i['content'], str): + ttl_num_toks += len(i['content'].split()) await process_logger.end("llm_generation_stream_chat", toks_per_sec=f"{tokens_per_second:.1f}", ttfs=f"{ttfs}", num_toks=num_user_toks, ttl_num_toks=ttl_num_toks) # Fetch semantic category from the output # semantic_compression = SemanticCompression(model=f"ollama:{model}", api_key=get_openai_api_key())