Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,8 +82,8 @@ def enhance_for_gradio(prompt_text, api_key):
|
|
| 82 |
messages,
|
| 83 |
max_new_tokens=512,
|
| 84 |
temperature=0.7,
|
| 85 |
-
do_sample=True
|
| 86 |
-
|
| 87 |
)
|
| 88 |
full_response = result[0]["generated_text"]
|
| 89 |
|
|
@@ -94,18 +94,16 @@ def enhance_for_gradio(prompt_text, api_key):
|
|
| 94 |
if assistant_messages:
|
| 95 |
enhanced_prompt = assistant_messages[-1]
|
| 96 |
else:
|
| 97 |
-
# Eğer assistant mesajı yoksa, tüm çıktıyı birleştir
|
| 98 |
enhanced_prompt = " ".join([msg.get("content", "") for msg in full_response])
|
| 99 |
else:
|
| 100 |
-
#
|
| 101 |
enhanced_prompt = full_response
|
| 102 |
|
| 103 |
-
# Temizlik
|
| 104 |
enhanced_prompt = enhanced_prompt.replace("<end_of_turn>", "").strip()
|
| 105 |
|
| 106 |
-
# Eğer hâlâ boşsa fallback
|
| 107 |
if not enhanced_prompt:
|
| 108 |
-
return "Model did not generate a valid response. Try again
|
| 109 |
|
| 110 |
return enhanced_prompt
|
| 111 |
|
|
|
|
| 82 |
messages,
|
| 83 |
max_new_tokens=512,
|
| 84 |
temperature=0.7,
|
| 85 |
+
do_sample=True
|
| 86 |
+
# stop_strings kaldırıldı - test için
|
| 87 |
)
|
| 88 |
full_response = result[0]["generated_text"]
|
| 89 |
|
|
|
|
| 94 |
if assistant_messages:
|
| 95 |
enhanced_prompt = assistant_messages[-1]
|
| 96 |
else:
|
|
|
|
| 97 |
enhanced_prompt = " ".join([msg.get("content", "") for msg in full_response])
|
| 98 |
else:
|
| 99 |
+
# String ise direkt kullan
|
| 100 |
enhanced_prompt = full_response
|
| 101 |
|
| 102 |
+
# Temizlik
|
| 103 |
enhanced_prompt = enhanced_prompt.replace("<end_of_turn>", "").strip()
|
| 104 |
|
|
|
|
| 105 |
if not enhanced_prompt:
|
| 106 |
+
return "Model did not generate a valid response. Try again."
|
| 107 |
|
| 108 |
return enhanced_prompt
|
| 109 |
|