Skip to content

Commit e350cb6

Browse files
committed
feat: update examples and dependencies for pytidb version 0.0.13.dev8
- Updated `.env.example` files across various examples to reflect new database names. - Modified `reqs.txt` files in examples to use the latest `pytidb` version 0.0.13.dev8. - Added a new rule in `.cursor/rules/update-examples.mdc` for updating `pytidb` dependencies in example projects. - Introduced a custom embedding example using the BGE-M3 model in `examples/custom_embedding`. - Refactored existing examples to ensure compatibility with the latest changes in the `pytidb` library. - Enhanced README files to provide clearer instructions and updated information.
1 parent 1a6978c commit e350cb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1938
-1442
lines changed

.cursor/rules/update-examples.mdc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
alwaysApply: false
3+
---
4+
5+
Update the `pytidb` dependency in all example projects (e.g., `examples/auto_embedding/reqs.txt`) and verify that they work with the latest version.
6+
7+
### Steps
8+
9+
1. List all examples
10+
2. Using `todo_write` tool to add each example to the ToDo list.
11+
3. Process each example as following steps one by one.
12+
1. Check the latest `pytidb` version in `pyproject.toml`.
13+
2. Update the `reqs.txt` files accordingly.
14+
3. Create a virtual environment (If not exists):
15+
16+
```bash
17+
python -m venv .venv
18+
source .venv/bin/activate
19+
```
20+
21+
4. Install dependencies:
22+
23+
```bash
24+
pip install -q -r reqs.txt
25+
```
26+
27+
5. Run the example entry point (python main.py or streamlit run app.py) to confirm functionality.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,6 @@ cython_debug/
172172

173173
# PyPI configuration file
174174
.pypirc
175+
176+
# Claude
177+
.claude/settings.local.json

examples/auto_embedding/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TIDB_HOST={gateway-region}.prod.aws.tidbcloud.com
33
TIDB_PORT=4000
44
TIDB_USERNAME={prefix}.root
55
TIDB_PASSWORD={password}
6-
TIDB_DATABASE=test
6+
TIDB_DATABASE=auto_embedding_example
77

88
EMBEDDING_PROVIDER=tidbcloud_free # No API key required
99
OPENAI_API_KEY=

examples/auto_embedding/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ TIDB_HOST={gateway-region}.prod.aws.tidbcloud.com
3939
TIDB_PORT=4000
4040
TIDB_USERNAME={prefix}.root
4141
TIDB_PASSWORD={password}
42-
TIDB_DATABASE=test
42+
TIDB_DATABASE=auto_embedding_example
4343
4444
# Using TiDB Cloud Free embedding model by default, which is no required to set up any API key
4545
EMBEDDING_PROVIDER=tidbcloud_free
@@ -56,7 +56,7 @@ python main.py
5656

5757
```plain
5858
=== Define embedding function ===
59-
Embedding function (model id: tidbcloud_free/amazon/titan-embed-text-v2) defined
59+
Embedding function (model name: tidbcloud_free/amazon/titan-embed-text-v2) defined
6060
6161
=== Define table schema ===
6262
Table created

examples/auto_embedding/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
port=int(os.getenv("TIDB_PORT", "4000")),
1515
username=os.getenv("TIDB_USERNAME", "root"),
1616
password=os.getenv("TIDB_PASSWORD", ""),
17-
database=os.getenv("TIDB_DATABASE", "pytidb_auto_embedding"),
17+
database=os.getenv("TIDB_DATABASE", "auto_embedding_example"),
1818
ensure_db=True,
1919
)
2020

@@ -86,7 +86,7 @@
8686
else:
8787
raise ValueError(f"Invalid embedding provider: {provider}")
8888

89-
print(f"Embedding function (model id: {embed_func.model_name}) defined")
89+
print(f"Embedding function (model name: {embed_func.model_name}) defined")
9090

9191
# Define table schema
9292
print("\n=== Define table schema ===")

examples/auto_embedding/reqs.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pytidb==0.0.12
2-
pytidb[models]==0.0.12
1+
pytidb==0.0.13.dev8
2+
pytidb[models]==0.0.13.dev8
33
python-dotenv

examples/basic/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ TIDB_HOST={gateway-region}.prod.aws.tidbcloud.com
33
TIDB_PORT=4000
44
TIDB_USERNAME={prefix}.root
55
TIDB_PASSWORD={password}
6-
TIDB_DATABASE=test
6+
TIDB_DATABASE=basic_example

examples/basic/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TIDB_HOST={gateway-region}.prod.aws.tidbcloud.com
3838
TIDB_PORT=4000
3939
TIDB_USERNAME={prefix}.root
4040
TIDB_PASSWORD={password}
41-
TIDB_DATABASE=test
41+
TIDB_DATABASE=basic_example
4242
EOF
4343
```
4444

examples/basic/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
port=int(os.getenv("TIDB_PORT", "4000")),
1616
username=os.getenv("TIDB_USERNAME", "root"),
1717
password=os.getenv("TIDB_PASSWORD", ""),
18-
database=os.getenv("TIDB_DATABASE", "pytidb_basic"),
18+
database=os.getenv("TIDB_DATABASE", "basic_example"),
1919
ensure_db=True,
2020
)
2121

examples/basic/reqs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytidb==0.0.10.post1
1+
pytidb==0.0.13.dev7
22
python-dotenv

0 commit comments

Comments
 (0)