UUpdate code
Browse files- response_formatter.py +27 -9
response_formatter.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from schemas import CodeTaskType, CodeXResponse
|
| 2 |
|
| 3 |
|
| 4 |
def clean_text(text: str) -> str:
|
|
@@ -12,16 +12,26 @@ def build_response(
|
|
| 12 |
model_output: str,
|
| 13 |
model_used: str,
|
| 14 |
used_fallback: bool,
|
|
|
|
|
|
|
| 15 |
) -> CodeXResponse:
|
| 16 |
cleaned_output = clean_text(model_output)
|
| 17 |
|
| 18 |
return CodeXResponse(
|
| 19 |
task_type=task_type,
|
| 20 |
answer=cleaned_output,
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
|
|
@@ -32,8 +42,16 @@ def build_error_response(
|
|
| 32 |
return CodeXResponse(
|
| 33 |
task_type=task_type,
|
| 34 |
answer="",
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
)
|
|
|
|
| 1 |
+
from schemas import CodeTaskType, CodeXResponse, ResponseMeta
|
| 2 |
|
| 3 |
|
| 4 |
def clean_text(text: str) -> str:
|
|
|
|
| 12 |
model_output: str,
|
| 13 |
model_used: str,
|
| 14 |
used_fallback: bool,
|
| 15 |
+
retrieval_used: bool = False,
|
| 16 |
+
source_count: int = 0,
|
| 17 |
) -> CodeXResponse:
|
| 18 |
cleaned_output = clean_text(model_output)
|
| 19 |
|
| 20 |
return CodeXResponse(
|
| 21 |
task_type=task_type,
|
| 22 |
answer=cleaned_output,
|
| 23 |
+
code_output=None,
|
| 24 |
+
explanation=None,
|
| 25 |
+
warnings=[],
|
| 26 |
+
sources=[],
|
| 27 |
+
needs_clarification=False,
|
| 28 |
+
meta=ResponseMeta(
|
| 29 |
+
used_model=model_used,
|
| 30 |
+
fallback_used=used_fallback,
|
| 31 |
+
retrieval_used=retrieval_used,
|
| 32 |
+
source_count=source_count,
|
| 33 |
+
processing_time_ms=None,
|
| 34 |
+
),
|
| 35 |
)
|
| 36 |
|
| 37 |
|
|
|
|
| 42 |
return CodeXResponse(
|
| 43 |
task_type=task_type,
|
| 44 |
answer="",
|
| 45 |
+
code_output=None,
|
| 46 |
+
explanation=None,
|
| 47 |
+
warnings=[clean_text(error_message)],
|
| 48 |
+
sources=[],
|
| 49 |
+
needs_clarification=False,
|
| 50 |
+
meta=ResponseMeta(
|
| 51 |
+
used_model="none",
|
| 52 |
+
fallback_used=False,
|
| 53 |
+
retrieval_used=False,
|
| 54 |
+
source_count=0,
|
| 55 |
+
processing_time_ms=None,
|
| 56 |
+
),
|
| 57 |
)
|