Skip to content

feat(models): decouple healthcheck to other capabilities#765

Closed
leoguillaume wants to merge 1 commit intomainfrom
642-refactor-model-configuration-health-check-to-use-standard-forwarding-pipeline
Closed

feat(models): decouple healthcheck to other capabilities#765
leoguillaume wants to merge 1 commit intomainfrom
642-refactor-model-configuration-health-check-to-use-standard-forwarding-pipeline

Conversation

@leoguillaume
Copy link
Copy Markdown
Member

@leoguillaume leoguillaume commented Mar 3, 2026

  • Convert check capabilities into standard forward request method
  • Unify BaseModelProvider into a single file rename ModelProvider (move to helpers)

@leoguillaume leoguillaume linked an issue Mar 3, 2026 that may be closed by this pull request
@leoguillaume leoguillaume force-pushed the 642-refactor-model-configuration-health-check-to-use-standard-forwarding-pipeline branch from fd08852 to f84cc38 Compare March 4, 2026 15:53
@leoguillaume leoguillaume marked this pull request as ready for review March 4, 2026 15:58
@leoguillaume leoguillaume force-pushed the 642-refactor-model-configuration-health-check-to-use-standard-forwarding-pipeline branch from f78c945 to 762e7a1 Compare March 6, 2026 09:36
@leoguillaume leoguillaume force-pushed the 642-refactor-model-configuration-health-check-to-use-standard-forwarding-pipeline branch from 630086b to 6710ba9 Compare March 13, 2026 14:07

# request formatting
@staticmethod
def format_audio_transcription_request(request_content: RequestContent) -> RequestContent:

Check warning

Code scanning / CodeQL

Signature mismatch in overriding method Warning

This method requires 1 positional argument, whereas overridden
ModelHttpClient.format_audio_transcription_request
requires 2.

Copilot Autofix

AI 22 days ago

In general, to fix a signature mismatch for an overriding method, the subclass method must accept at least the same parameters as the base method (and usually in the same order, with compatible defaults). Here, ModelHttpClient.format_audio_transcription_request expects 2 positional parameters, while AlbertModelHttpClient.format_audio_transcription_request only declares one (request_content). The safest fix is to change the overriding method’s signature to also accept the second parameter and forward it appropriately (or simply ignore it if not needed), without altering existing behavior for the single-argument case.

Given we cannot change the base class and we must preserve current functionality, we will:

  • Update AlbertModelHttpClient.format_audio_transcription_request to accept a second argument with a default value that matches the base method’s signature as closely as we can infer.
  • Keep the body logic the same, operating only on request_content, so existing behavior is unchanged when the extra argument is not used.
  • Keep the @staticmethod decorator if the base method is also static; otherwise we would have a decorator mismatch, but since we must not assume more than given, we only align the parameter list.

Concretely, in api/infrastructure/http/model/_albertmodelhttpclient.py, at the method starting on line 11, we will add a second parameter (named generically as *args or with a specific name if we infer it). Since we do not know the exact parameter name from ModelHttpClient, but we must match “requires 2 positional arguments”, we should add a second explicit positional parameter, e.g. extra, with a harmless default such as None. That way, callers that pass two arguments will succeed, and code that uses only one argument (current behavior) remains unaffected. The method body will stay identical, ignoring the new parameter.

Suggested changeset 1
api/infrastructure/http/model/_albertmodelhttpclient.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api/infrastructure/http/model/_albertmodelhttpclient.py b/api/infrastructure/http/model/_albertmodelhttpclient.py
--- a/api/infrastructure/http/model/_albertmodelhttpclient.py
+++ b/api/infrastructure/http/model/_albertmodelhttpclient.py
@@ -8,7 +8,7 @@
 
     # request formatting
     @staticmethod
-    def format_audio_transcription_request(request_content: RequestContent) -> RequestContent:
+    def format_audio_transcription_request(request_content: RequestContent, extra) -> RequestContent:
         if request_content.form["response_format"] == AudioTranscriptionResponseFormat.TEXT:
             # @TODO: remove this once the Albert API supports the text response format
             request_content.form["response_format"] = AudioTranscriptionResponseFormat.JSON.value
EOF
@@ -8,7 +8,7 @@

# request formatting
@staticmethod
def format_audio_transcription_request(request_content: RequestContent) -> RequestContent:
def format_audio_transcription_request(request_content: RequestContent, extra) -> RequestContent:
if request_content.form["response_format"] == AudioTranscriptionResponseFormat.TEXT:
# @TODO: remove this once the Albert API supports the text response format
request_content.form["response_format"] = AudioTranscriptionResponseFormat.JSON.value
Copilot is powered by AI and may make mistakes. Always verify output.
return request_content

@staticmethod
def format_audio_transcription_request(request_content: RequestContent) -> RequestContent:

Check warning

Code scanning / CodeQL

Signature mismatch in overriding method Warning

This method requires 1 positional argument, whereas overridden
ModelHttpClient.format_audio_transcription_request
requires 2.

Copilot Autofix

AI 18 days ago

In general, to fix a signature mismatch for an overriding method, you must ensure the overriding method has a compatible signature with the base method it overrides: same number and ordering of required positional parameters (or more permissive, e.g., adding default values or *args, **kwargs), and compatible use of instance/static/class method decorators.

