Skip to content

Make copilot integration tests pass on the replace-litellm branch #1109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/codegate/pipeline/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ async def process_stream(
finally:
# NOTE: Don't use await in finally block, it will break the stream
# Don't flush the buffer if we assume we'll call the pipeline again
if cleanup_sensitive is False and finish_stream:
self._record_to_db()
if cleanup_sensitive is False:
if finish_stream:
self._record_to_db()
return

# TODO figure out what's the logic here.
Expand Down
7 changes: 3 additions & 4 deletions src/codegate/providers/copilot/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,16 +871,15 @@ async def stream_iterator():
while not self.stream_queue.empty():
incoming_record = await self.stream_queue.get()
for choice in incoming_record.choices:
if choice.finish_reason and \
choice.finish_reason in ["stop", "length", "content_filter", "tool_calls"]:
if choice.finish_reason and choice.finish_reason is not None:
self.finish_stream = True
yield incoming_record

# needs to be set as the flag gets reset on finish_data
finish_stream_flag = any(
choice.get("finish_reason") == "stop"
choice.finish_reason is not None
for record in list(self.stream_queue._queue)
for choice in record.get("content", {}).get("choices", [])
for choice in record.choices
)
async for record in self.output_pipeline_instance.process_stream(
stream_iterator(),
Expand Down