Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
pipe = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
-
model="
|
| 8 |
max_new_tokens=200
|
| 9 |
)
|
| 10 |
|
| 11 |
def reply(message, history):
|
|
|
|
| 12 |
prompt = f"User: {message}\nAssistant:"
|
| 13 |
output = pipe(prompt)[0]["generated_text"]
|
| 14 |
-
|
| 15 |
-
#
|
| 16 |
if "Assistant:" in output:
|
| 17 |
output = output.split("Assistant:")[1].strip()
|
| 18 |
return output
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Daha küçük ve hafif bir model (phi-2)
|
| 5 |
pipe = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
+
model="microsoft/phi-2",
|
| 8 |
max_new_tokens=200
|
| 9 |
)
|
| 10 |
|
| 11 |
def reply(message, history):
|
| 12 |
+
# Basit bir prompt formatı
|
| 13 |
prompt = f"User: {message}\nAssistant:"
|
| 14 |
output = pipe(prompt)[0]["generated_text"]
|
| 15 |
+
|
| 16 |
+
# Eğer model 'Assistant:' ile devam ederse, oradan sonrasını al
|
| 17 |
if "Assistant:" in output:
|
| 18 |
output = output.split("Assistant:")[1].strip()
|
| 19 |
return output
|