Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit ff881d2

Browse files
jhrozekblkt
authored andcommitted
Fix codegate version (#1062)
1 parent ffb8be6 commit ff881d2

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/codegate/pipeline/cli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ async def process(
158158
response=PipelineResponse(
159159
step_name=self.name,
160160
content=cmd_out,
161-
model=request["model"],
161+
model=request.get_model()
162162
),
163163
context=context,
164164
)

src/codegate/providers/copilot/pipeline.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import time
32
from abc import ABC, abstractmethod
43
from typing import Dict, Tuple
@@ -9,8 +8,12 @@
98
from codegate.pipeline.base import PipelineContext, PipelineResult, SequentialPipelineProcessor
109
from codegate.pipeline.factory import PipelineFactory
1110
from codegate.providers.normalizer.completion import CompletionNormalizer
12-
from codegate.types.common import Delta, ModelResponse, StreamingChoices
13-
from codegate.types.openai import ChatCompletionRequest
11+
from codegate.types.openai import (
12+
ChatCompletionRequest,
13+
ChoiceDelta,
14+
MessageDelta,
15+
StreamingChatCompletion,
16+
)
1417

1518
logger = structlog.get_logger("codegate")
1619

@@ -69,18 +72,21 @@ def _get_copilot_headers(headers: Dict[str, str]) -> Dict[str, str]:
6972
return copilot_headers
7073

7174
@staticmethod
72-
def _create_shortcut_response(result: PipelineResult, model: str) -> bytes:
73-
response = ModelResponse(
75+
def _create_shortcut_response(result: PipelineResult) -> bytes:
76+
response = StreamingChatCompletion(
77+
id="",
7478
choices=[
75-
StreamingChoices(
79+
ChoiceDelta(
7680
finish_reason="stop",
7781
index=0,
78-
delta=Delta(content=result.response.content, role="assistant"),
79-
)
82+
delta=MessageDelta(
83+
content=result.response.content,
84+
role="assistant"),
85+
),
8086
],
81-
created=int(time.time()),
82-
model=model,
83-
stream=True,
87+
created = int(time.time()),
88+
model=result.response.model,
89+
object="chat.completion.chunk",
8490
)
8591
body = response.model_dump_json(exclude_none=True, exclude_unset=True).encode()
8692
return body
@@ -122,7 +128,7 @@ async def process_body(
122128
try:
123129
# Return shortcut response to the user
124130
body = CopilotPipeline._create_shortcut_response(
125-
result, normalized_body.model,
131+
result,
126132
)
127133
logger.info(f"Pipeline created shortcut response: {body}")
128134
return body, result.context

0 commit comments

Comments
 (0)