haive.core.utils.haive_discovery.base_analyzer¶

Base analyzer class and common functionality for component analysis.

Classes¶

ComponentAnalyzer

Abstract base class for component analyzers.

Module Contents¶

class haive.core.utils.haive_discovery.base_analyzer.ComponentAnalyzer[source]¶

Bases: abc.ABC

Abstract base class for component analyzers.

abstractmethod analyze(obj, module_path)[source]¶

Analyze the object and return component info.

Parameters:
  • obj (Any)

  • module_path (str)

Return type:

haive.core.utils.haive_discovery.component_info.ComponentInfo

abstractmethod can_analyze(obj)[source]¶

Check if this analyzer can handle the given object.

Parameters:

obj (Any)

Return type:

bool

create_engine_config(component_info)[source]¶

Create a Haive engine config if possible.

Parameters:

component_info (haive.core.utils.haive_discovery.component_info.ComponentInfo)

Return type:

Any | None

create_pydantic_model(cls, force_serializable=False)[source]¶

Create a Pydantic model from a class signature.

Parameters:
Return type:

type[pydantic.BaseModel]

create_tool(component_info)[source]¶

Convert component to a StructuredTool if possible.

Parameters:

component_info (haive.core.utils.haive_discovery.component_info.ComponentInfo)

Return type:

Any | None

detect_env_vars(source_code)[source]¶

Detect environment variables in source code.

Parameters:

source_code (str)

Return type:

list[str]

extract_schema(obj)[source]¶

Extract schema information from object.

Parameters:

obj (Any)

Return type:

dict[str, Any]

get_source_code(obj)[source]¶

Extract source code from object.

Parameters:

obj (Any)

Return type:

str

safe_get_class_name(obj)[source]¶

Safely get the class name of an object.

Parameters:

obj (Any)

Return type:

str

safe_get_name(obj, default_prefix='Component')[source]¶

Safely get the name of an object.

Parameters:
  • obj (Any)

  • default_prefix (str)

Return type:

str