Skip to content

🔍 Tutorial: Implementing DeepSeek Web Search using Higress #1841

Open
@johnlanni

Description

@johnlanni

Previously, we published an article on Higress supporting DeepSeek web search here, but it lacked a step-by-step guide. This article supplements that, aiming to assist those interested in using this feature.

We will not repeat the installation process for Higress; instead, let's start with an already installed instance of Higress.

Step 0: Configure the DeepSeek API Key

If you did not input the DeepSeek API Key during the installation of Higress, you can configure it here:

Step 1: Configure Search Engine API Domains

First, in the Higress console, configure the domain names of the various search engines by creating service origins:

  • Google Search API domain: customsearch.googleapis.com

  • Bing Search API domain: api.bing.microsoft.com

  • Quark Search API domain: cloud-iqs.aliyuncs.com

  • Arxiv API domain: export.arxiv.org

After configuring, you also need to apply for the corresponding API Keys. For Quark Search's API Key application (Google and Bing are not detailed as there is plenty of online information, and Arxiv is free without needing an API Key):

First, you need an Alibaba Cloud account. Then, search for IQS in the Alibaba Cloud console, enter the IQS console, and generate an API Key:

For more details, refer to the IQS documentation: https://help.aliyun.com/document_detail/2870227.html

Step 2: Configure the AI Search Plugin

For Higress versions before 2.1.0, you need to import the AI Search plugin via custom plugins:

Note the OCI image address for the plugin: higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-search:latest

To ensure you use the latest version of the AI Search plugin, if you prefer a stable version, change the tag to 1.0.0.

Choose the default execution stage, and set the execution priority to any value greater than 100 (this ensures the AI Search plugin executes just before forwarding to the LLM provider, modifying the prompt).

After adding the plugin, configure it accordingly:

Configuration example:

needReference: true # Set to true to include web page reference information in results
promptTemplate: | # You can skip configuring the template if using the built-in one
  # The following content is based on search results from the user-submitted query:
  {search_results}
  In the search results I provide, each result is formatted as [webpage X begin]...[webpage X end], where X represents the index number of each article. Please cite the context at the end of the sentences where appropriate. Use a format of citation number] in the answer for corresponding parts. If a sentence is derived from multiple contexts, list all relevant citation numbers, such as [3][5], and ensure not to cluster the citations at the end; instead, list them in the corresponding parts of the answer.
  When responding, please pay attention to the following:
  - Today’s date in Beijing time is: {cur_date}.
  - Not all content from the search results is closely related to the user's question. Discern and filter the search results based on the question.
  - For listing-type questions (e.g., listing all flight information), try to keep the answer within 10 points and inform the user they can check the search source for complete information. Prioritize providing the most comprehensive and relevant information; do not volunteer information missing from the search results unless necessary.
  - For creative questions (e.g., writing a paper), cite relevant references within the body paragraphs, such as [3][5], rather than only at the end of the article. Interpret and summarize the user's topic requirements, choose the appropriate format, fully utilize search results, extract crucial information, and generate answers that meet user requirements, with deep thought, creativity, and professionalism. Extend the length of your creation as much as possible, hypothesize the user's intent for each point, providing as many angles as possible, ensuring substantial information and detailed discussion.
  - If the response is lengthy, structure the summary into paragraphs. If responding with points, try to keep it within 5 points and consolidate related content.
  - For objective Q&A, if the answer is very short, add one or two related sentences to enrich the content.
  - Choose a suitable and aesthetically pleasing response format based on the user’s requirements and answer content to ensure high readability.
  - Your answers should synthesize multiple relevant web pages to respond and should not repeatedly quote a single web page.
  - Unless the user requests otherwise, respond in the same language the question was asked.
   # The user’s message is:
  {question}
searchFrom: # Below is a list of configured search engine options; only configure the ones you need
- type: quark
  apiKey: "your-quark-api-key" # 👈 Replace with your key
  serviceName: "quark.dns"
  servicePort: 443
- type: google
  apiKey: "your-google-api-key" # 👈 Replace with your key
  cx: "your-search-engine-id" # 👈 Replace with your engine id
  serviceName: "google.dns"
  servicePort: 443
- type: bing
  apiKey: "bing-key" # 👈 Replace with your key
  serviceName: "bing.dns"
  servicePort: 443
- type: arxiv
  serviceName: "arxiv.dns"
  servicePort: 443
searchRewrite:
  llmApiKey: "your-deepseek-api-key" # 👈 Replace with your key
  llmModelName: "deepseek-chat"
  llmServiceName: "llm-deepseek.internal.dns"
  llmServicePort: 443
  llmUrl: "https://api.deepseek.com/chat/completions"

Step 3: Test Direct Requests

Below is the effect of integrating lobechat with Higress:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions