File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -58,17 +58,22 @@ def respond(interpreter):
5858 chunk_type = "code"
5959 yield {"start_of_code" : True }
6060 if "code" in chunk and chunk_type != "code" :
61- # (This shouldn't happen though — ^ "language" should be emitted first)
61+ # (This shouldn't happen though — ^ "language" should be emitted first, but sometimes GPT-3.5 forgets this)
62+ # (But I'm pretty sure we handle that? If it forgets we emit Python anyway?)
6263 chunk_type = "code"
6364 yield {"start_of_code" : True }
6465 elif "message" not in chunk and chunk_type == "message" :
6566 chunk_type = None
6667 yield {"end_of_message" : True }
67- elif "code" not in chunk and "language" not in chunk and chunk_type == "code" :
68- chunk_type = None
69- yield {"end_of_code" : True }
7068
7169 yield chunk
70+
71+ # We don't trigger the end_of_message or end_of_code flag if we actually end on either
72+ if chunk_type == "message" :
73+ yield {"end_of_message" : True }
74+ elif chunk_type == "code" :
75+ yield {"end_of_code" : True }
76+
7277 except litellm .exceptions .BudgetExceededError :
7378 display_markdown_message (f"""> Max budget exceeded
7479
You can’t perform that action at this time.
0 commit comments