AI Personal Learning
and practical guidance

Realization of local/API knowledge base based on DeepSeek-R1 with access to WeChat BOT

In the previous article, "TheLocal Deployment DeepSeek-R1 and WeChat Bot Access TutorialsToday, I'd like to share with you a more interesting way to play: how to feed our AI assistant some dry stuff, so that it can turn into a professional consultant who really knows what it's doing!

 


Next I will take you by hand to complete the entire knowledge base building process, including environment configuration, knowledge base deployment, uploading information, and some details of the tuning tips. Finally, we will put this "full of knowledge" AI into the WeChat robot, to create a truly understand you, understand the industry's intelligent assistant!

First of all, let's see the result, this is the result after I uploaded a "human body injury degree of disability classification" information inquiry:

 

DeepSeek-R1 deployment

DeepSeek There are two ways of deployment, one is local deployment and the other is accessing third-party APIs.

Pros and cons of both:

  • local deployment
    ✅ Advantages: fully private data, low long-term cost, fast response time
    ❌ Cons: eats local arithmetic, requires a more configurable machine
  • API call
    ✅ Benefits: fast access, maintenance-free, resilient scaling
    ❌ Disadvantages: data needs to be transmitted to a third party, long-term costs are uncontrollable

Local DeepSeek

First you need to make sure that you have installed ollama and ollama is functioning properly.

DeepSeekAPI

I was actually going to write this post only about the local deployment approach .....

However, since the web version of DeepSeek has been "on strike" lately, I was forced to try the local version of ChatBox I didn't expect to experience a full-blooded version of R1, and it was a blast! I think this program also smells good, so I'll write in the API way by the way.

Here I provide two platforms for you to access of your choice.

First we need to get the APIkey, and subsequently we need to populate the knowledge base configuration with the APIkey.

 

volcanic ark

official website
https://console.volcengine.com/ark

prices

Input: ¥2/M Tokens

Output: ¥8/M Tokens

entryAPIKey ManagementCreateAPIkey

New secret key, copy APIkey

Silicon-based flow

Silicon-based flow official website

https://cloud.siliconflow.cn/account/ak

prices

Input: ¥4/M Tokens

Output: ¥16/M Tokens

Go to the left side of theAPI Secret KeyClickNew secret keypost-copying secret key

 

repository

Knowledge base installation

Next we need to access the knowledge base, here we use theAnythingLLMThe program.

 

AnythingLLM is an open source Large Language Model (LLM) application framework designed to help users easily build and deploy intelligent Q&A, document analysis, and other applications based on private data.

Go to the AnythingLLM website and download the installer.

https://anythingllm.com/

Run the installer, in between it will download additional dependencies required (GPU, NPG support)

If the download fails, or if you close this download window and skip this step, AnythingLLM will still install successfully.

Don't worry at this time, you can do the installation manually.

The web link has alibZip.

Extract the zip archive and place the extracted folder into theYour installation directory AnythingLLMresourcesollamaInside the catalog.

Knowledge base configuration

After the installation is complete, enter the AnythingLLM interface, where you need to select a default large model.

local configuration

If you're using a local deployment of DeepSeek, scroll down to find theOllamaJust choose.

API Configuration

If you are using a third-party API, this step does not need to be selectedollamaFind it down here.Generic OpenAI

Generic OpenAI:

 

Connect to any service compatible with the OpenAI interface format through a customized configuration.

Here you need to fill in 5 parameters

Use the silicone-based flow API:

BaseURLrequest address

https://api.siliconflow.cn/v1

APIkeyAPI secret key, fill in the one you just got.

ChatModelNameModel name

Pro/deepseek-ai/DeepSeek-R1

Token context window(context window)

4096

Max Tokens(Maximum number of tokens)

4096 or 8192 depending on your situation.

Use the Volcano Ark API:

BaseURLrequest address

https://ark.cn-beijing.volces.com/api/v3

APIkeyAPI secret key, fill in the one you just got.

ChatModelNameModel name

Here is special, Volcano Ark model name needs to be filled with access point ID. we need to go to the platform to create the access point.

Start by turning on DeepSeekR1 service first

Coming to Online Reasoning - Creating Access Points

Confirmation of access

This ID is the access point ID, just fill in this value.

Token context window(context window)

4096

Max Tokens(Maximum number of tokens)

4096 or 8192 depending on your situation.

Once the above settings are complete, don't forget to tapSaveChanageSave.

Workspace creation