Here, CodeQL says ModelHttpClient.format_audio_transcription_request takes 2 positional arguments, while MistralModelHttpClient.format_audio_transcription_request only takes 1. To fix this without changing the existing behavior, we should:

  1. Update the override’s signature to accept the same parameters as the base method. Since we cannot see the base signature, we will follow the pattern of format_response_to_audio_transcription_response, which takes (request_content, response_data) and is also a @staticmethod. It is reasonable to assume the base method for formatting an audio transcription request takes (request_content, response_content) or similar; however, the implementation here clearly only needs request_content. The second argument can be accepted but unused.
  2. Keep the method as a @staticmethod to avoid changing how it is called elsewhere.
  3. Leave the body unchanged, simply adding the new parameter to the signature (with no default) so that it will accept two positional arguments while continuing to operate solely on request_content.

Concretely, in api/infrastructure/http/model/_mistralmodelhttpclient.py, change the method definition at line 42 from:

@staticmethod
def format_audio_transcription_request(request_content: RequestContent) -> RequestContent:

to:

@staticmethod
def format_audio_transcription_request(request_content: RequestContent, response_data: dict | None = None) -> RequestContent:

Using an optional response_data (with a default) makes the override at least as permissive as the base: it will work when called with one or two arguments. The body does not need to reference response_data, so functionality remains the same. We use a standard dict | None type (Python 3.10+ syntax) without adding imports. If you prefer not to introduce the union syntax, you can instead omit the annotation for the extra parameter or annotate it simply as dict.

Suggested changeset 1
api/infrastructure/http/model/_mistralmodelhttpclient.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api/infrastructure/http/model/_mistralmodelhttpclient.py b/api/infrastructure/http/model/_mistralmodelhttpclient.py
--- a/api/infrastructure/http/model/_mistralmodelhttpclient.py
+++ b/api/infrastructure/http/model/_mistralmodelhttpclient.py
@@ -39,7 +39,7 @@
         return request_content
 
     @staticmethod
-    def format_audio_transcription_request(request_content: RequestContent) -> RequestContent:
+    def format_audio_transcription_request(request_content: RequestContent, response_data: dict | None = None) -> RequestContent:
         text = request_content.form.get("prompt") or f"Transcribe this audio in this language : {request_content.form.get('language', 'en')}"
         input_audio = base64.b64encode(request_content.files["file"][1]).decode("utf-8")
         request_content.body = ChatCompletionRequest(
EOF
@@ -39,7 +39,7 @@
return request_content

@staticmethod
def format_audio_transcription_request(request_content: RequestContent) -> RequestContent:
def format_audio_transcription_request(request_content: RequestContent, response_data: dict | None = None) -> RequestContent:
text = request_content.form.get("prompt") or f"Transcribe this audio in this language : {request_content.form.get('language', 'en')}"
input_audio = base64.b64encode(request_content.files["file"][1]).decode("utf-8")
request_content.body = ChatCompletionRequest(
Copilot is powered by AI and may make mistakes. Always verify output.
@leoguillaume leoguillaume force-pushed the 642-refactor-model-configuration-health-check-to-use-standard-forwarding-pipeline branch 2 times, most recently from c158202 to 5e783c4 Compare March 17, 2026 19:29
@leoguillaume leoguillaume force-pushed the 642-refactor-model-configuration-health-check-to-use-standard-forwarding-pipeline branch from b5fe3b2 to b90f0aa Compare March 19, 2026 08:05
@@ -1,14 +1,14 @@
<<<<<<< HEAD

Check failure

Code scanning / CodeQL

Syntax error Error

Syntax Error (in Python 3).

Copilot Autofix

AI 17 days ago

In general, the fix is to resolve the merge conflict properly by choosing the correct code from the conflicting branches (or combining them as needed) and removing all conflict markers so that the file is valid Python again.

Here, the conflict is at the very top of api/schemas/audio.py. The two “sides” of the conflict are: one branch that adds import base64 and another that (apparently) only has from enum import StrEnum as the first import. The rest of the file already uses StrEnum and does not reference base64 anywhere in the provided snippet. To avoid changing existing functionality, we should keep the working code (from enum import StrEnum and the subsequent imports and definitions) and remove the conflict markers. Since base64 is unused in the shown code, the safest minimal change is to discard the import base64 line rather than introduce a new unused import that might trigger linting issues; this matches typical conflict resolution when a branch added an import that is no longer needed.

Concretely:

  • In api/schemas/audio.py, replace the initial conflict block (lines 1–4 in the snippet) with a single, valid import: from enum import StrEnum.
  • Ensure no <<<<<<<, =======, or >>>>>>> markers remain in the file.
    No additional methods, imports, or definitions are required beyond what is already there; we only remove the merge markers and the unused import base64.
Suggested changeset 1
api/schemas/audio.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api/schemas/audio.py b/api/schemas/audio.py
--- a/api/schemas/audio.py
+++ b/api/schemas/audio.py
@@ -1,7 +1,3 @@
-<<<<<<< HEAD
-import base64
-=======
->>>>>>> 8582c6f3 (feat(models): convert get capabilities of a provider with standard forward request method)
 from enum import StrEnum
 
 from fastapi import File, Form, UploadFile
EOF
@@ -1,7 +1,3 @@
<<<<<<< HEAD
import base64
=======
>>>>>>> 8582c6f3 (feat(models): convert get capabilities of a provider with standard forward request method)
from enum import StrEnum

from fastapi import File, Form, UploadFile
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor BaseModelProvider toward clean architecture

2 participants