Download app.py from weeeeewew/chatbot: direct link, hf CLI and curl.
- Browser
- Download file 481 Bytes
-
https://huggingface.co/spaces/weeeeewew/chatbot/resolve/main/app.py
- Command line
-
hf download hf://spaces/weeeeewew/chatbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/weeeeewew/chatbot/resolve/main/app.py
481 Bytes
| import requests,json | |
| import gradio as gr | |
| def chat(prompt): | |
| url = "https://api.forchange.cn/" | |
| length = len(prompt) | |
| data = {'prompt':prompt, 'tokensLength': length} | |
| text = requests.post(url, json=data).text | |
| text = json.loads(text) | |
| text = text['choices'][0]['text'] | |
| return text | |
| def to_black(text): | |
| return chat(text).strip('啊').strip('?').strip('!').strip('\n\n') | |
| interface = gr.Interface(fn=to_black, inputs="text", outputs="text") | |
| interface.launch() |