Basilica R Client¶
-
basilica.
connect
(auth_key, server)¶ Instantiates and returns a Basilica connection tied to a specific auth key and server. It also populates a global basilica_connection that is a copy of the returned connection. If a conn argument is not passed to an embed_* function, this global connection will be used.
Parameters: - auth_key (str) – Basilica API key. You can view your auth keys at https://basilica.ai/auth_keys.
- server (str) – Basilica server to point to (Default: https://api.basilica.ai)
>>> conn <- connect("SLOW_DEMO_KEY") # Create a connection to pass to functions embeddings <- embed_sentences(c("hello world"), conn=conn)
>>> connect("SLOW_DEMO_KEY") # Populate the global connection embeddings <- embed_sentences(c("hello world")) embeddings <- embed_sentences(c("hello world")) # Will both use the sameglobal connection
-
basilica.
embed_sentence
(sentence, model, version, conn, timeout)¶ Get a vector of features for a sentence
Parameters: - sentence – Sentence or string
- model (character()) – Name of the image model you wish to use. (Default: english)
- version (character()) – Version of the image model you wish to use. (Default: default)
- conn (environment()) – Basilica connection. Must be created with the connect function (Default: Global basilica_connection)
- timeout (number()) – Time (in seconds) before requests times out. (Default 5)
Returns: An embedding.
Return type: Matrix
-
basilica.
embed_sentences
(sentences, model, version, conn, timeout)¶ Get a vector of features for a list of sentences
Parameters: - sentence – Sentence or string
- model (character()) – Name of the image model you wish to use. (Default: english)
- version (character()) – Version of the image model you wish to use. (Default: default)
- conn (environment()) – Basilica connection. Must be created with the connect function (Default: Global basilica_connection)
- timeout (number()) – Time (in seconds) before requests times out. (Default 5)
Returns: An embedding.
Return type: Matrix
-
basilica.
embed_image
(image, model, version, conn, timeout)¶ Get a vector of features for an image
Parameters: - image (raw()) – Raw vector read from image file (JPEG or PNG)
- model (character()) – Name of the image model you wish to use. (Default: generic)
- version (character()) – Version of the image model you wish to use. (Default: default)
- conn (environment()) – Basilica connection. Must be created with the connect function (Default: Global basilica_connection)
- timeout (number()) – Time (in seconds) before requests times out. (Default 5)
Returns: An embedding.
Return type: Matrix
-
basilica.
embed_image_file
(image_path, model, version, conn, timeout)¶ Get a vector of features for an image
Parameters: - image_path – Path to an image (JPEG or PNG)
- model (character()) – Name of the image model you wish to use. (Default: generic)
- version (character()) – Version of the image model you wish to use. (Default: default)
- conn (environment()) – Basilica connection. Must be created with the connect function (Default: Global basilica_connection)
- timeout (number()) – Time (in seconds) before requests times out. (Default 5)
Returns: An embedding.
Return type: Matrix
-
basilica.
embed_image_files
(image_paths, model, version, conn, timeout)¶ Get a vector of features for a list images
Parameters: - image_paths – List of file paths to images (JPEG or PNG)
- model (character()) – Name of the image model you wish to use. (Default: generic)
- version (character()) – Version of the image model you wish to use. (Default: default)
- conn (environment()) – Basilica connection. Must be created with the connect function (Default: Global basilica_connection)
- timeout (number()) – Time (in seconds) before requests times out. (Default 5)
Returns: An embedding.
Return type: Matrix
-
basilica.
embed_images
(images, model, version, conn, timeout)¶ Get a vector of features for a list images
Parameters: - images (list()) – List of raw vectors read from image files (JPEG or PNG)
- model (character()) – Name of the image model you wish to use. (Default: generic)
- version (character()) – Version of the image model you wish to use. (Default: default)
- conn (environment()) – Basilica connection. Must be created with the connect function (Default: Global basilica_connection)
- timeout (number()) – Time (in seconds) before requests times out. (Default 5)
Returns: An embedding.
Return type: Matrix