MCPcopy Create free account
hub / github.com/zai-org/ChatGLM3 / main

Function main

tools_using_demo/cli_demo_tool.py:103–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101
102
103def main():
104 past_key_values, history = None, [system_item]
105 role = "user"
106 global stop_stream
107 print("欢迎使用 ChatGLM3-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
108 while True:
109 query = input("\n用户:") if role == "user" else input("\n结果:")
110 if query.strip() == "stop":
111 break
112 if query.strip() == "clear":
113 past_key_values, history = None, [system_item]
114 role = "user"
115 os.system(clear_command)
116 print("欢迎使用 ChatGLM3-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
117 continue
118 print("\nChatGLM:", end="")
119 response, history = model.chat(tokenizer, query, history=history, role=role)
120 print(response, end="", flush=True)
121 print("")
122 if isinstance(response, dict):
123 role = "observation"
124 else:
125 role = "user"
126
127
128if __name__ == "__main__":

Callers 1

cli_demo_tool.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected