File size: 481 Bytes
7b1f97b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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() |