Download app.py from aguyader/Test_Bot: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/aguyader/Test_Bot/resolve/main/app.py
- Command line
-
hf download hf://spaces/aguyader/Test_Bot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/aguyader/Test_Bot/resolve/main/app.py
1.03 kB
| import openai | |
| import gradio as gr | |
| openai.api_key = "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" | |
| messages = [ | |
| {"role": "system", "content": "You are a chatbot that is very happy and kind."}, | |
| ] | |
| def chatbot(input): | |
| if input: | |
| messages.append({"role": "user", "content": input}) | |
| chat = openai.ChatCompletion.create( | |
| model="gpt-3.5-turbo", messages=messages | |
| #model="gpt-4o", messages=messages | |
| ) | |
| reply = chat.choices[0].message.content | |
| messages.append({"role": "assistant", "content": reply}) | |
| return reply | |
| inputs = gr.Textbox(lines=7, label="Chat with AI") | |
| outputs = gr.Textbox(label="Reply_app_1") | |
| gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="The AI Patch & Sparks Chatbot - App 1--- no doc ", | |
| description="Ask anything you want about Patch&Sparks", | |
| theme="compact").launch(share=True) | |