ZHIPU AI
This notebook shows how to use ZHIPU AI API in LangChain with the langchain.chat_models.ChatZhipuAI.
GLM-4 is a multi-lingual large language model aligned with human intent, featuring capabilities in Q&A, multi-turn dialogue, and code generation. The overall performance of the new generation base model GLM-4 has been significantly improved compared to the previous generation, supporting longer contexts; Stronger multimodality; Support faster inference speed, more concurrency, greatly reducing inference costs; Meanwhile, GLM-4 enhances the capabilities of intelligent agents.
Getting started
Installation
First, ensure the zhipuai package is installed in your Python environment. Run the following command:
#!pip install --upgrade httpx httpx-sse PyJWT
Importing the Required Modules
After installation, import the necessary modules to your Python script:
from langchain_community.chat_models import ChatZhipuAI
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
Setting Up Your API Key
Sign in to ZHIPU AI for the an API Key to access our models.
import os
os.environ["ZHIPUAI_API_KEY"] = "zhipuai_api_key"