Spaces:
Sleeping
Sleeping
File size: 949 Bytes
8ce7933 ea9d2ed 1129829 ea9d2ed 8ce7933 ea9d2ed 8ce7933 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
from transformers import pipeline
models = ["mistralai/Mixtral-8x7B-Instruct-v0.1", "microsoft/phi-2","meta-llama/Llama-2-7b-chat-hf" ]
def generate_text(prompt, model, max_length, temperature):
pipe = pipeline("text-generation", model=model,trust_remote_code = True)
try:
generated_text = pipe(prompt, max_length=max_length, temperature=temperature)[0]["generated_text"]
return generated_text
except Exception as e:
return f"An error occurred: {str(e)}"
title = "Enter your Prompt"
description = """
# This is multi Model Text Generating Tool
"""
gr.Interface(
generate_text,
[
gr.Textbox(label="Enter your Prompt"),
gr.Dropdown(models, label="choose your Model" ),
gr.Slider(minimum=100, maximum=650, step=50),
gr.Slider(minimum=0.1, maximum=1, step=0.1),
],
outputs="text",
title = title,
description = description
).launch()
|