Test-Phi3 / app.py
camanalo1's picture
Update app.py
2697f52 verified
raw
history blame contribute delete
740 Bytes
import gradio as gr
from transformers import pipeline
# Initialize the text generation pipeline
generator = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
# Define the function to generate text based on input prompt
def generate_text(prompt):
# Generate text based on the input prompt
generated_text = generator(prompt, max_length=100, num_return_sequences=1)[0]['generated_text']
return generated_text
# Create Gradio interface
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()