File size: 677 Bytes
5343c19
a47f135
5343c19
3719dc9
a47f135
3719dc9
 
 
 
 
 
5343c19
a47f135
0381361
a47f135
 
 
5343c19
a47f135
 
3719dc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer

# Ensure the correct model path
model_name = "QuantFactory/Meta-Llama-3-8B-Instruct-GGUF"

try:
    model = AutoModelForCausalLM.from_pretrained(model_name)
    tokenizer = AutoTokenizer.from_pretrained(model_name)
except OSError as e:
    print(f"Error loading the model: {e}")

def generate_response(prompt):
    inputs = AutoTokenizer(prompt, return_tensors="pt")
    outputs = model.generate(**inputs)
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return response

interface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
interface.launch()