File size: 983 Bytes
f4fac26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

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()