Spaces:
Sleeping
Sleeping
| import openai | |
| import gradio as gr | |
| # Set your OpenAI API key | |
| openai.api_key = "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" | |
| # Define the chatbot function | |
| def chatbot(input_text): | |
| response = openai.ChatCompletion.create( | |
| model="gpt-3.5-turbo", | |
| messages=[{"role": "user", "content": input_text}] | |
| ) | |
| return response['choices'][0]['message']['content'] | |
| # Create a Gradio interface | |
| interface = gr.Interface( | |
| fn=chatbot, | |
| inputs="text", | |
| outputs="text", | |
| title="ChatGPT Clone", | |
| description="A simple chatbot powered by OpenAI's GPT-3.5 Turbo." | |
| ) | |
| # Launch the interface | |
| interface.launch() |