Introduction
People often ask me to look up a product name, but they want it to be semantically similar, not a fuzzy search. For example, if you input ladle, you hope to match spoon, scoop. We can use LangGraph + vector database to implement a small tool for approximate semantic matching.
Preparation
-
Download a copy of the LangGraph code and remember the location, then update to .cursorrules -
Prepare a .cursorrules file to store the following content -
Download the reference file demo.py I provided and place it in the root directory of the project -
Set up a conda virtual environment
Content of the .cursorrules file :
The LangGraph code is in /xxx/github/langgraph. Use conda langgraph environment with OpenAI, model='deepseek-chat', base_url="https://api.deepseek.com", key=sk-xxxx. Install using pip, default to https://pypi.tuna.tsinghua.edu.cn/simple
Directory structure is as follows
LangGraph-Demo/├── demo.py # Reference file└── .cursorrules # Cursor IDE configuration file
One command to solve it
Prompt:
Develop a Python program based on LangChain, using VectorStoreToolkit to vectorize the product description field of SQLite (your own .db), then query similar material descriptions using natural language. Use conda langgraph environment as referenced in @demo.py
Cursor works automatically:
-
Enter the virtual environment -
Automatically install dependencies -
Automatically switch -
Automatically fix errors
Supplement
If you have an Excel file, you can first save it as a CSV format, then use the following command to convert it to SQLite
Create a new SQLite db file and import the specified CSV into it.
Reference file: https://749ju.notion.site/LangGraph-16f2cce1260e80148929f723870335f2?pvs=4
Now that you’ve read this far, feel free to join the 【Cursor User Group】 to chat about Cursor.
WeChat ID: puppy521
