Skip to content

Commit f2f893b

Browse files
committed
Version bump to 0.1.0 [skip ci]
1 parent 4b62e50 commit f2f893b

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## 0.1.0 (unreleased)
1+
## 0.1.0 (2023-10-17)
22

33
- First release

README.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
# pgvector-dart
22

3-
[pgvector](https://github.com/pgvector/pgvector) examples for Dart
3+
[pgvector](https://github.com/pgvector/pgvector) support for Dart
44

55
Supports the [postgres](https://github.com/isoos/postgresql-dart) package
66

77
[![Build Status](https://github.com/pgvector/pgvector-dart/workflows/build/badge.svg?branch=master)](https://github.com/pgvector/pgvector-dart/actions)
88

99
## Getting Started
1010

11-
Follow the instructions for your database library:
11+
Run:
12+
13+
```sh
14+
dart pub add pgvector
15+
```
16+
17+
And follow the instructions for your database library:
1218

1319
- [postgres](#postgres)
1420

1521
## postgres
1622

23+
Import the library
24+
25+
```dart
26+
import 'package:pgvector/pgvector.dart';
27+
```
28+
1729
Enable the extension
1830

1931
```dart
@@ -33,23 +45,23 @@ Insert vectors
3345
await connection.execute(
3446
"INSERT INTO items (embedding) VALUES (@a), (@b), (@c)",
3547
substitutionValues: {
36-
"a": [1, 1, 1].toString(),
37-
"b": [2, 2, 2].toString(),
38-
"c": [1, 1, 2].toString()
48+
"a": pgvector.encode([1, 1, 1]),
49+
"b": pgvector.encode([2, 2, 2]),
50+
"c": pgvector.encode([1, 1, 2])
3951
});
4052
```
4153

4254
Get the nearest neighbors
4355

4456
```dart
4557
List<List<dynamic>> results = await connection.query(
46-
"SELECT id, embedding::text FROM items ORDER BY embedding <-> @embedding LIMIT 5",
58+
"SELECT id, embedding FROM items ORDER BY embedding <-> @embedding LIMIT 5",
4759
substitutionValues: {
48-
"embedding": [1, 1, 1].toString()
60+
"embedding": pgvector.encode([1, 1, 1])
4961
});
5062
for (final row in results) {
5163
print(row[0]);
52-
print(jsonDecode(row[1]));
64+
print(pgvector.decode(row[1]));
5365
}
5466
```
5567

0 commit comments

Comments
 (0)