Spaces:
Runtime error
Runtime error
File size: 693 Bytes
8615d58 a42e4a7 aa085f1 0af2cbc aa085f1 8615d58 a42e4a7 aa085f1 a42e4a7 0af2cbc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import os
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
import gradio as gr
model_id = "meta-llama/Llama-3.1-8B-Instruct"
token = os.getenv("kumar")
tokenizer = AutoTokenizer.from_pretrained(model_id, token=token)
model = AutoModelForCausalLM.from_pretrained(model_id, token=token, device_map="auto")
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
def chat_with_llama(prompt):
result = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
return result[0]["generated_text"]
# ❌ DO NOT include share=True here on Spaces
gr.Interface(fn=chat_with_llama, inputs="text", outputs="text", title="Venkat's Chatbot").launch()
|