Spaces:
Runtime error
Runtime error
Download app.py from elitecode/Custom_ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 605 Bytes
-
https://huggingface.co/spaces/elitecode/Custom_ChatBot/resolve/main/app.py
- Command line
-
hf download hf://spaces/elitecode/Custom_ChatBot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/elitecode/Custom_ChatBot/resolve/main/app.py
605 Bytes
| import openai | |
| import gradio as gr | |
| openai.api_key = "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" | |
| messages=[{"role": "system", "content": "You are a Programming Expert"}] | |
| def Custom_GPT(msg): | |
| messages.append({"role": "user", "content": msg}) | |
| completion = openai.ChatCompletion.create(model='gpt-3.5-turbo', messages=messages) | |
| response = completion.choices[0].message.content | |
| messages.append({"role": "system", "content": response}) | |
| return response | |
| demo = gr.Interface(fn=Custom_GPT, inputs="text", outputs="text", title="Coder Chatbot") | |
| demo.launch(share=True) | |