Littendekitten commited on
Commit
8616d85
·
verified ·
1 Parent(s): 7036c68

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Gratis AI-model voor CPU Basic
5
+ chatbot = pipeline(
6
+ "text-generation",
7
+ model="mistralai/Mistral-7B-Instruct-v0.2",
8
+ device_map="auto"
9
+ )
10
+
11
+ # Functie die chatverloop bijhoudt
12
+ def ginger_ai(message, history):
13
+ history = history or []
14
+ prompt = ""
15
+ for h in history:
16
+ prompt += f"User: {h[0]}\nAssistant: {h[1]}\n"
17
+ prompt += f"User: {message}\nAssistant:"
18
+
19
+ result = chatbot(prompt, max_new_tokens=150, do_sample=True, temperature=0.7)
20
+ response = result[0]["generated_text"].split("Assistant:")[-1].strip()
21
+ history.append((message, response))
22
+ return history, history
23
+
24
+ # Gradio chat-interface
25
+ demo = gr.ChatInterface(
26
+ fn=ginger_ai,
27
+ title="GingerAI 🧠",
28
+ description="Je praat met GingerAI — gemaakt door Littendekitten!",
29
+ theme="soft"
30
+ )
31
+
32
+ if __name__ == "__main__":
33
+ demo.launch()