Skip to content

Commit 70cb1ec

Browse files
committed
feat: add support for aider
Aider offers two types of integrations: - compatible OPENAI API - local ollama Add support for those 2 integrations, and correct all different nuances that we are getting with this new engine Closes: #440
1 parent 84d589a commit 70cb1ec

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ sqlite_data/vectordb.db
4949

5050
# certificate directory
5151
*certs/
52+
.aider*

Diff for: src/codegate/pipeline/base.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,11 @@ def get_latest_user_messages(request: ChatCompletionRequest) -> str:
253253

254254
for message in reversed(request.get("messages", [])):
255255
if message["role"] == "user":
256-
latest_user_messages += "\n" + message["content"]
257-
else:
258-
break
256+
# if found we can stop here, if not we continue until we find it
257+
message_str = message.get("content", "")
258+
if message_str:
259+
latest_user_messages += "\n" + str(message_str)
260+
break
259261

260262
return latest_user_messages
261263

Diff for: src/codegate/pipeline/codegate_context_retriever/codegate.py

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ async def process(
5959
"""
6060
Use RAG DB to add context to the user request
6161
"""
62-
6362
# Get the latest user messages
6463
user_messages = self.get_latest_user_messages(request)
6564

Diff for: src/codegate/pipeline/output.py

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class OutputPipelineContext:
2727
snippets: List[CodeSnippet] = field(default_factory=list)
2828
# Store all content that has been processed by the pipeline
2929
processed_content: List[str] = field(default_factory=list)
30+
# partial buffer to store prefixes
31+
prefix_buffer: str = ""
3032

3133

3234
class OutputPipelineStep(ABC):

Diff for: src/codegate/pipeline/secrets/secrets.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ async def process(
280280
if "content" in message and message["content"]:
281281
# Protect the text
282282
protected_string, redacted_count = self._redact_text(
283-
message["content"], secrets_manager, session_id, context
283+
str(message["content"]), secrets_manager, session_id, context
284284
)
285285
new_request["messages"][i]["content"] = protected_string
286286

@@ -389,12 +389,17 @@ async def process_chunk(
389389
return [chunk]
390390

391391
# If we have a partial marker at the end, keep buffering
392-
if self.marker_start in buffered_content or self._is_partial_marker_prefix(
393-
buffered_content
394-
):
392+
if self.marker_start in buffered_content:
393+
context.prefix_buffer = ""
394+
return []
395+
396+
if self._is_partial_marker_prefix(buffered_content):
397+
context.prefix_buffer += buffered_content
395398
return []
396399

397400
# No markers or partial markers, let pipeline handle the chunk normally
401+
chunk.choices[0].delta.content = context.prefix_buffer + chunk.choices[0].delta.content
402+
context.prefix_buffer = ""
398403
return [chunk]
399404

400405

0 commit comments

Comments
 (0)