ChatGLM-6B and ChatGLM2-6B has the same api specs, so this example should work with both.from langchain.llms import ChatGLMfrom langchain.prompts import PromptTemplatefrom langchain.chains import LLMChain# import ostemplate = """{question}"""prompt = PromptTemplate(template=template, input_variables=["question"])# default endpoint_url for a local deployed ChatGLM api serverendpoint_url = "http://127.0.0.1:8000"# direct access endpoint in a proxied environment# os.environ['NO_PROXY'] = '127.0.0.1'llm = ChatGLM(    endpoint_url=endpoint_url,    max_token=80000,    history=[["æˆ‘å°†ä»�ç¾�å›½åˆ°ä¸­å›½æ�¥æ—…æ¸¸ï¼Œå‡ºè¡Œå‰�å¸Œæœ›äº†è§£ä¸­å›½çš„åŸ�å¸‚", "æ¬¢è¿�é—®æˆ‘ä»»ä½•é—®é¢˜ã€‚"]],    top_p=0.9,    model_kwargs={"sample_model_args": False},)# turn on with_history only when you want the LLM object to keep track of the conversation history# and send the accumulated context to the backend model api, which make it stateful. By default it is stateless.# llm.with_history = Truellm_chain = LLMChain(prompt=prompt, llm=llm)question = "åŒ—äº¬å’Œä¸Šæµ·ä¸¤åº§åŸ�å¸‚æœ‰ä»€ä¹ˆä¸�å�Œï¼Ÿ"llm_chain.run(question)    ChatGLM payload: {'prompt': 'åŒ—äº¬å’Œä¸Šæµ·ä¸¤åº§åŸ�å¸‚æœ‰ä»€ä¹ˆä¸�å�Œï¼Ÿ', 'temperature': 0.1, 'history': [['æˆ‘å°†ä»�ç¾�å›½åˆ°ä¸­å›½æ�¥æ—…æ¸¸ï¼Œå‡ºè¡Œå‰�å¸Œæœ›äº†è§£ä¸­å›½çš„åŸ�å¸‚', 'æ¬¢è¿�é—®æˆ‘ä»»ä½•é—®é¢˜ã€‚']], 'max_length': 80000, 'top_p': 0.9, 'sample_model_args': False}
ChatGLM-6B is an open bilingual language model based on General Language Model (GLM) framework, with 6.2 billion parameters. With the quantization technique, users can deploy locally on consumer-grade graphics cards (only 6GB of GPU memory is required at the INT4 quantization level).
ChatGLM-6B is an open bilingual language model based on General Language Model (GLM) framework, with 6.2 billion parameters. With the quantization technique, users can deploy locally on consumer-grade graphics cards (only 6GB of GPU memory is required at the INT4 quantization level). ->: ChatGLM-6B and ChatGLM2-6B has the same api specs, so this example should work with both.from langchain.llms import ChatGLMfrom langchain.prompts import PromptTemplatefrom langchain.chains import LLMChain# import ostemplate = """{question}"""prompt = PromptTemplate(template=template, input_variables=["question"])# default endpoint_url for a local deployed ChatGLM api serverendpoint_url = "http://127.0.0.1:8000"# direct access endpoint in a proxied environment# os.environ['NO_PROXY'] = '127.0.0.1'llm = ChatGLM(    endpoint_url=endpoint_url,    max_token=80000,    history=[["æˆ‘å°†ä»�ç¾�å›½åˆ°ä¸­å›½æ�¥æ—…æ¸¸ï¼Œå‡ºè¡Œå‰�å¸Œæœ›äº†è§£ä¸­å›½çš„åŸ�å¸‚", "æ¬¢è¿�é—®æˆ‘ä»»ä½•é—®é¢˜ã€‚"]],    top_p=0.9,    model_kwargs={"sample_model_args": False},)# turn on with_history only when you want the LLM object to keep track of the conversation history# and send the accumulated context to the backend model api, which make it stateful. By default it is stateless.# llm.with_history = Truellm_chain = LLMChain(prompt=prompt, llm=llm)question = "åŒ—äº¬å’Œä¸Šæµ·ä¸¤åº§åŸ�å¸‚æœ‰ä»€ä¹ˆä¸�å�Œï¼Ÿ"llm_chain.run(question)    ChatGLM payload: {'prompt': 'åŒ—äº¬å’Œä¸Šæµ·ä¸¤åº§åŸ�å¸‚æœ‰ä»€ä¹ˆä¸�å�Œï¼Ÿ', 'temperature': 0.1, 'history': [['æˆ‘å°†ä»�ç¾�å›½åˆ°ä¸­å›½æ�¥æ—…æ¸¸ï¼Œå‡ºè¡Œå‰�å¸Œæœ›äº†è§£ä¸­å›½çš„åŸ�å¸‚', 'æ¬¢è¿�é—®æˆ‘ä»»ä½•é—®é¢˜ã€‚']], 'max_length': 80000, 'top_p': 0.9, 'sample_model_args': False}