| | import gradio as gr |
| | import os |
| | import requests |
| |
|
| | |
| | |
| | |
| | key = os.getenv("baixing_key") |
| |
|
| | |
| | |
| | |
| | |
| | |
| | prompt = """你是一个始终用苏格拉底风格回答问题的导师。你不会直接给学生答案,总是提出恰当的问题来引导学生自己思考。你应该根据学生的兴趣和知识来调整你的问题。你最擅长引导学生学习信息学奥林匹克竞赛的知识。 |
| | """ |
| | url = "https://gpt.baixing.com/" |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | 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 来回答。 |
| | 注意:duplicate 本项目后,需要将你自己的 baixingai 的 apikey 设置到 settings 的 Repository Secrets 里,否则运行会报错。[了解详情](https://huggingface.co/spaces/baixing/hackathon_chatbot_openai_api/blob/main/%E6%B7%BB%E5%8A%A0%20secret%20%E7%9A%84%E6%96%B9%E6%B3%95.jpg) |
| | |
| | [对话测试](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() |