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