-
-
Save muyiwexy/b44a481473fe68d908a33421c558fd87 to your computer and use it in GitHub Desktop.
langchain_service_impl.dart(3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LangchainServicesImpl extends LangchainService { | |
final Connection connection; | |
final OpenAIEmbeddings embeddings; | |
final OpenAI openAI; | |
LangchainServicesImpl({ | |
required this.connection, | |
required this.embeddings, | |
required this.openAI, | |
}); | |
// do something | |
// do something | |
// do somthing | |
// do something | |
@override | |
Future<String> createNeonVecorExt() async { | |
debugPrint("Creating pgVector extension ..."); | |
await connection.execute("CREATE EXTENSION vector;"); | |
return "Vector extension created Successfully"; | |
} | |
@override | |
Future<String> createNeonTable(String tableName) async { | |
debugPrint("Creating the $tableName table ... "); | |
await connection.execute( | |
"CREATE TABLE $tableName (id text, metadata text, embedding vector(1536));", | |
); | |
debugPrint("Indexing the $tableName using the ivfflat vector cosine"); | |
await connection.execute( | |
'CREATE INDEX ON $tableName USING ivfflat (embedding vector_cosine_ops) WITH (lists = 24);'); | |
return "Table created successfully"; | |
} | |
@override | |
Future<String> deleteNeonTableRows(String tableName) async { | |
debugPrint("Deleting tableRows"); | |
await connection.execute("TRUNCATE $tableName;"); | |
return "Table rows deleted successfuly"; | |
} | |
} | |
void debugPrint(String message) { | |
if (kDebugMode) { | |
print(message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment