File size: 895 Bytes
e627d09
4a9b043
8616d85
ab298f8
8616d85
 
ab298f8
8616d85
 
ab298f8
8616d85
 
 
 
 
 
 
e627d09
8616d85
 
 
 
4a9b043
8616d85
 
e627d09
 
8616d85
 
 
 
 
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
29
30
31
32
import gradio as gr
from transformers import pipeline

# Kies een CPU-vriendelijk model (1B parameters)
chatbot = pipeline(
    "text-generation",
    model="TheBloke/guanaco-1B-HF",  # werkt op CPU
)

# Functie die chatverloop bijhoudt
def ginger_ai(message, history):
    history = history or []
    prompt = ""
    for h in history:
        prompt += f"User: {h[0]}\nAssistant: {h[1]}\n"
    prompt += f"User: {message}\nAssistant:"

    result = chatbot(prompt, max_new_tokens=150, do_sample=True, temperature=0.7)
    response = result[0]["generated_text"].split("Assistant:")[-1].strip()
    history.append((message, response))
    return history, history

# Gradio chat-interface
demo = gr.ChatInterface(
    fn=ginger_ai,
    title="GingerAI 🧠",
    description="Je praat met GingerAI — gemaakt door Littendekitten!",
    theme="soft"
)

if __name__ == "__main__":
    demo.launch()