You can quickly create an agent application by using the Alibaba Cloud Model Studio console without coding, and integrate Retrieval-Augmented Generation (RAG) and plug-in capabilities. Then, you can use the application in the console or by API calling. This topic describes how to create and use an agent application.
Why use agent application
Large language models (LLMs) have powerful language understanding and generation capabilities but also limitations, such as:
Cannot answer private domain questions, such as company policies or personnel details.
Cannot access real-time information, such as current weather or sports scores.
Cannot provide accurate answers to specialized questions, such as complex math calculations or image generation.
An agent application overcomes these challenges by leveraging an LLM integrated with tailored external capabilities based on business requirements.
External capabilities refer to functions not inherent to the LLM, such as querying real-time data or answering private domain questions.
You can quickly create an agent application by using the Model Studio console without coding, incorporating external capabilities to address your business needs.
Typical scenarios for agent applications include:
Private domain knowledge Q&A
Prepare your knowledge base file and swiftly create a private domain Q&A application in the console. The application is suitable for queries about company policies, employee information, and more.
Intelligent assistant
Incorporate RAG and custom plug-ins to build an intelligent assistant that boosts work efficiency in tasks such as email management and report writing.
Step 1: Create an agent application
Go to the application creation page
Go to My Applications in the Model Studio console, choose .
Select a model
In the configuration page of the application, click Settings, and choose a model from the Select Model dropdown list. In this example, Qwen-Max is selected.
Configure the parameters. For details, hover over the icon. If you have no specific need, use the default settings.
Test the application
After you select a model, the agent application is ready for use. Enter your query to test it.
Step 2: Expand the capabilities of the application
Expand the functionality of your application on the configuration page by configuring prompt, RAG, and plug-ins.
Guide response direction by prompt
Enter prompt to guide the direction of the response. For example, enter the following prompt:
Please imitate the tone of William Shakespeare.
Input "Hello", and the application returns the following response.
Introduce private domain knowledge by RAG
RAG greatly enhances the Q&A performance in private or vertical domains. You can use the console to integrate RAG into your application.
1. Upload data
Go to Data Management, click Import Data. In this case, Bailian Phones Specifications.docx is used as a sample file. On the Import Data page, select Upload Local File and upload the file.
2. Create a knowledge base
Go to the Knowledge Base Index page. Click Create Knowledge Base.
Enter a Name and Description for the knowledge base. Leave the remaining settings at their default values and click Next Step.
As an example, set the name to Phone Introduction and enter the following description: This knowledge base contains detailed information of Bailian phone products.
Choose Select File, find and select the file you imported. Then, click Next Step.
In the Data Processing section, choose Intelligent Splitting and click Import.
The knowledge base is ready when the Status becomes Parsed.
3. Integrate RAG into the application
Go to My Applications. Click Manage on the card of the application you created.
Enable the Knowledge Base Retrieval Augmentation feature. The system automatically fills the Prompt that directs the model to the knowledge base.
Click Configure Knowledge Base and add Phone Introduction. If you do not have other requirements, use the default options for other settings.
Enter a question in the input box:
I like playing games, which phone do you recommend?
The application can now answer your question based on the provided document.
Currently, agent applications can only generate text content.
Extend capabilities by plug-ins
Plug-ins can enhance the efficiency and professional capabilities of agent applications in your business scenarios. On the configuration page of the application, you can click Select Plug-in and choose one or more plug-ins from the Official Plug-ins list.
For custom plug-ins, see the Plug-in Overview.
Add a plug-in
In this example, add the Python Code Interpreter.
Test the plug-in
Enter Python code.
import matplotlib.pyplot as plt import numpy as np x = np.linspace(-2, 2, 100) y1 = np.sqrt(1 + x**2) y2 = -np.sqrt(1 + x**2) plt.plot(x, y1, label='y = sqrt(1 + x^2)') plt.plot(x, y2, label='y = -sqrt(1 + x^2)') plt.xlabel('x') plt.ylabel('y') plt.title('Hyperbola') plt.legend() plt.show()
With the plug-in, the application can execute Python code and perform visual analytics on data.
Use more plug-ins
You can add up to 10 plug-ins to a single application. The application can select one or more appropriate plug-ins to use based on the input.
Step 3: Publish the application
Publish your application to make it accessible through API. Click Publish in the top-right corner of the configuration page.
If your application has been published before, a dialog box appears to display changes since the last version. Confirm these changes and click Confirm Publish.
The dialog box does not appear when your application is published for the first time.
Use API call
Click Sharing Method to go to the API Call tab. The unique app_id is pre-filled in the code. You only need to replace YOUR_API_KEY
with your API Key to initiate the call.