Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import os | |
| import requests | |
| # 如果你只打算通过 prompt 来定制机器人的行为,只需要修改这段 prompt 就够了。 | |
| prompt = """请将下述文字改成只用emoji来表达,不要输出任何其它字符 | |
| 然后空两行,给出emoji表达的回复 | |
| ######## | |
| """ | |
| key = os.getenv("baixing_key") | |
| url = "https://gpt.baixing.com/" | |
| # 修改本函数,来实现你自己的 chatbot | |
| # p: 对机器人说话的内容 | |
| # qid: 当前消息的唯一标识。例如 `'bxqid-cManAtRMszw...'`。由平台生成并传递给机器人,以便机器人区分单个问题(写日志、追踪调试、异步回调等)。同步调用可忽略。 | |
| # uid: 用户的唯一标识。例如`'bxuid-Aj8Spso8Xsp...'`。由平台生成并传递给机器人,以便机器人区分用户。可被用于实现多轮对话的功能。 | |
| # 返回值:[type, content] | |
| # 详见 https://huggingface.co/spaces/baixing/hackathon_test/blob/main/bot-api.md | |
| def chat(p, qid, uid): | |
| result = requests.get(url, params={"p": prompt + p, "k": key}).json()['data'] | |
| return ["text", result] | |
| iface = gr.Interface(fn=chat, | |
| inputs=["text", "text", "text"], | |
| outputs=["text", "text"], | |
| description="""这是一个极其简单的示范程序,把你的问话翻译成 emoji 并只用 emoji 来回答。 | |
| [对话测试](https://huggingface.co/spaces/BaixingAI/hackathon_test) [参考文档](https://huggingface.co/spaces/baixing/hackathon_test/blob/main/bot-api.md) [Q & A](https://huggingface.co/spaces/baixing/hackathon_test/blob/main/qna.md) | |
| """ | |
| ) | |
| iface.launch() |