WesanCZE commited on
Commit
a9bbcbf
·
verified ·
1 Parent(s): 9920573

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
+
4
+ # Načtení modelu
5
+ model_name = "mistralai/Mistral-7B-Instruct-v0.1"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ # Vytvoření AI asistenta
10
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
11
+
12
+ # Funkce pro odpověď AI
13
+ def ai_assistant(prompt):
14
+ response = pipe(prompt, max_length=200, do_sample=True)
15
+ return response[0]['generated_text']
16
+
17
+ # Gradio UI
18
+ iface = gr.Interface(
19
+ fn=ai_assistant,
20
+ inputs="text",
21
+ outputs="text",
22
+ title="AI Asistent",
23
+ description="Zeptej se na cokoli!",
24
+ )
25
+
26
+ # Spuštění aplikace
27
+ iface.launch()