Spaces:
Runtime error
Runtime error
Download chatbot.py from fgvsdfvdbsfdvsadvf/chatbot: direct link, hf CLI and curl.
- Browser
- Download file 773 Bytes
-
https://huggingface.co/spaces/fgvsdfvdbsfdvsadvf/chatbot/resolve/main/chatbot.py
- Command line
-
hf download hf://spaces/fgvsdfvdbsfdvsadvf/chatbot/chatbot.py
-
curl -L -o chatbot.py https://huggingface.co/spaces/fgvsdfvdbsfdvsadvf/chatbot/resolve/main/chatbot.py
773 Bytes
| 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() |