import gradio as gr from transformers import pipeline def chat_with_gpt(input_text): model_name = "text-davinci-003" # 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=1000, do_sample=True, top_k=500, top_p=1) 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()