Skip to content

Commit 65dfe96

Browse files
jhrozekblkt
authored andcommitted
Make copilot integration tests pass on the replace-litellm branch (#1109)
* Fix copilot secret unredaction The copilot provider always sends `cleanup_sensitive` set to `False` as it manages the context itself. On streams where `finish_stream` was set to `False` as well, we would have yielded the rest of the context buffer though which would break secret unredaction. To reproduce, ask Copilot to make a simple modification in a file containing secrets so that it's forced to print the secrets back to you. * Port recent copilot change to the new chunk API
1 parent 29ccf51 commit 65dfe96

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/codegate/providers/copilot/provider.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -871,16 +871,15 @@ async def stream_iterator():
871871
while not self.stream_queue.empty():
872872
incoming_record = await self.stream_queue.get()
873873
for choice in incoming_record.choices:
874-
if choice.finish_reason and \
875-
choice.finish_reason in ["stop", "length", "content_filter", "tool_calls"]:
874+
if choice.finish_reason and choice.finish_reason is not None:
876875
self.finish_stream = True
877876
yield incoming_record
878877

879878
# needs to be set as the flag gets reset on finish_data
880879
finish_stream_flag = any(
881-
choice.get("finish_reason") == "stop"
880+
choice.finish_reason is not None
882881
for record in list(self.stream_queue._queue)
883-
for choice in record.get("content", {}).get("choices", [])
882+
for choice in record.choices
884883
)
885884
async for record in self.output_pipeline_instance.process_stream(
886885
stream_iterator(),

0 commit comments

Comments
 (0)