Commit 8939415

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-01-29 14:43:22
fix(gpt): filter out empty context
1 parent 58d8c91
Changed files (1)
src
src/llm/contexts.py
@@ -46,6 +46,7 @@ async def get_conversation_contexts(client: Client, conversations: list[Message]
     """
     # parse context for each message
     contexts = [await single_context(client, message) for message in conversations]
+    contexts = [x for x in contexts if x]  # filter out empty context
     contexts = combine_consecutive_role_contexts(contexts)
     return contexts[: int(GPT.HISTORY_CONTEXT)]