Build a DeepSeek Web Search Application with LangStudio

更新时间:
复制 MD 格式

Build an AI chat application with real-time web search using the IQS Web Search Chat Assistant template in LangStudio. Extend and customize the template for your use case.

Preparations

1. Deploy an LLM model service

Note

This application flow requires an LLM model service. If you already have one that supports the OpenAI API, skip this step.

This example uses a DeepSeek-R1 model deployed via EAS. Deploy from Quick Start > Model Gallery. One-click deployment of DeepSeek-V4 and DeepSeek-R1 models. Model deployment and training.

2. Activate Alibaba Cloud Information Query Service

This application flow uses Alibaba Cloud Information Query Service (IQS) to retrieve web search results.

Activate Alibaba Cloud Information Query Service. New user guide.

Create an LLM service connection

Create an LLM service connection using the EAS service deployed in QuickStart > Model Gallery. Connection configuration.

Go to LangStudio, select your workspace, then on the Connection > Model Service tab, click New Connection to set up a generic LLM model service connection.

Set Model Name to DeepSeek-R1-Distill-Qwen-7B and set Tool Call to Not supported.

Key parameters:

Parameter

Description

Service provider

  • PAI-EAS model service: Select EAS Service, choose the LLM service deployed in 1. Deploy an LLM model service. The base_url and api_key fields auto-fill with the VPC endpoint and token of your deployed LLM.

  • Third-party model service: For example, if using DeepSeek's official service, set base_url to https://api.deepseek.com and obtain the api_key from the DeepSeek website.

Model name

For models deployed via Model Gallery, find the model name on the model's product page in Model Gallery. Create connection – Model service.

Create a runtime (execution environment)

The runtime is a PAI-DSW instance that provides the execution environment for LangStudio application flows.

Important

Create a new runtime as described below, or verify that your existing runtime meets these requirements.

On the Runtime tab, click New Runtime.

In the Create Runtime dialog box, enter a Runtime Name, set Resource Source to Public Resources, choose ecs.g6.xlarge (4 vCPU / 16 GiB) for Resource Specification, and select Public Gateway for Internet Access Gateway.

Key parameters:

  • Runtime Working Path: Must match the application flow's working path. Use your workspace's default storage path.

  • Instance RAM Role: Use a custom role.

    • Default Roles of PAI (not recommended): Requires an api_key for IQS web search over the public network, reducing data security.

    • Custom Roles (recommended): Uses the RAM role below to access IQS via VPC-based RAM authentication—no public network traffic, higher security.

      Create a RAM role

      Follow these steps. Create and authorize a RAM role.

      1. Log on to the Resource Access Management (RAM) console, go to Identities > Role, and on the Role page, click Create Role.

      2. In the top-right corner of the Create Role page, click Switch Editor to open the Script Editor.

      3. Enter the following JSON in the Script Editor. Click OK, enter a role name, and click OK.

        {
          "Statement": [
            {
              "Action": "sts:AssumeRole",
              "Effect": "Allow",
              "Principal": {
                "Service": "pai.aliyuncs.com"
              }
            },
            {
              "Action": "sts:AssumeRole",
              "Effect": "Allow",
              "Principal": {
                "Service": "eas.pai.aliyuncs.com"
              }
            }
          ],
          "Version": "1"
        }
      4. Attach the following access policies to the role: AliyunIQSFullAccess, AliyunOSSFullAccess, and AliyunPAIFullAccess.

Develop the application flow

  1. Go to LangStudio, select your workspace, then on the Application Flow tab, click Create Application Flow.

    • Creation Method: From template.

    • Select template: IQS Web Search Chat Assistant.

    • Select Runtime: Choose the runtime created in Step 2.

    • Working Path: Fills automatically after selecting a runtime.

  2. On the Application Flow tab, click your application flow to open its details page.

    This flow contains four sequential nodes: Start Node (input parameters: chat_history, question) → Alibaba Cloud IQS – Standard SearchLLM NodeEnd Node (output parameter: answer).

    Configure key nodes as follows. Keep other settings at default. Prebuilt component reference.

    • Alibaba Cloud IQS – Standard Search:

      • Time range: Select the time range for search results.

      • IQS connection:

        • If you assigned a RAM role to the runtime in the previous step, no configuration is needed.

        • If the runtime uses the PAI default role, configure an IQS connection. On the Connection tab, choose Custom Connection > New Connection. Set the custom key to api_key. Obtain the value from Information Query Service – Credential Management.

    • LLM Node: Calls a large language model to process natural language queries.

  3. Click Run in the top-right corner to run the flow. For troubleshooting, see FAQ.

    The Run panel on the right shows the interaction result, including user input and the generated response with reference websites.

  4. Click View Traces under the answer to view trace details.

    The waterfall chart shows the call chain: root span chat-pfchen-001 (CHAIN) includes child spans iqs_generic_search (search) and llm (LLM inference), which calls ChatCompletion. Click any span to view its details, including app name, API name, spanId, status code, Attributes, and Resources.

Deploy the application flow

Click Deploy to deploy the flow as an EAS service. Key parameters:

  • Resource Info > Instance Count: Number of service instances. This example uses 1 for testing. In production, use multiple instances for high availability.

  • VPC > Virtual Private Cloud (VPC): IQS depends on Alibaba Cloud Information Query Service. Check Endpoints for regions with VPC access. In unsupported regions, the system falls back to the Zhangjiakou public endpoint. EAS services cannot access the public network by default—configure a VPC with public network access if needed. EAS access to public or private network resources.

  • Role and Permissions > Instance RAM Role: Match the setting used for the runtime instance.

Application flow deployment.

Invoke the service

After deployment, go to PAI-EAS and on the Online Debugging tab, send a request. The key in the request body must match the Start Node's "Dialog Input" field. This example uses the default field question.

Enter sample JSON such as {"question": "What is NVIDIA's stock price?"} and click Send Request. Status Code 200 indicates success. The response body contains the answer.

Other invocation methods including API calls: Application flow deployment – Invoke service.

Clean up resources

  • Stop or delete your runtime after development to avoid charges. Runtime management.

  • If you no longer need the EAS model service:

    • Public resources: Stop or delete the service to prevent ongoing billing.

    • Pay-as-you-go instances: Delete the instances to stop billing.

References