File size: 719 Bytes
48e1709
86d8051
48e1709
86d8051
28fd333
86d8051
28fd333
86d8051
48e1709
86d8051
 
 
48e1709
86d8051
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from transformers import pipeline

def chat_with_gpt(input_text):
    model_name = "openai-gpt" # Replace this with the appropriate GPT model you want to use.
    chat_gpt = pipeline("text-generation", model=model_name, device=0)
    generated_text = chat_gpt(input_text, max_length=150, do_sample=True, top_k=50, top_p=0.95)
    return generated_text[0]["generated_text"]

# Gradio user interface
input_text = gr.inputs.Textbox(lines=5, label="Your question about AI:")
output_text = gr.outputs.Textbox(label="ChatGPT Response:")

iface = gr.Interface(fn=chat_with_gpt, inputs=input_text, outputs=output_text, title="Chat with ChatGPT", description="Ask ChatGPT questions about AI.")
iface.launch()