Skip to content

Commit 38dcb8c

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 038a3ce commit 38dcb8c

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
@@ -874,16 +874,15 @@ async def stream_iterator():
874874
while not self.stream_queue.empty():
875875
incoming_record = await self.stream_queue.get()
876876
for choice in incoming_record.choices:
877-
if choice.finish_reason and \
878-
choice.finish_reason in ["stop", "length", "content_filter", "tool_calls"]:
877+
if choice.finish_reason and choice.finish_reason is not None:
879878
self.finish_stream = True
880879
yield incoming_record
881880

882881
# needs to be set as the flag gets reset on finish_data
883882
finish_stream_flag = any(
884-
choice.get("finish_reason") == "stop"
883+
choice.finish_reason is not None
885884
for record in list(self.stream_queue._queue)
886-
for choice in record.get("content", {}).get("choices", [])
885+
for choice in record.choices
887886
)
888887
async for record in self.output_pipeline_instance.process_stream(
889888
stream_iterator(),

0 commit comments

Comments
 (0)