Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import platform | |
| import os | |
| import time | |
| from threading import Thread | |
| from rich.text import Text | |
| from rich.live import Live | |
| from model.infer import ChatBot | |
| from config import InferConfig | |
| infer_config = InferConfig() | |
| chat_bot = ChatBot(infer_config=infer_config) | |
| # streamer = chat_bot.chat("你好") | |
| # print(streamer) | |
| # streamer = chat_bot.stream_chat("你好") | |
| # welcome_txt = '欢迎使用ChatBot,输入`exit`退出,输入`cls`清屏。\n' | |
| # def build_prompt(history: list[list[str]]) -> str: | |
| # prompt = welcome_txt | |
| # for query, response in history: | |
| # prompt += '\n\033[0;33;40m用户:\033[0m{}'.format(query) | |
| # prompt += '\n\033[0;32;40mChatBot:\033[0m\n{}\n'.format(response) | |
| # return prompt | |
| # print(build_prompt(streamer)) | |
| def greet(name): | |
| streamer = chat_bot.chat("你好") | |
| return streamer | |
| # return "Hello " + name + "!!" | |
| iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| iface.launch() | |