Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ai/guides/auto-embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ Auto embedding is a feature that allows you to automatically generate vector emb

```python hl_lines="7"
from pytidb.schema import TableModel, Field
from pytidb.datatype import Text
from pytidb.datatype import TEXT

class Chunk(TableModel):
id: int = Field(primary_key=True)
text: str = Field(sa_type=Text)
text: str = Field(sa_type=TEXT)
text_vec: list[float] = embed_func.VectorField(source_field="text")

table = client.create_table(schema=Chunk, mode="overwrite")
table = client.create_table(schema=Chunk, if_exists="overwrite")
```

You don't need to specify the `dimensions` parameter, it will be automatically determined by the embedding model.
Expand Down
2 changes: 1 addition & 1 deletion src/ai/guides/fulltext-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TiDB provides full-text search capabilities for **massive datasets** with high p
id: int = Field(primary_key=True)
title: str = FullTextField(fts_parser="MULTILINGUAL")

table = client.create_table(schema=Item, mode="overwrite")
table = client.create_table(schema=Item, if_exists="overwrite")
```

The `fts_parser` parameter specifies the parser for the full-text index. Supported values:
Expand Down
2 changes: 1 addition & 1 deletion src/ai/guides/hybrid-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ embed_fn = EmbeddingFunction(
text: str = FullTextField()
text_vec: list[float] = embed_fn.VectorField(source_field="text")

table = client.create_table(schema=Chunk, mode="overwrite")
table = client.create_table(schema=Chunk, if_exists="overwrite")
```

In this example, PyTiDB will automatically create a full-text index on the `text` column and a vector index on the `text_vec` column.
Expand Down
2 changes: 1 addition & 1 deletion src/ai/guides/image-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ImageItem(TableModel):
source_field="image_uri"
)

table = client.create_table(schema=ImageItem, mode="overwrite")
table = client.create_table(schema=ImageItem, if_exists="overwrite")
```

### Step 3. Insert image data
Expand Down
4 changes: 2 additions & 2 deletions src/ai/guides/joins.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ As a relational database, TiDB allows you to store diverse data in tables with d
id: int = Field(primary_key=True)
title: str = Field(max_length=255)

client.create_table(schema=Document, mode="overwrite")
client.create_table(schema=Document, if_exists="overwrite")
client.table("documents").truncate()
client.table("documents").bulk_insert([
Document(id=1, title="The Power of Positive Thinking"),
Expand All @@ -41,7 +41,7 @@ As a relational database, TiDB allows you to store diverse data in tables with d
text: str = Field(max_length=255)
document_id: int = Field(foreign_key="documents.id")

client.create_table(schema=Chunk, mode="overwrite")
client.create_table(schema=Chunk, if_exists="overwrite")
client.table("chunks").truncate()
client.table("chunks").bulk_insert([
Chunk(id=1, text="Positive thinking can change your life", document_id=1),
Expand Down
8 changes: 4 additions & 4 deletions src/ai/guides/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ In the following example, you create a table named `items` with these columns:
embedding: list[float] = VectorField(dimensions=3)
meta: dict = Field(sa_type=JSON, default_factory=dict)

table = client.create_table(schema=Item, mode="overwrite")
table = client.create_table(schema=Item, if_exists="overwrite")
```

The `create_table` method accepts these parameters:

- `schema`: The `TableModel` class that defines your table structure.
- `mode`: The creation mode of the table.
- `create` (default): Creates the table if it does not exist; raises an error if it already exists.
- `exists_ok`: Creates the table if it does not exist; does nothing if it already exists.
- `if_exists`: The creation mode of the table.
- `raise` (default): Creates the table if it does not exist; raises an error if it already exists.
- `skip`: Creates the table if it does not exist; does nothing if it already exists.
- `overwrite`: Drops the existing table and creates a new one. This is useful for **testing and development**, but not recommended for production environments.

Once the table is created, you can use the `table` object to insert, update, delete, and query data.
Expand Down
4 changes: 2 additions & 2 deletions src/ai/guides/vector-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This section shows you how to use vector search in your application in minimal s
text_vec: list[float] = VectorField(dimensions=3)
meta: dict = Field(sa_type=JSON, default_factory=dict)

table = client.create_table(schema=Document, mode="overwrite")
table = client.create_table(schema=Document, if_exists="overwrite")
```

The `VectorField` class accepts the following parameters:
Expand Down Expand Up @@ -385,7 +385,7 @@ For example, you can store both text embeddings and image embeddings in the same
image_url: str
image_vec: list[float] = VectorField(dimensions=3)

table = client.create_table(schema=RichTextDocument, mode="overwrite")
table = client.create_table(schema=RichTextDocument, if_exists="overwrite")

# Insert sample data ...

Expand Down
2 changes: 1 addition & 1 deletion src/ai/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ As an example, create a table named `chunks` with the following columns:
text_vec: list[float] = text_embed.VectorField(source_field="text")
user_id: int = Field()

table = client.create_table(schema=Chunk, mode="overwrite")
table = client.create_table(schema=Chunk, if_exists="overwrite")
```

Once created, you can use the `table` object to insert data, search data, and more.
Expand Down