Skip to content

Instantly share code, notes, and snippets.

@muyiwexy
Created November 28, 2023 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muyiwexy/b44a481473fe68d908a33421c558fd87 to your computer and use it in GitHub Desktop.
Save muyiwexy/b44a481473fe68d908a33421c558fd87 to your computer and use it in GitHub Desktop.
langchain_service_impl.dart(3)
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