|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
generator = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True) |
|
|
|
|
|
def generate_text(prompt): |
|
|
|
generated_text = generator(prompt, max_length=100, num_return_sequences=1)[0]['generated_text'] |
|
return generated_text |
|
|
|
|
|
prompt_input = gr.Textbox(lines=5, label="Input Prompt") |
|
output_text = gr.Textbox(label="Generated Text") |
|
|
|
gr.Interface(generate_text, prompt_input, output_text, title="Conversational AI", description="Engage in conversation with our AI.").launch() |
|
|