Skip to content

Commit

Permalink
Improved directory structure for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jul 24, 2024
1 parent 100e28c commit b6de02a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 23 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ And follow the instructions for your database library:

Or check out some examples:

- [Embeddings](examples/openai_test.go) with OpenAI
- [Binary embeddings](examples/cohere_test.go) with Cohere
- [Recommendations](examples/disco_test.go) with Disco
- [Horizontal scaling](examples/citus_test.go) with Citus
- [Bulk loading](examples/loading_test.go) with `COPY`
- [Embeddings](examples/openai/main.go) with OpenAI
- [Binary embeddings](examples/cohere/main.go) with Cohere
- [Recommendations](examples/disco/main.go) with Disco
- [Horizontal scaling](examples/citus/main.go) with Citus
- [Bulk loading](examples/loading/main.go) with `COPY`

## pgx

Expand Down Expand Up @@ -385,5 +385,5 @@ go test -v
To run an example:

```sh
go test -v examples/loading_test.go
go run ./examples/loading
```
5 changes: 2 additions & 3 deletions examples/citus_test.go → examples/citus/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package pgvector_test
package main

import (
"context"
"fmt"
"math/rand"
"testing"

"github.com/jackc/pgx/v5"
"github.com/pgvector/pgvector-go"
pgxvector "github.com/pgvector/pgvector-go/pgx"
)

func TestCitus(t *testing.T) {
func main() {
// generate random data
rows := 1000000
dimensions := 128
Expand Down
8 changes: 4 additions & 4 deletions examples/cohere_test.go → examples/cohere/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pgvector_test
package main

import (
"bytes"
Expand All @@ -7,15 +7,15 @@ import (
"fmt"
"net/http"
"os"
"testing"

"github.com/jackc/pgx/v5"
)

func TestCohere(t *testing.T) {
func main() {
apiKey := os.Getenv("CO_API_KEY")
if apiKey == "" {
t.Skip("Set CO_API_KEY")
fmt.Println("Set CO_API_KEY")
os.Exit(1)
}

ctx := context.Background()
Expand Down
5 changes: 2 additions & 3 deletions examples/disco_test.go → examples/disco/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package pgvector_test
package main

import (
"context"
"fmt"
"testing"

"github.com/ankane/disco-go"
"github.com/jackc/pgx/v5"
"github.com/pgvector/pgvector-go"
)

func TestDisco(t *testing.T) {
func main() {
ctx := context.Background()

conn, err := pgx.Connect(ctx, "postgres://localhost/pgvector_example")
Expand Down
5 changes: 2 additions & 3 deletions examples/loading_test.go → examples/loading/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package pgvector_test
package main

import (
"context"
"fmt"
"math/rand"
"testing"

"github.com/jackc/pgx/v5"
"github.com/pgvector/pgvector-go"
pgxvector "github.com/pgvector/pgvector-go/pgx"
)

func TestLoading(t *testing.T) {
func main() {
// generate random data

rows := 1000000
Expand Down
8 changes: 4 additions & 4 deletions examples/openai_test.go → examples/openai/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pgvector_test
package main

import (
"bytes"
Expand All @@ -7,16 +7,16 @@ import (
"fmt"
"net/http"
"os"
"testing"

"github.com/jackc/pgx/v5"
"github.com/pgvector/pgvector-go"
)

func TestOpenAI(t *testing.T) {
func main() {
apiKey := os.Getenv("OPENAI_API_KEY")
if apiKey == "" {
t.Skip("Set OPENAI_API_KEY")
fmt.Println("Set OPENAI_API_KEY")
os.Exit(1)
}

ctx := context.Background()
Expand Down

0 comments on commit b6de02a

Please sign in to comment.