The next step into this privacy interface, is to tell you how to save data, how to use those instructions, anyway, are all platitudes, directly skip the next step can be

This step is the welcome screen, nothing special, just skip it!

Create a name for the workspace. It's recommended that you use English, because it will come in handy if you want to use the API to call it later.

Now enter AnythingLLM The main interface of the game is now up. It will teach you how to play with a sample dialog

Click on the workspace we just named on the left to enter a new dialog.

Here's a simple dialog to test if the model call was successful.

Workspace Setup

Click the Setup button on the right side of the workspace to enter the Setup interface.

Go to the chat settings, where we can tweak the model in detail

Here is where you adjust the large model currently in use. The default is to use the one set by the system, which was set earlierollama

You can also choose other local big models or API services.

The mode is divided into chat and query, query means only use the query context function (you need to have your own uploaded documents), chat means use the chat function + query

Number of contexts

You can understand that it is a persona prompt word, and you can modify it to Chinese or keep it as default.

Feeding information

Next, you need to feed the knowledge base, click on the workspace next to theUpload button

Access to the Knowledge Base Management interface

Supports batch uploading, supports Excel, world, txt and other file formats. Here I uploaded aClassification of Degrees of Disability in Human Injury.pdfThe

Select the file and clickMove to WorkSpaceThis step adds files from the temporary area to the workspace.

You can see the uploaded files transferred to the right, here click on theSace and EmbedMake a save.

Tips belowWorkSpace updated successfullyIndicates a successful save.

Here you need to clickPin to workspaceThis button.

Pin to workspace::

 

If, when using AnythingLLM, you find that you are not getting satisfactory answers by default, you can improve the quality of your answers by pinning documents. This is a quick way to improve the accuracy and relevance of your answers.

Simply put, document pinning is the process of "feeding" the content of a document directly to the language model so that it can refer to that content when answering a question and provide a better answer.

Then we go back to the Conversations page, create a new conversation, ask a question, and verify that the knowledge base was added successfully.

error resolution

You can see that DeepSeek has answered the question in conjunction with the uploaded information, but there are errors in the answer.

For example, the first question:

Ask:

 

What is the grade for two broken ribs?

Answer:

 

Based on the contextual information provided, the Human Injury Disability Classification Standards for rib fractures are as follows:

Serious Injury Grade 2: Fracture of more than four ribs or more than two ribs with paradoxical movement;

Minor injuries of the first degree: fractures of the first to third ribs.

In the case of a two rib fracture that is not accompanied by paradoxical activity or other serious conditions (e.g., more than four), it is classified as a minor first-degree injury. Thus, two rib fractures are graded:

minor injuries (first degree)

However, this is in the uploaded file, two broken ribs are classified as a minor second degree injury. This is a rather serious error for an application in legal advice.

There is no need to rush when it comes to this kind of inability to answer questions, let's troubleshoot the cause.

I took a closer look at the uploaded PDF file and realized that it contained a lot of tables, special formatting, and a whole lot of unused content. These "impurities" affect the AI's ability to understand what we really want it to learn.

All this cluttered formatting can prevent the AI from getting to the point, like when we see a messy book, so I reorganized the key content into a concise Word document, deleted the unused content, and then re-fed it to the AI.

An excerpt from the contents of the organized document:

5.6.4 Minor Injury Grade 2
b) Fracture of ribs in 2 or more places.
c) Sternum fracture; clavicle fracture; scapula fracture.
d) Dislocation of the sternoclavicular joint; dislocation of the acromioclavicular joint.
e) Chest injury resulting in subcutaneous emphysema that is not self-absorbed for 1 week.
f) Hematochezia of the thoracic cavity; pneumothorax.
g) Chest wall penetrating trauma.
h) Chest compression with signs of asphyxia.
5.6.5 Minor injuries
a) Fractured ribs; fractured costal cartilage.
5.7 Abdominal injuries
5.7. 1 Serious injury grade I
a) Impaired liver function (severe).
b) Gastrointestinal injury resulting in severe impairment of digestion and absorption and dependence on parenteral nutrition.
c) Renal insufficiency (uremic stage).

Tried the question again and this time the answer was much more accurate!

This is just the simplest solution. If you want AI to answer more accurately, you can also try adjusting the document format, optimizing the search method, adjusting the AI parameters, and so on. But we'll talk about these advanced plays later.

 

Access to WeChat BOT

Get AnythingLLM secret key

show (a ticket)AnythingLLMinterface, go to Settings - API Secret Key - Generate New API Secret Key

