Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline | |
| # Načtení modelu | |
| model_name = "mistralai/Mistral-7B-Instruct-v0.1" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForCausalLM.from_pretrained(model_name) | |
| # Vytvoření AI asistenta | |
| pipe = pipeline("text-generation", model=model, tokenizer=tokenizer) | |
| # Funkce pro odpověď AI | |
| def ai_assistant(prompt): | |
| response = pipe(prompt, max_length=200, do_sample=True) | |
| return response[0]['generated_text'] | |
| # Gradio UI | |
| iface = gr.Interface( | |
| fn=ai_assistant, | |
| inputs="text", | |
| outputs="text", | |
| title="AI Asistent", | |
| description="Zeptej se na cokoli!", | |
| ) | |
| # Spuštění aplikace | |
| iface.launch() |