Update app.py
Browse files
app.py
CHANGED
@@ -66,12 +66,20 @@ def generate(req: UserInputRequest):
|
|
66 |
]
|
67 |
|
68 |
# === Önce chat template string'ini al
|
69 |
-
|
70 |
messages,
|
71 |
add_generation_prompt=True,
|
72 |
return_tensors=None
|
73 |
)
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
# === Sonra tokenizer() ile input_ids + attention_mask hazırla
|
76 |
tokenized_inputs = tokenizer(
|
77 |
chat_template_str,
|
|
|
66 |
]
|
67 |
|
68 |
# === Önce chat template string'ini al
|
69 |
+
chat_template_raw = tokenizer.apply_chat_template(
|
70 |
messages,
|
71 |
add_generation_prompt=True,
|
72 |
return_tensors=None
|
73 |
)
|
74 |
|
75 |
+
# Güvenlik: None veya beklenmedik tip gelirse zorla string'e çevir
|
76 |
+
if chat_template_raw is None:
|
77 |
+
chat_template_str = ""
|
78 |
+
elif isinstance(chat_template_raw, str):
|
79 |
+
chat_template_str = chat_template_raw
|
80 |
+
else:
|
81 |
+
chat_template_str = str(chat_template_raw)
|
82 |
+
|
83 |
# === Sonra tokenizer() ile input_ids + attention_mask hazırla
|
84 |
tokenized_inputs = tokenizer(
|
85 |
chat_template_str,
|