Using the Integration Pack

I've putAnythingLLMinterface toNGCBOTin and made into an integrated package.

Unzip the netbook link in theNGCBOT_LLM.zipzip file, double-click on theLauncher.exeReady to run.

There are three things you need to do before using it!

There are three things you need to do before using it!

There are three things you need to do before using it!

First, make sure that your integration package directory does not have Chinese, there is Chinese must report errors!

correct demonstration

F:AIAIpackageNGCBot

false demonstration

F:WeChat BOTAIpackageNGCBot

Second, install the specified version of WeChat.

There is a microsoft version in the web link

WeChatSetup-3.9.10.27.exe

Install this version, the computer originally had microsoft do not need to delete, directly override the installation.

Third, modify the NGCBOT configuration file.

require a thorough understanding ofConfigConfig.yamlThe configuration file can be modified.

There are three changes to the configuration file

1. Modify the super administrator configuration.

Here fill in the ID of the micro-signal you set up, remember to always change it! Otherwise it's all sent to me ....

How do I get this ID? Use the microsignal you want to set as administrator, send a message to the bot, then you can see the id of the person who sent the message in the console.

2. Modify the ai priority configuration.

Here is the order in which the ai interfaces are executed, the smaller the number in front means the execution is prioritized. The default setting is AnythingLLM priority.

3. AnythingLLM configuration.

Here you need to change theworkspace,AnythingLLMkeyThese two values are just fine.

workspaceFill in the name of the workspace you AnythingLLM created, it's the lowercase one.

AnythingLLMkeyFill in the secret key you get in AnythingLLM. Not the secret key from Silicon Flow or the one from Volcano Ark!

Remember to leave the Bearer in front of it.

After following the above steps to make changes, double-click theLauncher.exeThen you can have fun!

Integration pack acquisition is at the end of the article.

Congratulations! Anyone who sees this is 👍🏻👍🏻

If you just want to get started playing with knowledge base bots quickly, see here.

Here's what's written for the little ones who want to delve deeper into it

  • How to Call AnythingLLM Interface
  • How to Extend NGCBOT Functionality

Read on if you're interested

 

development and expansion

interface call

 

This step is suitable for those who want to expand their development and research, if you are a beginner and want to play the integration pack directly, please skip this step.

OK, let's get a little more advanced. Browser inputs[http://localhost:3001/api/docs/](http://localhost:3001/api/docs/)Go to the API page.

Here, since the original official API documentation cannot be accessed on the web, it has been changed to local access to the API documentation.

After entering the API description page, you can see that there are various interfaces here. And it supports debugging directly on this page.

Before we can start accessing it, we need to authorize the secret key by clicking on theAuthorizeThe

Paste AnythingLLMAPI secret key into the open interface, the authorization is successful!

Then go down and find/v1/workspace/{slug}/chatThis API

Parameter description

parameters clarification note
slug workspace Reject Chinese characters, uppercase and other special characters, lowercase only
message Message The message you want to send
mode paradigm The schema is divided into chat and query, query means only using the query context function (you need to have your own uploaded documents), chat means using the chat function

Example of a request (Request body)

curl --location 'http://localhost:3001/api/v1/workspace/newwork/chat'
--header 'Authorization: Bearer 7X26VBD-0824RMG-MD0VV2X-PC02ZJ4'
--header 'Content-Type: application/json'
--data '{
  "message": "What is the grade for two broken ribs?" ,
  "mode": "chat"
}'

Responses

