File size: 679 Bytes
4dae327
084d1ba
4dae327
86db4a4
73b8458
 
86db4a4
73b8458
 
4dae327
084d1ba
86db4a4
73b8458
 
86db4a4
 
73b8458
 
084d1ba
4dae327
084d1ba
 
 
 
4dae327
 
084d1ba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()