| |
|
|
| import gradio as gr |
| from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline |
| import torch |
|
|
| |
| model_path = "Athagi/Agillm-v2" |
| tokenizer = AutoTokenizer.from_pretrained(model_path) |
| model = AutoModelForCausalLM.from_pretrained(model_path) |
|
|
| |
| chatbot = pipeline("text-generation", model=model, tokenizer=tokenizer, device=0 if torch.cuda.is_available() else -1) |
|
|
| |
| def chat_with_model(user_input): |
| response = chatbot(user_input, max_length=200, do_sample=True, temperature=0.7) |
| return response[0]['generated_text'] |
|
|
| |
| interface = gr.Interface( |
| fn=chat_with_model, |
| inputs="text", |
| outputs="text", |
| title="Chat with Agillm-v2", |
| description="Type a message and interact with the Agillm-v2 model.", |
| theme="huggingface" |
| ) |
|
|
| |
| interface.launch() |