chatbot / app.py
weeeeewew's picture
Rename myapp.py to app.py
aa9829f
Raw History Blame Contribute Delete
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()