{
    "id": "488ff13e-0206-4014-bf50-ea2d8e78c1c3",
    "type": "textResponse",
    
    "error": null, "chatId": 17, "error": 17
    "chatId": 17, "textResponse": null, "close": true, "error": null, "chatId": 17, "textResponse": null, "textResponse": null
    "textResponse":"nOkay, I now need to address the user's question, "What is the grade for two broken ribs?" The user has asked this question before and I gave an answer, but now he is asking it again and may want a more detailed or different explanation.nnFirst, review the context. In the Context 0 provided, the 5.6.4 Minor Injury Grade 2 section mentions that b) 2 or more rib fractures are a minor injury grade 2. Therefore, two fractured ribs meets this criterion and should be graded as a minor second-degree injury.nnThe user may be a legal practitioner, a family member, or the injured person him/herself, and want to know the severity of the fracture for the purpose of dealing with workers' compensation or other related matters. They may not be familiar with the grading criteria, which is why they ask multiple times.nnIn the thought process, I need to identify if there are other relevant grading criteria that could affect the outcome. For example, whether there are special circumstances such as the location of the fracture, whether it is accompanied by internal organ damage, etc. These factors may change the grading level. However, according to the Context provided, there is no mention of these circumstances, so I can only make a judgment based on the information given.nnIn addition, users may want to know how to apply for work injury recognition or the subsequent compensation process, but due to the limited information available, I am unable to provide the specific steps, but I can suggest that they contact the labor security department or a medical institution to obtain professional guidance.nnIn summary, the two fractured ribs fall into the category of minor second-degree injuries, which is a conclusion based on the criteria provided. The user may need further legal or medical advice to deal with the matter.nnnBased on the contextual information you provided:nnIn **5.6.4 Minor Injury Grade 2**, it mentions:n- **b) Ribs fractured in more than 2 places**.nnTherefore, **two fractured ribs fall into the category of Minor Injury Grade 2**." ,
    "sources": [
        {
            "text": "5.2.4 Minor Injury Grade II nna) A single wound or scar on the face of more than 4.5cm in length; multiple wounds or scars of more than 6.0cm in cumulative length.nnb) Penetrating wounds on the cheeks, with skin wounds or scars of more than 1.0cm in length.nnc) Full-length lacerations of the mouth and lips, with skin wounds or scars of more than 1.0cm in length.nnd) Massive scarring of the face that A single piece measuring 3.0 cm² or more or multiple pieces measuring a cumulative total of 5.0 cm² or more. nne) Facial patches of fine scarring or pigmentation abnormalities measuring a cumulative total of 8.0 cm² or more. f) Orbital wall fracture (other than a simple fracture of the medial orbital wall). nng) Eyelid defect. nnh) Mild ectropion of one eyelid. nnni) Ptosis of the upper eyelid over the pupil of one eye. nnj) Inadequate closure of the eyelid of one eye. nnj) Inadequate closure of the eyelid of one eye. nnj) Inadequate closure of the eyelid of one eye. nnj) Inadequate closure of the eyelid of one eye. nnk) Lacrimal organ injury with tearing on one side. nn1) Auricular incision or scar length of 6.0 cm or more cumulatively. nnm) Auricular disarticulation, defect, or contracture deformity of a cumulatively equivalent to 15% or more of the auricular area on one side. nnn) Nasal tip or nasal flange deficiency on one side. nno) Comminuted fracture of the nasal bone; bilateral fractures of the nasal bones; fracture of the nasal bone combined with a fracture of the frontal process of the maxilla; fracture of the nasal bone combined with a fracture of the nasal septum; fracture of the nasal bone combined with a fracture of the maxillary frontal process; fracture of the nasal bone combined with a Fractures of the nasal septum; bilateral fractures of the maxillary frontal process. nnp) Loss of tongue. nnq) Loss of teeth or fracture of two or more teeth. nnr) Substantial injury to the parotid, submandibular or sublingual glands. nns) Injury resulting in difficulty in opening the mouth to the degree of I. nnnt) Fractures of the jaws (other than fracture of the alveolar process and fracture of the maxillary frontal process of the maxilla on one side). u) Fractures of the zygomatic bone. nnn5.2.5 Minor Injuries nnnnnnnnna) Facial soft tissue trauma. nnb) Facial injury with scarring or pigmentation changes. nnc) Facial skin abrasion with an area of 2.0 cm² or more; facial soft tissue contusion; facial scratches of 4.0 cm or more. nnnd) Fracture of the inner orbital wall. nnne) Ocular contusion; ocular trauma that affects the appearance of the eye. nnf) Auricular trauma. nnn) Nasal bone fracture; nose bleed. nnnnn) Nasal bone fracture; nose bleed. nnnnnnnna) Nasal bone fracture; nasal bleeding. nnnnnnnna) Nasal bone fracture; nasal bleed. h) Frontal process fracture of the maxilla. nni) Breach of oral mucosa; tongue injury. nnj) Lost or missing teeth; fracture of the alveolar process; more than 2 loose teeth or more than 1 loose tooth of degree III. nn5.3 Auditory hearing impairment nn5.3. 1 Serious Injury Grade I nna) Binaural hearing loss (≥ 91dB HL). nn5.3.2 Serious Injury Grade II nna) Binaural hearing loss in one ear (≥ 91dB HL). nnb) Hearing impairment in one ear (≥81dB HL) and in the other ear (≥41dB HL). nnc) Hearing impairment in one ear (≥81dB HL) with ipsilateral vestibular balance dysfunction. nnd) Bilateral hearing impairment in both ears (≥61dB HL). nnne) Loss of bilateral vestibular balance, with difficulty in opening the eyes to walk and the inability to stand side-by-side. nn5.3.2 Serious Injury Level 2 nn5.3.3 Minor Injury Grade I nna) Hearing loss in both ears (≥41 dB HL). nnb) Atresia of the external auditory canal in both ears. nn5.3.4 Minor Injury Grade II nna) Traumatic perforation of the tympanic membrane that has failed to heal by itself within 6 weeks. b.... .continued on in source document..." ,
            "id": "210f98f0-d656-4c0f-b3d5-d617f6398eca",
            "url": "file://C:\Users\XX\AppData\Roaming\anythingllm-desktop\storage\hotdir\New DOCX Document.docx", "title": "New DOCX Document.
            
            "docAuthor": "no author found", "description": "No description found".
            "description": "No description found.", "docAuthor": "no author found", "docAuthor": "no author found", "description": "No description found.
            "docSource": "pdf file uploaded by the user.", "chunkSource": "pdf file uploaded by the user.
            "chunkSource": "localfile://C:\Users\XX\Desktop\New DOCX document.docx", "published": "2025/2000", "description": "No description found.", "docSource": "pdf file uploaded by the user.", "docSource": "pdf file uploaded by the user.
            "published": "2025/2/7 13:00:52",
            "wordCount": 126, "token_count_estimate".
            "token_count_estimate": 3870
        }
    ],.
    "metrics": {
        "prompt_tokens": 431,
        
        "total_tokens": 757, "outputTps": 63.17825943406,
        "outputTps": 63.178294573643406, "duration": 5.16.5
        "duration": 5.16
    }
}

