File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ let config = PostgresClient.Configuration(
1313
1414let client = PostgresClient ( configuration: config)
1515
16- func generateEmbedding ( input: String ) async throws -> [ Double ] {
16+ func embed ( input: String ) async throws -> [ Double ] {
1717 let response = try await Client . default. embed (
1818 model: " nomic-embed-text " ,
1919 input: input
@@ -37,12 +37,12 @@ try await withThrowingTaskGroup(of: Void.self) { taskGroup in
3737 ]
3838
3939 for content in input {
40- let embedding = try await generateEmbedding ( input: content)
40+ let embedding = try await embed ( input: content)
4141 try await client. query ( " INSERT INTO documents (content, embedding) VALUES ( \( content) , \( embedding) ) " )
4242 }
4343
4444 let query = " forest "
45- let embedding = try await generateEmbedding ( input: query)
45+ let embedding = try await embed ( input: query)
4646 let rows = try await client. query ( " SELECT content FROM documents ORDER BY embedding <=> \( embedding) ::vector LIMIT 5 " )
4747 for try await row in rows {
4848 print ( row)
You can’t perform that action at this time.
0 commit comments