Submodules
biolm.models.examples module
Generate SDK usage examples for BioLM models.
- class biolm.models.examples.ExampleGenerator(api_key: str | None = None, base_url: str | None = None)
Bases:
objectGenerate SDK usage examples for BioLM models.
- async fetch_community_models() → List[Dict[str, Any]]
Fetch list of available models.
Uses biolm-hub OpenAPI when in hub mode, otherwise the platform community-api-models endpoint.
- async fetch_model_details(model_slug: str, code_examples: bool = False, exclude_docs_html: bool = True) → Dict[str, Any] | None
Fetch detailed information for a specific model from community-api-models endpoint.
- Args:
model_slug: Model slug (e.g., ‘esmfold’) code_examples: If True, include code examples in the response exclude_docs_html: If True, exclude HTML documentation
- Returns:
Model details dictionary or None if not found
- async generate_example(model_name: str, action: str | None = None, format: str = 'python', input_type: str | None = None) → str
Generate example for a model and action.
- Args:
model_name: Name of the model. action: Action name (encode, predict, generate, lookup). If None, generates for all available actions. format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). input_type: Optional input type override.
- Returns:
Formatted example string.
- async get_model_schema(model_name: str, action: str) → Dict[str, Any] | None
Get schema for a model and action.
- Args:
model_name: Name of the model. action: Action name (encode, predict, generate, lookup).
- Returns:
Schema dictionary or None if not found.
- async shutdown()
Close HTTP client connections.
- biolm.models.examples.ExampleGeneratorSync
alias of
BlockingExampleGeneratorSync
- biolm.models.examples.get_example(model_name: str, action: str | None = None, format: str = 'python', api_key: str | None = None, base_url: str | None = None) → str
Generate SDK usage example for a model (synchronous).
- Args:
model_name: Name of the model. action: Action name (optional, will try to detect). format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). api_key: Optional API key. base_url: Optional base URL.
- Returns:
Formatted example string.
- async biolm.models.examples.get_example_async(model_name: str, action: str | None = None, format: str = 'python', api_key: str | None = None, base_url: str | None = None) → str
Generate SDK usage example for a model (async).
- Args:
model_name: Name of the model. action: Action name (optional, will try to detect). format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). api_key: Optional API key. base_url: Optional base URL.
- Returns:
Formatted example string.
- biolm.models.examples.get_model_details(model_slug: str, code_examples: bool = False, exclude_docs_html: bool = True, api_key: str | None = None, base_url: str | None = None) → Dict[str, Any] | None
Fetch detailed information for a specific model (synchronous).
- Args:
model_slug: Model slug (e.g., ‘esmfold’). code_examples: If True, include code examples in the response. exclude_docs_html: If True, exclude HTML documentation. api_key: Optional API key. base_url: Optional base URL.
- Returns:
Model details dictionary or None if not found.
- biolm.models.examples.list_models(api_key: str | None = None, base_url: str | None = None) → List[Dict[str, Any]]
List all available models from community-api-models endpoint (synchronous).
- Args:
api_key: Optional API key. base_url: Optional base URL.
- Returns:
List of model dictionaries.
- async biolm.models.examples.list_models_async(api_key: str | None = None, base_url: str | None = None) → List[Dict[str, Any]]
List all available models from community-api-models endpoint (async).
- Args:
api_key: Optional API key. base_url: Optional base URL.
- Returns:
List of model dictionaries.
Module contents
High-level model interface for BioLM (Model, encode/predict/generate helpers).
- class biolm.models.BioLM(*, entity: str, action: str, type: str | None = None, items: Any | List[Any], params: dict | None = None, api_key: str | None = None, **kwargs)
Bases:
objectUniversal client for BioLM API (deprecated, use Model instead).
This class is kept for backward compatibility. New code should use Model.
- run() → Any
Run the specified action on the entity with the given item(s). Returns the result(s), unpacked if a single item was provided.
- class biolm.models.Model(name: str, api_key: str | None = None, **kwargs)
Bases:
objectUser-friendly model interface for BioLM API.
- Args:
name (str): The model name (e.g., ‘esm2-8m’, ‘esmfold’). api_key (Optional[str]): API key for authentication.
**kwargs: Additional arguments passed to BioLMApi.
- encode(items: Any | List[Any], type: str | None = None, params: dict | None = None, progress: bool = True, progress_callback: Callable[[int, int], None] | None = None, **kwargs)
Encode using the model.
- Args:
items: Single item or list of items to encode. type: Type of item (e.g., ‘sequence’). Required if items are not dicts. params: Optional parameters for the encoding. progress: If True (default), show Rich progress bar (multiple items only). progress_callback: Optional (completed, total) callback; overrides progress=True if provided.
**kwargs: Additional arguments (stop_on_error, output, file_path, etc.).- Returns:
Encoding results.
- generate(items: Any | List[Any], type: str | None = None, params: dict | None = None, progress: bool = True, progress_callback: Callable[[int, int], None] | None = None, **kwargs)
Generate using the model.
- Args:
items: Single item or list of items to generate from. type: Type of item (e.g., ‘context’, ‘pdb’). Required if items are not dicts. params: Optional parameters for the generation. progress: If True (default), show Rich progress bar (multiple items only). progress_callback: Optional (completed, total) callback; overrides progress=True if provided.
**kwargs: Additional arguments (stop_on_error, output, file_path, etc.).- Returns:
Generation results.
- get_example(action: str | None = None, format: str = 'python', **kwargs) → str
Get SDK usage example for this model.
- Args:
action: Action name (encode, predict, generate, lookup). If None, generates for first available action. format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’).
**kwargs: Additional arguments passed to ExampleGenerator (base_url).- Returns:
Formatted example string.
- get_examples(format: str = 'python', **kwargs) → str
Get SDK usage examples for all supported actions of this model.
- Args:
format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’).
**kwargs: Additional arguments passed to ExampleGenerator (base_url).- Returns:
Formatted examples string with all actions.
- lookup(query: dict | List[dict], **kwargs)
Lookup using the model.
- Args:
query: Query dict or list of query dicts.
**kwargs: Additional arguments (raw, output, file_path).- Returns:
Lookup results.
- predict(items: Any | List[Any], type: str | None = None, params: dict | None = None, progress: bool = True, progress_callback: Callable[[int, int], None] | None = None, **kwargs)
Predict using the model.
- Args:
items: Single item or list of items to predict. type: Type of item (e.g., ‘sequence’, ‘pdb’). Required if items are not dicts. params: Optional parameters for the prediction. progress: If True (default), show Rich progress bar (multiple items only). progress_callback: Optional (completed, total) callback; overrides progress=True if provided.
**kwargs: Additional arguments (stop_on_error, output, file_path, etc.).- Returns:
Prediction results.
- biolm.models.encode(model_name: str, items: Any | List[Any], type: str | None = None, params: dict | None = None, **kwargs)
Quick encoding using a model.
- biolm.models.generate(model_name: str, items: Any | List[Any], type: str | None = None, params: dict | None = None, **kwargs)
Quick generation using a model.
- biolm.models.predict(model_name: str, items: Any | List[Any], type: str | None = None, params: dict | None = None, **kwargs)
Quick prediction using a model.