PluginDataImageSearch Model
PluginDataImageSearch model for storing the configuration of an ImageSearchPlugin.
Note
Experimental. The ImageSearchPlugin was designed and coded by Claude Code (Anthropic’s Claude Opus 5.5), with Lawrence McDaniel as co-author. It is experimental.
- class smarter.apps.llmtool.models.plugin_data_image_search.PluginDataImageSearch(*args, **kwargs)[source]
Bases:
PluginDataBaseStores the configuration of an ImageSearchPlugin, which searches the Brave Image Search API and returns image urls.
query_termsare appended to every query that the LLM sends. The search parameters (count,country,search_lang,safesearchandspellcheck) map 1:1 to the Brave Image Search API’s other query parameters. The filters (file_type,min_width,min_height,allowed_domainsandblocked_domains) are applied by Smarter to Brave’s results. The Brave Search API key is stored in a Smarter Secret, which is referred to by name, and read when the plugin is called. If it is unavailable then the plugin returns no images, and logs a warning that explains how to create it.See also
PluginDataBase
- Parameters:
id (Unknown) – Primary key: ID
created_at (Unknown) – Created at
updated_at (Unknown) – Updated at
description (Unknown) – Description. A brief description of what this plugin returns. Be verbose, but not too verbose.
parameters (Unknown) – Parameters. A JSON dict containing parameter names and data types. Example: {‘required’: [], ‘properties’: {‘max_cost’: {‘type’: ‘float’, ‘description’: ‘the maximum cost that a student is willing to pay for a course.’}, ‘description’: {‘enum’: [‘AI’, ‘mobile’, ‘web’, ‘database’, ‘network’, ‘neural networks’], ‘type’: ‘string’, ‘description’: ‘areas of specialization for courses in the catalogue.’}}}
test_values (Unknown) – Test values. A JSON dict containing test values for each parameter. Example: {‘city’: ‘San Francisco’}
api_key_secret_name (Unknown) – Api key secret name. The name of the Secret that contains the Brave Search API key.
query_terms (Unknown) – Query terms. Search terms appended to every query that the LLM sends.
llm_search_params (Unknown) – Llm search params. Whether the LLM may set every search parameter in each tool call. The others are then defaults.
count (Unknown) – Count. The maximum number of images per search.
country (Unknown) – Country. A two letter country code, or all for worldwide results.
search_lang (Unknown) – Search lang. Prefer images from content in this language, e.g. en.
safesearch (Unknown) – Safesearch. Adult content filtering: strict or off.
spellcheck (Unknown) – Spellcheck. Whether Brave may correct the spelling of the query.
file_type (Unknown) – File type. Only images of these file types, e.g. jpg|png.
min_width (Unknown) – Min width. Only images at least this many pixels wide. Images of unknown width are skipped.
min_height (Unknown) – Min height. Only images at least this many pixels high. Images of unknown height are skipped.
allowed_domains (Unknown) – Allowed domains. If not empty, only images from web pages on these domains, and their subdomains.
blocked_domains (Unknown) – Blocked domains. Never images on these domains, nor from web pages on them, including their subdomains.
validate_urls (Unknown) – Validate urls. Only return image urls that respond to a request with HTTP 200.
timeout (Unknown) – Timeout. Seconds to wait for each web request.
cache_ttl (Unknown) – Cache ttl. Seconds to cache search results. 0 disables caching.
Relationship fields:
- Parameters:
plugin (Unknown) – Plugin (related name:
plugin_data_base_plugin)plugindatabase_ptr (Unknown) – Primary key: Plugindatabase ptr (related name:
plugindataimagesearch)
- exception DoesNotExist
Bases:
DoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- exception NotUpdated
Bases:
NotUpdated
- allowed_domains
-
Allowed domains. If not empty, only images from web pages on these domains, and their subdomains.
- Type:
Type
- api_key_secret_name
-
Api key secret name. The name of the Secret that contains the Brave Search API key.
- Type:
Type
- blocked_domains
-
Blocked domains. Never images on these domains, nor from web pages on them, including their subdomains.
- Type:
Type
- cache_ttl
-
Cache ttl. Seconds to cache search results. 0 disables caching.
- Type:
Type
- count
-
Count. The maximum number of images per search.
- Type:
Type
- property domain_policy: DomainPolicy
The plugin’s domain policy, which applies to the web pages that images come from.
- property file_types: list[str]
The permitted file types, e.g.
['jpg', 'png'].Empty if any file type is permitted.
- classmethod get_cached_data_by_plugin(plugin, invalidate=False)[source]
Return a single instance of PluginDataImageSearch by plugin, with caching.
- Parameters:
plugin (
PluginMeta) – The plugin whose data should be retrieved.invalidate (
bool) – If True, invalidate the cache before retrieving.
- Return type:
- Returns:
The PluginDataImageSearch instance.
- Raises:
PluginDataImageSearch.DoesNotExist – If the plugin has no image search data.
- classmethod get_cached_object(*args, invalidate=False, pk=None, plugin=None, **kwargs)[source]
Retrieve a model instance by primary key or by plugin, with caching.
- Parameters:
- Return type:
- Returns:
The model instance.
- Raises:
PluginDataImageSearch.DoesNotExist – If the plugin has no image search data.
- get_safesearch_display(*, field=<django.db.models.CharField: safesearch>)
Shows the label of the
safesearch. Seeget_FOO_display()for more information.
- llm_search_params
-
Llm search params. Whether the LLM may set every search parameter in each tool call. The others are then defaults.
- Type:
Type
- min_height
-
Min height. Only images at least this many pixels high. Images of unknown height are skipped.
- Type:
Type
- min_width
-
Min width. Only images at least this many pixels wide. Images of unknown width are skipped.
- Type:
Type
- plugindatabase_ptr
OneToOneFieldtoPluginDataBasePrimary key: Plugindatabase ptr (related name:
plugindataimagesearch)- Type:
Type
- plugindatabase_ptr_id
Internal field, use
plugindatabase_ptrinstead.
- query_terms
-
Query terms. Search terms appended to every query that the LLM sends.
- Type:
Type
- safesearch
-
Safesearch. Adult content filtering: strict or off.
Choices:
offstrict
- Type:
Type
- sanitized_return_data(params=None)[source]
Return the configuration of the plugin, without its api key.
The image urls are returned by
smarter.apps.llmtool.plugin.image_search.ImageSearchPlugin.tool_call_fetch_plugin_response().
- search_lang
-
Search lang. Prefer images from content in this language, e.g. en.
- Type:
Type
- search_params(query=None, count=None, llm_params=None)[source]
Return the Brave Image Search API query parameters.
- Parameters:
query (
str|None) – The LLM’s search query, to whichquery_termsare appended.count (
int|None) – The number of images, which defaults tocount. It may not exceedcount, or, ifllm_search_params,MAX_COUNT.llm_params (
dict[str,Any] |None) – The search parameters that the LLM set in its tool call:country,search_lang,safesearchandspellcheck. They are used only ifllm_search_params, and invalid values are ignored, in favor of the plugin’s own.
- Return type:
- Returns:
The query parameters, without empty values.
- spellcheck
-
Spellcheck. Whether Brave may correct the spelling of the query.
- Type:
Type
- timeout
-
Timeout. Seconds to wait for each web request.
- Type:
Type
- validate()[source]
Validate the configuration.
- Raises:
SmarterValueError – If a value is out of range, or a search parameter or filter is not permitted.
- Return type:
- validate_urls
-
Validate urls. Only return image urls that respond to a request with HTTP 200.
- Type:
Type