# import gradio as gr # def greet(name): # return "Hello " + name + "!!" # iface = gr.Interface(fn=greet, inputs="text", outputs="text") # iface.launch() import gradio as gr import torch from transformers import AutoTokenizer, AutoModelForCausalLM # Define the model and tokenizer model_name = "atharvapawar/securix_Llama-2-7B-Chat-GGML" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name) def generate_response(user_input): input_ids = tokenizer.encode(user_input, return_tensors="pt") with torch.no_grad(): output = model.generate(input_ids) response = tokenizer.decode(output[0], skip_special_tokens=True) return response iface = gr.Interface( fn=generate_response, inputs=gr.inputs.Textbox(lines=2, label="Enter your question:"), outputs=gr.outputs.Textbox(label="Generated Response:") ) if __name__ == "__main__": iface.launch()