Skip to content

Instantly share code, notes, and snippets.

@muyiwexy
Created November 28, 2023 21:44
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/963aeaf2545bb7c5f4fc2844287d6828 to your computer and use it in GitHub Desktop.
Save muyiwexy/963aeaf2545bb7c5f4fc2844287d6828 to your computer and use it in GitHub Desktop.
langchain_service_impl.dart(2)
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
@override
Future<bool> checkExtExist() async {
final checkExtExist = await connection.execute(
"SELECT EXISTS (SELECT FROM pg_extension WHERE extname = 'vectors');",
);
return checkExtExist.first[0] as bool;
}
@override
Future<bool> checkTableExist(String tableName) async {
final checkTableExist = await connection.execute(
"SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'public' AND table_name = '$tableName');",
);
return checkTableExist.first[0] as bool;
}
}
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