SEC101_space / app.py
gefrontz's picture
Update app.py
86db4a4 verified
raw
history blame contribute delete
679 Bytes
import gradio as gr
from transformers import pipeline
# Daha küçük ve hafif bir model (phi-2)
pipe = pipeline(
"text-generation",
model="microsoft/phi-2",
max_new_tokens=200
)
def reply(message, history):
# Basit bir prompt formatı
prompt = f"User: {message}\nAssistant:"
output = pipe(prompt)[0]["generated_text"]
# Eğer model 'Assistant:' ile devam ederse, oradan sonrasını al
if "Assistant:" in output:
output = output.split("Assistant:")[1].strip()
return output
demo = gr.ChatInterface(
fn=reply,
title="My AI Tool Prototype",
description="This is a simple AI prototype for my assignment."
)
demo.launch()