ERNIE SDK



In some complex scenarios, we need to flexibly call the LLM and a series of required tools based on user input. Agents provide the possibility for the implementation of such applications. ERNIE SDK offers Agent development driven by the Function Calling capabilities of the Wenxin large model, allowing developers to directly use pre-built Agents and instantiate them through Chat Model, Tool, and Memory, or customize their own Agents by inheriting from the erniebot_agent.agents.Agent base class.

The Chat Model module in ERNIE SDK is the core scheduler for decision-making, which is the knowledge-enhanced large language model developed by Baidu: the Wenxin large model.



This module standardizes user input and the feedback messages from the Wenxin large model to facilitate storage in the subsequent Memory module.

The large language model itself does not have memory, so an important aspect of building large model applications is to give the Agent memory functionality. ERNIE SDK provides fast memory capabilities, allowing information from multiple rounds of dialogue to be stored in a List and then transferred to the context window of the Chat Model. However, this memory mode is also limited by the input tokens of the Wenxin large model. Meanwhile, ERNIE SDK also allows developers to build more complex memory modules, with reference processing methods including:
1. Vector store-backed memory; each Message from a dialogue round will be stored in a vector database after embedding processing, allowing for semantic vector approximate retrieval to find the most relevant memory fragments based on the user’s natural language input in subsequent dialogue contexts. This approach enables long-term memory, no longer limited by the context window of the Wenxin large model.
2. Conversation summary memory; this processing method summarizes the dialogue information after each round of dialogue using the Chat Model and stores the summarized brief content to relieve the pressure of storage content.
3. LangChain/LlamaIndex; enabling custom memory modules, ERNIE SDK allows developers to freely integrate frameworks like LlamaIndex to implement more complex memory modules, leveraging LlamaIndex’s excellent document retrieval capabilities for long-term memory.

Allowing Agents to autonomously combine and use complex external tools to solve more complex problems is key to the widespread adoption of future AI applications; ERNIE SDK allows developers to quickly build complex applications using over 30 tools already launched by the PaddlePaddle community and also enables customization of local tools based on their business needs.

Although general large models absorb extensive knowledge during training, they have limited understanding of domain-specific or proprietary business knowledge. The cost of fine-tuning large models with specific domain data is prohibitively high, hence the introduction of RAG (Retrieval Augmented Generation) technology, which aims to rapidly integrate external knowledge bases into large models, thus gaining a deeper understanding of specialized knowledge in specific fields. Key functions of the Retrieval module include:
-
Loading data sources, covering various data types: Structured data, such as SQL and Excel
Unstructured data, such as PDF and PPT documents
Semi-structured data, such as Notion documents
-
Chunk transformation of data. -
Vector embedding processing of data. -
Storing processed data in a vector database. -
Quickly locating relevant information through approximate vector retrieval. The Retrieval module of ERNIE SDK not only supports Baidu’s Wenxin Baizhong search but is also compatible with the Retrieval components of LangChain and LlamaIndex, significantly improving the efficiency and accuracy of data processing.

Now, let’s quickly understand how to develop an Agent— a manuscript review assistant. The main function of this Agent is to help us review whether the manuscripts published on various platforms comply with regulations.
Step one, log in to the PaddlePaddle community and create a new personal project. The free computing resources provided by the community are sufficient.

To securely manage your sensitive token information, we recommend using Dotenv. First, install Dotenv, then save your token in a newly created .env file. Note that this file is not visible by default in the file directory; if you need to view it, you must change the settings.

Example .env file content:

Step three, verify whether your access token can be used normally:

If everything is normal, it will print out your access token. Create a new text file named manuscript.txt, which should contain the text you want to audit for compliance.

Step four, build the basic Agent (using the pre-built tools provided by the PaddlePaddle community tool center).

Run this code, and you will see the Agent using the [text-moderation/v1.2/text_moderation] tool to review the manuscript content and output the review results. Thus, the development of a simple manuscript review assistant Agent is completed. Together, we experienced the rapid development process and practicality of Agents based on ERNIE SDK.

After deeply exploring ERNIE SDK, let’s take a look at the multi-tool intelligent orchestration feature of the PaddlePaddle community. The PaddlePaddle community not only provides a fine-grained SDK to support the detailed needs of technical developers but also introduces the multi-tool intelligent orchestration feature. This means developers can easily integrate various external tools based on the powerful Wenxin large model to create personalized AI applications. Compared to using ERNIE SDK alone, this method is faster and more convenient, greatly simplifying the development process. We will use multi-tool intelligent orchestration to reproduce the manuscript review assistant.
First, create the application using low-code development and select intelligent orchestration.

Second, click to mount the “Text Review Tool” in the sidebar tool mounting section, which is one of the more than 30 pre-built tools provided by the PaddlePaddle community tool center. You can also create your own tools.

Then, set the role identity for the manuscript assistant in the basic settings. After that, click to apply all settings, and you can experience it in the sidebar.
It is worth mentioning that the multi-tool intelligent orchestration of the PaddlePaddle community is extremely friendly to team members without a technical background. Even without in-depth programming knowledge, team members can quickly get started and easily build their own AI applications. For example, the creation of the above manuscript assistant only takes a few minutes, which not only accelerates product iteration speed but also promotes collaboration and innovation within the team.
Currently, Baidu PaddlePaddle has opened applications. Visit the PaddlePaddle community for invitation testing registration to learn more details and apply for use.
With the development of general large language models and the rise of intelligent Agent technology, we are ushering in a new era of AI application development. From the in-depth exploration of ERNIE SDK to the application of multi-tool intelligent orchestration in the PaddlePaddle community, we see how AI technology frameworks like Baidu PaddlePaddle ERNIE SDK break traditional boundaries, providing developers with unprecedented convenience and enormous developmental potential. Whether developers with a strong technical background or non-technical personnel, everyone can find their space in this new era, jointly promoting the advancement of AI technology and the popularization of AI applications. The future of AI is full of infinite potential. The vast world of AI applications awaits us to explore and create.
Related Links
Multi-tool intelligent orchestration invitation testing registration:https://aistudio.baidu.com/activitydetail/1503017298




