import os import gradio as gr os.system( 'pip install --upgrade torch' ) os.system( 'pip install "modelscope" --upgrade -f https://pypi.org/project/modelscope/' ) os.system('pip install transformers -U') from modelscope.pipelines import pipeline from modelscope.utils.constant import Tasks pipe = pipeline(task=Tasks.chat, model='ZhipuAI/chatglm2-6b', model_revision='v1.0.2',device_map='auto') def clear_session(): return '', None def predict(input, history=None): dictionary = { 'prmpt': input } print(dictionary) if history is None: history = [] inputs = inputs = {'text': input, 'history': history} result = pipe(inputs) history = result['history'] return '', history, history block = gr.Blocks() with block as demo: gr.Markdown("""