SimilaritySearchApi
All URIs are relative to https://app.coactive.ai
Method |
HTTP request |
Description |
get_similar_images |
POST /api/v0/similarity-search/embeddings/{embedding_id}/search |
Get similar images |
get_similar_images_grouped |
POST /api/v0/similarity-search/embeddings/{embedding_id}/grouped-search |
Get similar images grouped by the group by key |
get_similar_images_grouped_semantic |
POST /api/v0/similarity-search/embeddings/{embedding_id}/grouped-search/semantic |
Get similar images grouped by the group by key and semantic notion of metadata |
search_images_by_text_grouped |
GET /api/v0/similarity-search/similarity-search/embeddings/{embedding_id}/grouped-search/text |
Get similar images grouped by the group by key and semantic notion of the text query |
get_similar_images
bool, date, datetime, dict, float, int, list, str, none_type get_similar_images(embedding_id, file)
Returns the images most similar to the image at the provided path within the same embedding space
Example
- Bearer Authentication (HTTPBearer):
| import time
import coactive
from coactive.apis import SimilaritySearchApi
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse
# Defining the host is optional and defaults to https://app.coactive.ai.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: HTTPBearer
# See configuration.py for a list of all supported configuration parameters.
from YOUR_ENV import CLIENT_ID, CLIENT_SECRET
configuration = coactive.Configuration(
host = "https://app.coactive.ai",
access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)
# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = SimilaritySearchApi(api_client)
embedding_id = "b78a6e5f-5434-46c4-9e4f-ded092147584"
file = open('/path/to/file', 'rb')
limit = 100 # (optional) if omitted the server will use the default value of 100
# example passing only required values which don't have defaults set
try:
# Get similar images
api_response = api_instance.get_similar_images(embedding_id, file)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->get_similar_images: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get similar images
api_response = api_instance.get_similar_images(embedding_id, file, limit=limit)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->get_similar_images: %s\n" % e)
|
Parameters
Name |
Type |
Description |
Notes |
embedding_id |
str |
The unique identifier for the embedding |
|
file |
file_type |
An image on which to perform similarity search |
|
limit |
int, none_type |
Max number of items to return |
[optional] if omitted the server will use the default value of 100 |
Return type
bool, date, datetime, dict, float, int, list, str, none_type
Authorization
HTTPBearer
- Content-Type: multipart/form-data
- Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
200 |
Similar images within the same embedding space |
- |
403 |
Authentication error |
- |
401 |
Unauthorized |
- |
404 |
Embedding not found |
- |
400 |
The file must be an image |
- |
422 |
Validation Error |
- |
[Back to top] [Back to API list] [Back to Model list] [Back to home]
get_similar_images_grouped
SimilaritySearchResponse get_similar_images_grouped(embedding_id, group_by, file)
Returns the images most similar to the image at the provided path within the same embedding space grouped by the group by key
Example
- Bearer Authentication (HTTPBearer):
| import time
import coactive
from coactive.apis import SimilaritySearchApi
from coactive.model.similarity_search_response import SimilaritySearchResponse
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse
# Defining the host is optional and defaults to https://app.coactive.ai.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: HTTPBearer
# See configuration.py for a list of all supported configuration parameters.
from YOUR_ENV import CLIENT_ID, CLIENT_SECRET
configuration = coactive.Configuration(
host = "https://app.coactive.ai",
access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)
# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = SimilaritySearchApi(api_client)
embedding_id = "b78a6e5f-5434-46c4-9e4f-ded092147584"
group_by = "sku"
file = open('/path/to/file', 'rb')
limit = 100 # (optional) if omitted the server will use the default value of 100
# example passing only required values which don't have defaults set
try:
# Get similar images grouped by the group by key
api_response = api_instance.get_similar_images_grouped(embedding_id, group_by, file)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->get_similar_images_grouped: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get similar images grouped by the group by key
api_response = api_instance.get_similar_images_grouped(embedding_id, group_by, file, limit=limit)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->get_similar_images_grouped: %s\n" % e)
|
Parameters
Name |
Type |
Description |
Notes |
embedding_id |
str |
The unique identifier for the embedding |
|
group_by |
str |
If provided the result will be grouped by the provided asset metadata key |
|
file |
file_type |
An image on which to perform similarity search |
|
limit |
int, none_type |
Max number of items to return |
[optional] if omitted the server will use the default value of 100 |
Return type
SimilaritySearchResponse
Authorization
HTTPBearer
- Content-Type: multipart/form-data
- Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
200 |
Similar images within the same embedding space |
- |
403 |
Authentication error |
- |
401 |
Unauthorized |
- |
404 |
Embedding not found |
- |
400 |
The file must be an image |
- |
422 |
Validation Error |
- |
[Back to top] [Back to API list] [Back to Model list] [Back to home]
get_similar_images_grouped_semantic
SimilaritySearchResponse get_similar_images_grouped_semantic(embedding_id, group_by, file)
Returns the images most similar to the image at the provided path within the same embedding space grouped by the group by key and optionally by the semantic notion of metadata about the assets
Example
- Bearer Authentication (HTTPBearer):
| import time
import coactive
from coactive.apis import SimilaritySearchApi
from coactive.model.similarity_search_response import SimilaritySearchResponse
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse
# Defining the host is optional and defaults to https://app.coactive.ai.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: HTTPBearer
# See configuration.py for a list of all supported configuration parameters.
from YOUR_ENV import CLIENT_ID, CLIENT_SECRET
configuration = coactive.Configuration(
host = "https://app.coactive.ai",
access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)
# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = SimilaritySearchApi(api_client)
embedding_id = "b78a6e5f-5434-46c4-9e4f-ded092147584"
group_by = "sku"
file = open('/path/to/file', 'rb')
metadata_key = "metadata_key_1" # (optional)
metadata_value = "metadata_value_1" # (optional)
limit = 100 # (optional) if omitted the server will use the default value of 100
# example passing only required values which don't have defaults set
try:
# Get similar images grouped by the group by key and semantic notion of metadata
api_response = api_instance.get_similar_images_grouped_semantic(embedding_id, group_by, file)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->get_similar_images_grouped_semantic: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get similar images grouped by the group by key and semantic notion of metadata
api_response = api_instance.get_similar_images_grouped_semantic(embedding_id, group_by, file, metadata_key=metadata_key, metadata_value=metadata_value, limit=limit)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->get_similar_images_grouped_semantic: %s\n" % e)
|
Parameters
Name |
Type |
Description |
Notes |
embedding_id |
str |
The unique identifier for the embedding |
|
group_by |
str |
If provided the result will be grouped by the provided asset metadata key |
|
file |
file_type |
An image on which to perform similarity search |
|
metadata_key |
str |
The metadata key field to add the semantic search on, if left blank all columns will be taken into consideration. Required if metadata key is passed in, else optional. |
[optional] |
metadata_value |
str |
The metadata value to use for the semantic search. Required if metadata key is passed in, else optional. |
[optional] |
limit |
int, none_type |
Max number of items to return |
[optional] if omitted the server will use the default value of 100 |
Return type
SimilaritySearchResponse
Authorization
HTTPBearer
- Content-Type: multipart/form-data
- Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
200 |
Similar images within the same embedding space |
- |
403 |
Authentication error |
- |
401 |
Unauthorized |
- |
404 |
Embedding not found |
- |
400 |
The file must be an image |
- |
422 |
Validation Error |
- |
[Back to top] [Back to API list] [Back to Model list] [Back to home]
search_images_by_text_grouped
SimilaritySearchResponse search_images_by_text_grouped(embedding_id, query)
Returns the images most similar to the text query provided within the same embedding space grouped by the group by key
Example
- Bearer Authentication (HTTPBearer):
| import time
import coactive
from coactive.apis import SimilaritySearchApi
from coactive.model.similarity_search_response import SimilaritySearchResponse
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse
# Defining the host is optional and defaults to https://app.coactive.ai.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: HTTPBearer
# See configuration.py for a list of all supported configuration parameters.
from YOUR_ENV import CLIENT_ID, CLIENT_SECRET
configuration = coactive.Configuration(
host = "https://app.coactive.ai",
access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)
# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = SimilaritySearchApi(api_client)
embedding_id = "b78a6e5f-5434-46c4-9e4f-ded092147584"
query = "A dog"
group_by = "sku" # (optional)
limit = 100 # (optional) if omitted the server will use the default value of 100
# example passing only required values which don't have defaults set
try:
# Get similar images grouped by the group by key and semantic notion of the text query
api_response = api_instance.search_images_by_text_grouped(embedding_id, query)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->search_images_by_text_grouped: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get similar images grouped by the group by key and semantic notion of the text query
api_response = api_instance.search_images_by_text_grouped(embedding_id, query, group_by=group_by, limit=limit)
print(api_response)
except coactive.ApiException as e:
print("Exception when calling SimilaritySearchApi->search_images_by_text_grouped: %s\n" % e)
|
Parameters
Name |
Type |
Description |
Notes |
embedding_id |
str |
The unique identifier for the embedding |
|
query |
str |
The query string to fetch images of |
|
group_by |
str, none_type |
If provided the result will be grouped by the provided asset metadata key |
[optional] |
limit |
int, none_type |
Max number of items to return |
[optional] if omitted the server will use the default value of 100 |
Return type
SimilaritySearchResponse
Authorization
HTTPBearer
- Content-Type: Not defined
- Accept: application/json
HTTP response details
Status code |
Description |
Response headers |
200 |
Similar images within the same embedding space |
- |
403 |
Authentication error |
- |
401 |
Unauthorized |
- |
404 |
Embedding not found |
- |
422 |
Validation Error |
- |
[Back to top] [Back to API list] [Back to Model list] [Back to home]