File size: 740 Bytes
797a570
67a004a
9f189d0
67a004a
 
9d34671
67a004a
 
 
2697f52
67a004a
797a570
67a004a
 
 
797a570
67a004a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()