Spaces:
Sleeping
Sleeping
| 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() | |