In this way we have completed the test of calling AnythingLLM interface. According to this interface you can implement your own business logic, below we combine the WeChat BOT to realize the knowledge base robot.

NGC Modifications

The NGCBOT program requires that theApiServerAiServerAiDialogue.pyAdd a call to the scriptAnythingLLMThe logic of the

Here I'll just put the code.

def getAnythingLLM(self, content, messages).
"""
Local AnythingLLM model
:param content: content of the conversation
:param messages: list of messages
:return.
"""
op(f'[*]: Local AnythingLLM dialog interface is being invoked... ...')
messages.append({"role": "user", "content": f'{content}'})

data = {
"model": self.anythingLLMConfig.get('anythingllmModel'),
"message": content
}

headers = {
"Content-Type": "application/json", "Authorization": self.anythingLLMConfig.get('anythingllmModel'), "message": content
"Authorization": self.anythingLLMConfig.get('anythingllmKey')
}

try.
resp = requests.post(
url=self.anythingLLMConfig.get('anythingllmApi').format(workspace=self.anythingLLMConfig.get('workspace')),
headers=headers,
json=data,
timeout=300
)

resp.encoding = 'utf-8'
json_data = resp.json()

assistant_content = json_data['textResponse']

if "" in assistant_content:
assistant_content = assistant_content.split("")[1].strip()

messages.append({"role": "assistant", "content": f"{assistant_content}"})
if len(messages) == 21.
del messages[1]
del messages[2]
return assistant_content, messages
except Exception as e.
op(f'[-]: Error in local AnythingLLM dialog interface, error message: {e}')
return None, [{"role": "system", "content": f'{self.systemAiRole}'}]

 

Add theanythingLLMConfig

self.anythingLLMConfig = {
            'anythingllmApi': configData['apiServer']['aiConfig']['AnythingLLM']['AnythingllmApi'],
            'anythingllmKey': configData['apiServer']['aiConfig']['AnythingLLM']['AnythingllmKey'],
            'anythingllmModel': configData['apiServer']['aiConfig']['AnythingLLM']['AnythingllmModel'],
            'workspace': configData['apiServer']['aiConfig']['AnythingLLM']['workspace']
        }

 

Integration pack acquisition

Tootsie Labs - Windowns Edition

Quark:
https://pan.quark.cn/s/8d1293227cf9

Baidu.
https://pan.baidu.com/s/1wx8LmbY2XBaJAAJvmGK06g?pwd=8d5m

May not be reproduced without permission:Chief AI Sharing Circle " Realization of local/API knowledge base based on DeepSeek-R1 with access to WeChat BOT

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish