Spaces:
Runtime error
Runtime error
Download app.py from MLEvangelist/Depression_Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/MLEvangelist/Depression_Chatbot/resolve/main/app.py
- Command line
-
hf download hf://spaces/MLEvangelist/Depression_Chatbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MLEvangelist/Depression_Chatbot/resolve/main/app.py
1.14 kB
| # -*- coding: utf-8 -*- | |
| """app.py | |
| Automatically generated by Colaboratory. | |
| Original file is located at | |
| https://colab.research.google.com/drive/1mcXiMSco30xGunxMFqCH3C9C2vqqim9M | |
| """ | |
| import os | |
| import openai | |
| openai.api_key = os.getenv("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") | |
| start_sequence = "\nAI:" | |
| restart_sequence = "\nHuman: " | |
| openai.api_key = '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' | |
| prompt = 'hello bot' | |
| response = openai.Completion.create( | |
| model="text-davinci-003", | |
| prompt=prompt, | |
| temperature=0.9, | |
| max_tokens=150, | |
| top_p=1, | |
| frequency_penalty=0, | |
| presence_penalty=0.6, | |
| stop=[" Human:", " AI:"] | |
| ) | |
| x = response | |
| response = x['choices'][0]['text'] | |
| import gradio as gr | |
| def start(inp): | |
| prompt = inp | |
| response = openai.Completion.create( | |
| model="text-davinci-003", | |
| prompt=prompt, | |
| temperature=0.9, | |
| max_tokens=150, | |
| top_p=1, | |
| frequency_penalty=0, | |
| presence_penalty=0.6, | |
| stop=[" Human:", " AI:"] | |
| ) | |
| x = response | |
| return x['choices'][0]['text'] | |
| iface = gr.Interface(fn=start, inputs='text', outputs='text') | |
| iface.launch(debug=True, share=True) | |