Download app.py from flokitech/Alfred: direct link, hf CLI and curl.
- Browser
- Download file 892 Bytes
-
https://huggingface.co/spaces/flokitech/Alfred/resolve/main/app.py
- Command line
-
hf download hf://spaces/flokitech/Alfred/app.py
-
curl -L -o app.py https://huggingface.co/spaces/flokitech/Alfred/resolve/main/app.py
892 Bytes
| import openai | |
| import gradio | |
| import os | |
| openai.api_key = os.environ.get("open_ai_token") | |
| text_file = open("Alfred.txt", "r") | |
| texto = text_file.read() | |
| messages = [{"role": "system", "content":texto}] | |
| def CustomChatGPT(user_input): | |
| messages.append({"role": "user", "content": user_input}) | |
| response = openai.ChatCompletion.create( | |
| model = "gpt-3.5-turbo", | |
| messages = messages, | |
| temperature=0.3 | |
| ) | |
| ChatGPT_reply = response["choices"][0]["message"]["content"] | |
| messages.append({"role": "assistant", "content": ChatGPT_reply}) | |
| return ChatGPT_reply | |
| user_input = gradio.inputs.Textbox(lines=2, placeholder="Como posso te ajudar?", label="Como posso te ajudar?") | |
| output = gradio.outputs.Textbox(label="Resposta:") | |
| demo = gradio.Interface(fn=CustomChatGPT, inputs = user_input, outputs = output, title = "Marina - Evento Páscoa 8/Abril") | |
| demo.launch() |