Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| def chat_with_gpt(input_text): | |
| model_name = "gpt-3.5-turbo" # 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() |