Download Appy from Nana71/NanAI_Scribo: direct link, hf CLI and curl.
- Browser
- Download file 882 Bytes
-
https://huggingface.co/Nana71/NanAI_Scribo/resolve/main/Appy
- Command line
-
hf download hf://Nana71/NanAI_Scribo/Appy
-
curl -L -o Appy https://huggingface.co/Nana71/NanAI_Scribo/resolve/main/Appy
882 Bytes
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| # Alegem un model AI open-source gratuit | |
| model_name = "mistralai/Mistral-7B-Instruct" # Poți schimba cu un alt model | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto") | |
| def chat(user_input): | |
| inputs = tokenizer(user_input, return_tensors="pt").to("cuda") | |
| output = model.generate(**inputs, max_length=300) | |
| response = tokenizer.decode(output[0], skip_special_tokens=True) | |
| return response | |
| # Creăm interfața web | |
| iface = gr.Interface( | |
| fn=chat, | |
| inputs=gr.Textbox(lines=5, placeholder="Scrie aici..."), | |
| outputs="text", | |
| title="NanAI Scribo", | |
| description="Chatbot AI specializat în metafizică, filozofie și terapii holistice." | |
| ) | |
| iface.launch() | |