|
1 | | -package com.pgvector; |
| 1 | +package com.example; |
2 | 2 |
|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.net.URI; |
|
18 | 18 | import com.fasterxml.jackson.databind.ObjectMapper; |
19 | 19 | import com.fasterxml.jackson.databind.JsonNode; |
20 | 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 21 | +import com.pgvector.PGbit; |
21 | 22 | import com.pgvector.PGvector; |
22 | | -import org.postgresql.PGConnection; |
23 | | -import org.junit.jupiter.api.Test; |
24 | 23 |
|
25 | | -public class CohereTest { |
26 | | - @Test |
27 | | - void example() throws IOException, InterruptedException, SQLException { |
| 24 | +public class Example { |
| 25 | + public static void main(String[] args) throws IOException, InterruptedException, SQLException { |
28 | 26 | String apiKey = System.getenv("CO_API_KEY"); |
29 | 27 | if (apiKey == null) { |
30 | | - return; |
| 28 | + System.out.println("Set CO_API_KEY"); |
| 29 | + System.exit(1); |
31 | 30 | } |
32 | 31 |
|
33 | 32 | Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/pgvector_example"); |
@@ -67,7 +66,7 @@ void example() throws IOException, InterruptedException, SQLException { |
67 | 66 | } |
68 | 67 |
|
69 | 68 | // https://docs.cohere.com/reference/embed |
70 | | - private List<byte[]> fetchEmbeddings(String[] texts, String inputType, String apiKey) throws IOException, InterruptedException { |
| 69 | + private static List<byte[]> fetchEmbeddings(String[] texts, String inputType, String apiKey) throws IOException, InterruptedException { |
71 | 70 | ObjectMapper mapper = new ObjectMapper(); |
72 | 71 | ObjectNode root = mapper.createObjectNode(); |
73 | 72 | for (String v : texts) { |
|
0 commit comments