Spaces:
Sleeping
Sleeping
File size: 616 Bytes
e8f3051 66e4d07 e8f3051 66e4d07 d06aa40 e8f3051 3549293 d06aa40 3549293 46e9920 3b70afc e8f3051 3549293 e8f3051 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import pipeline
import os
access_token = os.getenv("Token")
pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct", token=access_token)
def predict(query):
messages = []
messages.append({"role": "system","content": "you are a helpful assistant"})
messages.append({"role": "user","content": query})
return pipe(messages,max_new_tokens=256)[0]["generated_text"][-1]['content']
gradio_app = gr.Interface(
predict,
inputs="text", outputs="text",
title="Llama-3.2-1B-Instruct",
)
if __name__ == "__main__":
gradio_app.launch() |