aiWithWechat · WeChat assistant · 2023

A close question gets the stored answer

The questions and answers stay on your own system, and each question is embedded. In WeChat, a message needs the configured mark. A close wording gets that stored answer. If nothing is close enough, that question goes to the model.

Our own product · private deployment · Chinese interface

Three stages. Accounts, menus and pairs first. Then embed the questions, start the assistant, set the trigger, and connect the model. Then answer in WeChat.
Three stages. Accounts, menus and pairs first. Then embed the questions, start the assistant, set the trigger, and connect the model. Then answer in WeChat.
A close question uses the stored answer
Match
Otherwise the question is sent on
Then ask
Kept on your own list
One pair
Log in to desktop WeChat
Scan

Screens

The list comes first, then the question in WeChat

The admin site is labelled 微信智能助手 (WeChat smart assistant). The menu shows the assistant settings, the system, and the logs. The pairs and the WeChat replies are the introduction’s sample.

Question and answer settings. Search by either field. Each row shows the answer and the token count recorded for that embedding. The questions are sample.
Question and answer settings. Search by either field. Each row shows the answer and the token count recorded for that embedding. The questions are sample.
A new row takes a question and an answer. The embedding happens when it is saved. The pair on screen is sample.
A new row takes a question and an answer. The embedding happens when it is saved. The pair on screen is sample.
The list is on the left, a logged-in WeChat window on the right. A marked question that is close to a row gets that answer. A question that is not on the list gets a longer reply, written by the model. That reply is sample.
The list is on the left, a logged-in WeChat window on the right. A marked question that is close to a row gets that answer. A question that is not on the list gets a longer reply, written by the model. That reply is sample.

01 / What it is

Match the preset pairs inside WeChat

aiWithWechat runs on your own server. People keep the pairs in the admin site and ask the assistant in WeChat. It is not the system that answers from one file.

01

Pairs go in first

The admin site stores a question and an answer. Saving embeds the question and writes it, with the answer, into pgvector on PostgreSQL. The list shows the token count from that call.

02

WeChat needs the mark

The bot is Wechaty, attached to desktop WeChat, and someone scans to log in. Only text that carries the configured trigger is matched. The introduction screen uses /. Ordinary chat without the mark is left alone.

03

A close match uses the stored answer

The question is embedded and compared with the stored questions. At or above the configured score, the stored answer goes back, even when the wording is not identical. Below that, the question goes to the model.

02 / Why

A written answer should not be generated again

A service desk already has questions that are close to each other, with the answer written down. Match those first. Send on only what does not match.

  1. The answer stays here

    Questions, answers and vectors sit in your own PostgreSQL. A match returns the stored answer. It does not write a new paragraph for that turn.

  2. Only the miss is sent on

    Saving a pair sends the question to OpenAI to embed it. A WeChat question that misses is sent to the model. A hit is not sent again for that reply.

  3. Close is enough

    The match is a vector comparison, not an exact sentence. On the introduction screen the wording differs from the row, and the reply is still that stored answer.

  4. Sign-ins are in the logs

    Sign-in, action and error logs are kept apart. Menus open by role. Splitting data by region is written down as later work.

03 / One question

No match, no stored answer

The order is on the system diagram. The score lives in the configuration. This page does not publish it as a fixed figure.

  1. 01

    Keep

    Write the question and the answer. Saving embeds the question into pgvector.

  2. 02

    Start

    Wechaty opens desktop WeChat and someone scans to log in. It is not an official WeChat API.

  3. 03

    Mark

    A private or group text message is matched only when it carries the configured mark. The introduction screen uses /.

  4. 04

    Match, then ask

    At the configured score, the stored answer goes back. Below it, the question goes to the model and the reply returns to WeChat.

04 / Besides

People and logs sit beside the list

The working menu is the question list. System and logs are next to it.

  • Users, roles and menus
  • Sign-in, action and error logs
  • View, edit and delete on a row
  • Marked text in a private chat or a group

Delivery

On your own server

The admin site is a browser. The bot attaches to desktop WeChat. The interface and the logs are in Chinese.

  • B/S admin site
  • Spring Boot
  • Vue and Element UI
  • MyBatis-Plus
  • Python and Wechaty
  • OpenAI
  • PostgreSQL and pgvector
  • The score is in the configuration. This page does not treat an example as the system’s figure
  • The interface and the logs are Chinese. The requirements say there is no second language
  • Menu permissions are in. Splitting data by region is not
  • A join or a pat is sent to the model with a prepared prompt. Other non-text messages are ignored
  • Voice, images, a company’s own APIs, an official account or WeCom are written down as later work
  • The captcha can use Redis. Without it, the code uses a local cache
A close question gets the answer you wrote. Only a miss sends that question to the model.

05 / Questions

The boundary first

Is this an official WeChat API?

No. The bot is Wechaty on desktop WeChat, and someone scans to log in. Use it inside WeChat’s own rules.

Must the wording match exactly?

No. The match is a vector comparison. On the introduction screen the wording differs from the row, and the reply is still the stored answer.

What if it does not match?

Below the configured score, the question goes to the model and the reply comes back to WeChat. That paragraph is the model’s, not a stored answer.

Does saving send the question out?

Yes. Saving sends the question to OpenAI to embed it. The vector and the answer stay in your database. A later hit does not ask the model again for that reply.

Is this the document search system?

No. aiWithDoc answers from one file. This one matches preset pairs inside WeChat.

Next

If WeChat should answer the fixed questions first

We will say whether this fits, and whether the first two weeks are the question list, the scan-to-login, or the score in the configuration.

Ask about this system