File size: 724 Bytes
48e1709
86d8051
48e1709
86d8051
f1dc173
86d8051
0870e71
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 = "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()