code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def test_on_data_returns_message(mock_message): """Test that on_data returns the same IngestControlMessage object it receives.""" result = on_data(mock_message) assert result is mock_message, "on_data should return the input IngestControlMessage object."
Test that on_data returns the same IngestControlMessage object it receives.
test_on_data_returns_message
python
NVIDIA/nv-ingest
tests/service_tests/modules/injectors/test_task_injector.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/modules/injectors/test_task_injector.py
Apache-2.0
def test_process_message_normal( mock_IngestControlMessage, mock_ControlMessageTask, mock_validate_ingest_job, mock_annotate_cm, mock_format_trace_id, ): """ Test that process_message correctly processes a valid job. The job dict contains: - "job_id": identifier - "job_payloa...
Test that process_message correctly processes a valid job. The job dict contains: - "job_id": identifier - "job_payload": a list of dicts to be converted to a DataFrame - "tasks": a list of task dicts (each with optional id, type, task_properties) - "tracing_options": options that trigg...
test_process_message_normal
python
NVIDIA/nv-ingest
tests/service_tests/modules/sources/test_message_broker_task_source.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/modules/sources/test_message_broker_task_source.py
Apache-2.0
def test_fetch_and_process_messages_dict_job(mock_process_message): """ Test that when the client returns a job as a dictionary, fetch_and_process_messages yields a processed control message. """ job = { "job_id": "job_dict", "job_payload": [{"x": 1}, {"x": 2}], "tasks": [], ...
Test that when the client returns a job as a dictionary, fetch_and_process_messages yields a processed control message.
test_fetch_and_process_messages_dict_job
python
NVIDIA/nv-ingest
tests/service_tests/modules/sources/test_message_broker_task_source.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/modules/sources/test_message_broker_task_source.py
Apache-2.0
def test_fetch_and_process_messages_base_model_job(mock_process_message): """ Test that when the client returns a job as a BaseModel with response_code 0, the job.response is JSON-decoded and processed. """ job_dict = { "job_id": "job_bm", "job_payload": [{"y": "a"}], "tasks"...
Test that when the client returns a job as a BaseModel with response_code 0, the job.response is JSON-decoded and processed.
test_fetch_and_process_messages_base_model_job
python
NVIDIA/nv-ingest
tests/service_tests/modules/sources/test_message_broker_task_source.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/modules/sources/test_message_broker_task_source.py
Apache-2.0
def test_fetch_and_process_messages_skip_on_nonzero_response_code(mock_process_message): """ Test that when the client returns a BaseModel job with a nonzero response_code, the job is skipped and not processed. Then a subsequent valid dictionary job is processed. """ response_bad = DummyResponse...
Test that when the client returns a BaseModel job with a nonzero response_code, the job is skipped and not processed. Then a subsequent valid dictionary job is processed.
test_fetch_and_process_messages_skip_on_nonzero_response_code
python
NVIDIA/nv-ingest
tests/service_tests/modules/sources/test_message_broker_task_source.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/modules/sources/test_message_broker_task_source.py
Apache-2.0
def test_fetch_and_process_messages_timeout_error(): """ Test that if client.fetch_message raises a TimeoutError, fetch_and_process_messages catches it and continues to the next message. """ call = [0] class TimeoutThenValidClient: def fetch_message(self, task_queue, count, override_fet...
Test that if client.fetch_message raises a TimeoutError, fetch_and_process_messages catches it and continues to the next message.
test_fetch_and_process_messages_timeout_error
python
NVIDIA/nv-ingest
tests/service_tests/modules/sources/test_message_broker_task_source.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/modules/sources/test_message_broker_task_source.py
Apache-2.0
def test_fetch_and_process_messages_exception_handling(): """ Test that if client.fetch_message raises a generic Exception, fetch_and_process_messages logs the error and continues fetching. """ call = [0] class ExceptionThenValidClient: def fetch_message(self, task_queue, count, overrid...
Test that if client.fetch_message raises a generic Exception, fetch_and_process_messages logs the error and continues fetching.
test_fetch_and_process_messages_exception_handling
python
NVIDIA/nv-ingest
tests/service_tests/modules/sources/test_message_broker_task_source.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/modules/sources/test_message_broker_task_source.py
Apache-2.0
def test_audio_config_schema_valid_grpc(): """Test AudioConfigSchema with a valid gRPC endpoint.""" config = AudioConfigSchema(audio_endpoints=("grpc://localhost:50051", "")) assert config.audio_endpoints == ("grpc://localhost:50051", None) assert config.audio_infer_protocol == "grpc"
Test AudioConfigSchema with a valid gRPC endpoint.
test_audio_config_schema_valid_grpc
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_audio_extractor_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_audio_extractor_schema.py
Apache-2.0
def test_audio_config_schema_valid_http(): """Test AudioConfigSchema with a valid HTTP endpoint.""" config = AudioConfigSchema(audio_endpoints=("", "http://localhost:8080")) assert config.audio_endpoints == (None, "http://localhost:8080") assert config.audio_infer_protocol == "http"
Test AudioConfigSchema with a valid HTTP endpoint.
test_audio_config_schema_valid_http
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_audio_extractor_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_audio_extractor_schema.py
Apache-2.0
def test_audio_config_schema_valid_both_endpoints(): """Test AudioConfigSchema with both gRPC and HTTP endpoints provided.""" config = AudioConfigSchema(audio_endpoints=("grpc://localhost:50051", "http://localhost:8080")) assert config.audio_endpoints == ("grpc://localhost:50051", "http://localhost:8080") ...
Test AudioConfigSchema with both gRPC and HTTP endpoints provided.
test_audio_config_schema_valid_both_endpoints
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_audio_extractor_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_audio_extractor_schema.py
Apache-2.0
def test_audio_config_schema_whitespace_endpoints(): """Test AudioConfigSchema removes whitespace-only values.""" config = AudioConfigSchema(audio_endpoints=(" ", "http://localhost:8080")) assert config.audio_endpoints == (None, "http://localhost:8080") assert config.audio_infer_protocol == "http"
Test AudioConfigSchema removes whitespace-only values.
test_audio_config_schema_whitespace_endpoints
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_audio_extractor_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_audio_extractor_schema.py
Apache-2.0
def test_audio_config_schema_default_protocol(): """Test that the default protocol is inferred correctly.""" config = AudioConfigSchema(audio_endpoints=("grpc://localhost:50051", None)) assert config.audio_infer_protocol == "grpc" config = AudioConfigSchema(audio_endpoints=(None, "http://localhost:8080...
Test that the default protocol is inferred correctly.
test_audio_config_schema_default_protocol
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_audio_extractor_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_audio_extractor_schema.py
Apache-2.0
def test_audio_extractor_schema_with_audio_config(): """Test AudioExtractorSchema with an embedded AudioConfigSchema.""" audio_config = AudioConfigSchema(audio_endpoints=("grpc://localhost:50051", "")) extractor = AudioExtractorSchema(audio_extraction_config=audio_config) assert extractor.audio_extracti...
Test AudioExtractorSchema with an embedded AudioConfigSchema.
test_audio_extractor_schema_with_audio_config
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_audio_extractor_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_audio_extractor_schema.py
Apache-2.0
def valid_module_config(): """Returns a valid job payload for testing purposes.""" return { "raise_on_failure": True, }
Returns a valid job payload for testing purposes.
valid_module_config
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_image_dedup_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_image_dedup_schema.py
Apache-2.0
def test_task_injection_schema_explicit_value(): """ Test TaskInjectionSchema with an explicit value for raise_on_failure. """ schema = TaskInjectionSchema(raise_on_failure=True) assert schema.raise_on_failure is True, "raise_on_failure should respect the explicitly provided value."
Test TaskInjectionSchema with an explicit value for raise_on_failure.
test_task_injection_schema_explicit_value
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_injection_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_injection_schema.py
Apache-2.0
def test_task_injection_schema_forbids_extra(): """ Test that TaskInjectionSchema forbids extra fields due to the 'extra = "forbid"' configuration. """ with pytest.raises(ValidationError) as excinfo: TaskInjectionSchema(raise_on_failure=False, unexpected_field="value") assert "Extra inputs a...
Test that TaskInjectionSchema forbids extra fields due to the 'extra = "forbid"' configuration.
test_task_injection_schema_forbids_extra
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_injection_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_injection_schema.py
Apache-2.0
def test_metadata_injector_schema_default(): """ Test the MetadataInjectorSchema with default values. """ schema = MetadataInjectorSchema() assert schema.raise_on_failure is False, "Default value for raise_on_failure should be False."
Test the MetadataInjectorSchema with default values.
test_metadata_injector_schema_default
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_metadata_injector_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_metadata_injector_schema.py
Apache-2.0
def test_metadata_injector_schema_explicit_value(): """ Test the MetadataInjectorSchema with an explicit value for raise_on_failure. """ schema = MetadataInjectorSchema(raise_on_failure=True) assert schema.raise_on_failure is True, "raise_on_failure should respect the explicitly provided value."
Test the MetadataInjectorSchema with an explicit value for raise_on_failure.
test_metadata_injector_schema_explicit_value
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_metadata_injector_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_metadata_injector_schema.py
Apache-2.0
def test_metadata_injector_schema_forbids_extra(): """ Test that the MetadataInjectorSchema forbids extra fields due to the 'extra = "forbid"' configuration. """ with pytest.raises(ValidationError) as excinfo: MetadataInjectorSchema(raise_on_failure=False, unexpected_field="value") assert "E...
Test that the MetadataInjectorSchema forbids extra fields due to the 'extra = "forbid"' configuration.
test_metadata_injector_schema_forbids_extra
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_metadata_injector_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_metadata_injector_schema.py
Apache-2.0
def test_metadata_injector_schema_raise_on_failure_parametrized(input_value): """ Parametrized test for different boolean values of raise_on_failure. """ schema = MetadataInjectorSchema(raise_on_failure=input_value) assert schema.raise_on_failure is input_value, f"raise_on_failure should be {input_v...
Parametrized test for different boolean values of raise_on_failure.
test_metadata_injector_schema_raise_on_failure_parametrized
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_metadata_injector_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_metadata_injector_schema.py
Apache-2.0
def test_redis_client_schema_optional_fields(use_ssl, connection_timeout, max_backoff, max_retries): """ Parametrized test for RedisClientSchema to check behavior with various combinations of optional fields. """ schema = MessageBrokerClientSchema( broker_params={"use_ssl": use_ssl}, con...
Parametrized test for RedisClientSchema to check behavior with various combinations of optional fields.
test_redis_client_schema_optional_fields
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_redis_client_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_redis_client_schema.py
Apache-2.0
def test_redis_client_schema_with_custom_host_and_port(): """ Test RedisClientSchema instantiation with custom host and port. """ custom_host = "custom_redis_host" custom_port = 1234 schema = MessageBrokerClientSchema(host=custom_host, port=custom_port) assert schema.host == custom_host ...
Test RedisClientSchema instantiation with custom host and port.
test_redis_client_schema_with_custom_host_and_port
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_redis_client_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_redis_client_schema.py
Apache-2.0
def test_redis_task_sink_schema_defaults(): """ Test RedisTaskSinkSchema with default values, including the default embedded RedisClientSchema. """ schema = MessageBrokerTaskSinkSchema() assert isinstance( schema.broker_client, MessageBrokerClientSchema ), "redis_client should be an inst...
Test RedisTaskSinkSchema with default values, including the default embedded RedisClientSchema.
test_redis_task_sink_schema_defaults
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_redis_task_sink_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_redis_task_sink_schema.py
Apache-2.0
def test_redis_task_sink_schema_custom_values(): """ Test RedisTaskSinkSchema with custom values for its fields and embedded RedisClientSchema. """ custom_redis_client = MessageBrokerClientSchema(host="custom_host", port=12345, broker_params={"use_ssl": True}) schema = MessageBrokerTaskSinkSchema(br...
Test RedisTaskSinkSchema with custom values for its fields and embedded RedisClientSchema.
test_redis_task_sink_schema_custom_values
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_redis_task_sink_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_redis_task_sink_schema.py
Apache-2.0
def test_redis_task_source_schema_custom_values(): """ Test RedisTaskSourceSchema with custom values for its fields. """ custom_redis_client = MessageBrokerClientSchema(host="custom_host", port=12345, broker_params={"use_ssl": True}) schema = MessageBrokerTaskSourceSchema( broker_client=cust...
Test RedisTaskSourceSchema with custom values for its fields.
test_redis_task_source_schema_custom_values
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_redis_task_source_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_redis_task_source_schema.py
Apache-2.0
def test_redis_task_source_schema_invalid_progress_engines(progress_engines): """ Test RedisTaskSourceSchema with invalid values for progress_engines to ensure validation catches them. """ with pytest.raises(ValidationError) as excinfo: MessageBrokerTaskSourceSchema(progress_engines=progress_eng...
Test RedisTaskSourceSchema with invalid values for progress_engines to ensure validation catches them.
test_redis_task_source_schema_invalid_progress_engines
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_redis_task_source_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_redis_task_source_schema.py
Apache-2.0
def test_text_splitter_schema_defaults(): """ Test the TextSplitterSchema with default values. """ schema = TextSplitterSchema() assert schema.tokenizer is None assert schema.chunk_size == 1024 assert schema.chunk_overlap == 150 assert schema.raise_on_failure is False
Test the TextSplitterSchema with default values.
test_text_splitter_schema_defaults
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_text_splitter_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_text_splitter_schema.py
Apache-2.0
def test_text_splitter_schema_custom_values(): """ Test the TextSplitterSchema with custom values. """ tokenizer = "meta-llama/Llama-3.2-1B" chunk_size = 500 chunk_overlap = 10 schema = TextSplitterSchema( tokenizer=tokenizer, chunk_size=chunk_size, chunk_overlap=chunk_overlap, raise...
Test the TextSplitterSchema with custom values.
test_text_splitter_schema_custom_values
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_text_splitter_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_text_splitter_schema.py
Apache-2.0
def test_text_splitter_schema_chunk_overlap_validation(chunk_size, chunk_overlap, is_valid): """ Parametrized test for validating the chunk_overlap logic in TextSplitterSchema. """ if is_valid: schema = TextSplitterSchema(chunk_size=chunk_size, chunk_overlap=chunk_overlap) assert schema....
Parametrized test for validating the chunk_overlap logic in TextSplitterSchema.
test_text_splitter_schema_chunk_overlap_validation
python
NVIDIA/nv-ingest
tests/service_tests/schemas/test_text_splitter_schema.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/schemas/test_text_splitter_schema.py
Apache-2.0
def test_is_subset_wildcard(): """Test that the special wildcard '*' matches any value.""" assert _is_subset("anything", "*") assert _is_subset(123, "*") assert _is_subset({"a": 1}, "*")
Test that the special wildcard '*' matches any value.
test_is_subset_wildcard
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_is_subset_dict_true(): """Test that a dictionary is a subset when all required keys/values are present.""" superset = {"a": 1, "b": 2, "c": 3} subset = {"a": 1, "b": 2} assert _is_subset(superset, subset)
Test that a dictionary is a subset when all required keys/values are present.
test_is_subset_dict_true
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_filter_decorator_complex_nested_match(): """ Test that a complex nested property requirement with regex and list matching is satisfied. Required task: ("taskComplex", {"nested": {"key": "regex:^start"}, "list": [1, 2]}) Dummy task: - type: "taskComplex" - properties: a dict ...
Test that a complex nested property requirement with regex and list matching is satisfied. Required task: ("taskComplex", {"nested": {"key": "regex:^start"}, "list": [1, 2]}) Dummy task: - type: "taskComplex" - properties: a dict with a nested dict whose 'key' starts with "start" ...
test_filter_decorator_complex_nested_match
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_filter_decorator_complex_nested_no_match(): """ Test that a complex nested property requirement fails when nested values do not match. Required task: ("taskComplex", {"nested": {"key": "regex:^start"}, "list": [1, 2, 3]}) Dummy task: - type: "taskComplex" - properties: a dic...
Test that a complex nested property requirement fails when nested values do not match. Required task: ("taskComplex", {"nested": {"key": "regex:^start"}, "list": [1, 2, 3]}) Dummy task: - type: "taskComplex" - properties: a dict with a nested dict whose 'key' does not start with "start"...
test_filter_decorator_complex_nested_no_match
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_filter_decorator_multiple_required_conditions_match(): """ Test that multiple property conditions within a single required task tuple are all satisfied. Required task: ("taskMulti", {"a": 1}, {"b": 2}) Dummy task: - type: "taskMulti" - properties: a dict that includes 'a': 1...
Test that multiple property conditions within a single required task tuple are all satisfied. Required task: ("taskMulti", {"a": 1}, {"b": 2}) Dummy task: - type: "taskMulti" - properties: a dict that includes 'a': 1 and 'b': 2 (along with extra data).
test_filter_decorator_multiple_required_conditions_match
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_filter_decorator_multiple_required_conditions_no_match(): """ Test that if not all property conditions within a required task tuple are satisfied, the function is not executed. Required task: ("taskMulti", {"a": 1}, {"b": 2}) Dummy task: - type: "taskMulti" - properties:...
Test that if not all property conditions within a required task tuple are satisfied, the function is not executed. Required task: ("taskMulti", {"a": 1}, {"b": 2}) Dummy task: - type: "taskMulti" - properties: a dict that satisfies 'a': 1 but has 'b': 3 (which does not match the req...
test_filter_decorator_multiple_required_conditions_no_match
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_filter_decorator_pydantic_properties_match(): """ Test that the decorator correctly handles Pydantic model instances as task properties. Required task: ("taskPydantic", {"a": 10, "b": "hello"}) Dummy task: - type: "taskPydantic" - properties: a DummyModel instance with value...
Test that the decorator correctly handles Pydantic model instances as task properties. Required task: ("taskPydantic", {"a": 10, "b": "hello"}) Dummy task: - type: "taskPydantic" - properties: a DummyModel instance with values that satisfy the requirement.
test_filter_decorator_pydantic_properties_match
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_filter_decorator_pydantic_properties_no_match(): """ Test that a Pydantic model instance does not satisfy the required property criteria if its values differ. Required task: ("taskPydantic", {"a": 10, "b": "world"}) Dummy task: - type: "taskPydantic" - properties: a DummyMod...
Test that a Pydantic model instance does not satisfy the required property criteria if its values differ. Required task: ("taskPydantic", {"a": 10, "b": "world"}) Dummy task: - type: "taskPydantic" - properties: a DummyModel instance that does not match the required properties.
test_filter_decorator_pydantic_properties_no_match
python
NVIDIA/nv-ingest
tests/service_tests/util/flow_control/test_filter_by_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/flow_control/test_filter_by_task.py
Apache-2.0
def test_fetch_and_validate_module_config_valid(): """ Test the function with a valid module configuration. """ valid_config = {"name": "Test Name", "age": 30} mock_builder.get_current_module_config.return_value = valid_config validated_config = fetch_and_validate_module_config(mock_builder, Sa...
Test the function with a valid module configuration.
test_fetch_and_validate_module_config_valid
python
NVIDIA/nv-ingest
tests/service_tests/util/modules/test_config_validator.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/modules/test_config_validator.py
Apache-2.0
def test_fetch_and_validate_module_config_invalid(mock_logger): """ Test the function with an invalid module configuration, ensuring it raises ValueError and logs the error. """ invalid_config = {"name": "Test Name"} # Missing required 'age' field mock_builder.get_current_module_config.return_value...
Test the function with an invalid module configuration, ensuring it raises ValueError and logs the error.
test_fetch_and_validate_module_config_invalid
python
NVIDIA/nv-ingest
tests/service_tests/util/modules/test_config_validator.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/modules/test_config_validator.py
Apache-2.0
def test_fetch_and_validate_module_config_raises_with_no_config(): """ Test the function when no configuration is provided, ensuring it raises a ValueError. """ mock_builder.get_current_module_config.return_value = {} with pytest.raises(ValueError): fetch_and_validate_module_config(mock_bui...
Test the function when no configuration is provided, ensuring it raises a ValueError.
test_fetch_and_validate_module_config_raises_with_no_config
python
NVIDIA/nv-ingest
tests/service_tests/util/modules/test_config_validator.py
https://github.com/NVIDIA/nv-ingest/blob/master/tests/service_tests/util/modules/test_config_validator.py
Apache-2.0
def main(): """Main entry point for the Anus AI agent""" parser = argparse.ArgumentParser(description="Anus AI - Autonomous Networked Utility System") parser.add_argument("--config", type=str, default="config.yaml", help="Path to configuration file") parser.add_argument("--mode", type=str, default="sing...
Main entry point for the Anus AI agent
main
python
nikmcfly/ANUS
anus/main.py
https://github.com/nikmcfly/ANUS/blob/master/anus/main.py
MIT
def __init__(self, config_path: str = "config.yaml"): """ Initialize an AgentOrchestrator instance. Args: config_path: Path to the configuration file. """ self.config = self._load_config(config_path) self.agents: Dict[str, BaseAgent] = {} self...
Initialize an AgentOrchestrator instance. Args: config_path: Path to the configuration file.
__init__
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def execute_task(self, task: str, mode: Optional[str] = None) -> Dict[str, Any]: """ Execute a task using an appropriate agent. Args: task: The task description to execute. mode: Execution mode ("single" or "multi"). If None, uses the config default. ...
Execute a task using an appropriate agent. Args: task: The task description to execute. mode: Execution mode ("single" or "multi"). If None, uses the config default. Returns: The execution result.
execute_task
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def list_agents(self) -> List[Dict[str, Any]]: """ List all registered agents. Returns: A list of agent descriptions. """ agent_list = [] # Add primary agent agent_list.append({ "id": self.primary_agent.id, "na...
List all registered agents. Returns: A list of agent descriptions.
list_agents
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def _load_config(self, config_path: str) -> Dict[str, Any]: """ Load configuration from a YAML file. Args: config_path: Path to the configuration file. Returns: The loaded configuration. """ # Default configuration def...
Load configuration from a YAML file. Args: config_path: Path to the configuration file. Returns: The loaded configuration.
_load_config
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def _merge_configs(self, default: Dict[str, Any], override: Dict[str, Any]) -> Dict[str, Any]: """ Merge two configuration dictionaries. Args: default: Default configuration. override: Override configuration. Returns: The merged c...
Merge two configuration dictionaries. Args: default: Default configuration. override: Override configuration. Returns: The merged configuration.
_merge_configs
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def _create_primary_agent(self) -> HybridAgent: """ Create the primary agent based on configuration. Returns: A HybridAgent instance. """ # Get agent config agent_config = self.config.get("agent", {}) name = agent_config.get("name", "anus") ...
Create the primary agent based on configuration. Returns: A HybridAgent instance.
_create_primary_agent
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def _create_short_term_memory(self) -> ShortTermMemory: """ Create a short-term memory instance based on configuration. Returns: A ShortTermMemory instance. """ memory_config = self.config.get("memory", {}).get("short_term", {}) capacity = memory_conf...
Create a short-term memory instance based on configuration. Returns: A ShortTermMemory instance.
_create_short_term_memory
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def _create_long_term_memory(self) -> Optional[LongTermMemory]: """ Create a long-term memory instance based on configuration. Returns: A LongTermMemory instance, or None if disabled. """ memory_config = self.config.get("memory", {}).get("long_term", {}) ...
Create a long-term memory instance based on configuration. Returns: A LongTermMemory instance, or None if disabled.
_create_long_term_memory
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def _create_specialized_agents(self, primary_agent: HybridAgent) -> None: """ Create specialized agents for multi-agent mode. Args: primary_agent: The primary HybridAgent instance. """ # Default specialized agent roles default_roles = ["researcher", "...
Create specialized agents for multi-agent mode. Args: primary_agent: The primary HybridAgent instance.
_create_specialized_agents
python
nikmcfly/ANUS
anus/core/orchestrator.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/orchestrator.py
MIT
def __init__(self, name: Optional[str] = None, **kwargs): """ Initialize a BaseAgent instance. Args: name: Optional name for the agent. If not provided, a UUID will be generated. **kwargs: Additional configuration options for the agent. """ self.i...
Initialize a BaseAgent instance. Args: name: Optional name for the agent. If not provided, a UUID will be generated. **kwargs: Additional configuration options for the agent.
__init__
python
nikmcfly/ANUS
anus/core/agent/base_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/base_agent.py
MIT
def log_action(self, action: str, details: Dict[str, Any]) -> None: """ Log an action performed by the agent. Args: action: The name of the action. details: Details about the action. """ log_entry = { "timestamp": time.time(), ...
Log an action performed by the agent. Args: action: The name of the action. details: Details about the action.
log_action
python
nikmcfly/ANUS
anus/core/agent/base_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/base_agent.py
MIT
def get_info(self) -> Dict[str, Any]: """ Get information about the agent. Returns: A dictionary containing agent information. """ return { "id": self.id, "name": self.name, "created_at": self.created_at, "state...
Get information about the agent. Returns: A dictionary containing agent information.
get_info
python
nikmcfly/ANUS
anus/core/agent/base_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/base_agent.py
MIT
def __init__( self, name: Optional[str] = None, max_iterations: int = 10, tools: Optional[List[str]] = None, **kwargs ): """ Initialize a HybridAgent instance. Args: name: Optional name for the agent. max_iterations: Ma...
Initialize a HybridAgent instance. Args: name: Optional name for the agent. max_iterations: Maximum number of thought-action cycles to perform. tools: Optional list of tool names to load. **kwargs: Additional configuration options for the agent. ...
__init__
python
nikmcfly/ANUS
anus/core/agent/hybrid_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/hybrid_agent.py
MIT
def _assess_complexity(self, task: str) -> float: """ Assess the complexity of a task. Args: task: The task description. Returns: A complexity score between 0 and 10. """ complexity = 0.0 # Check for multiple ...
Assess the complexity of a task. Args: task: The task description. Returns: A complexity score between 0 and 10.
_assess_complexity
python
nikmcfly/ANUS
anus/core/agent/hybrid_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/hybrid_agent.py
MIT
def execute(self, task: str, **kwargs) -> Dict[str, Any]: """ Execute a task using the appropriate mode based on complexity. Args: task: The task description to execute. **kwargs: Additional parameters for task execution. Returns: ...
Execute a task using the appropriate mode based on complexity. Args: task: The task description to execute. **kwargs: Additional parameters for task execution. Returns: A dictionary containing the execution result and metadata.
execute
python
nikmcfly/ANUS
anus/core/agent/hybrid_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/hybrid_agent.py
MIT
def _execute_multi_agent(self, task: str, **kwargs) -> Dict[str, Any]: """ Execute a task using multiple specialized agents. Args: task: The task description to execute. **kwargs: Additional parameters for task execution. Returns: ...
Execute a task using multiple specialized agents. Args: task: The task description to execute. **kwargs: Additional parameters for task execution. Returns: A dictionary containing the aggregated results.
_execute_multi_agent
python
nikmcfly/ANUS
anus/core/agent/hybrid_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/hybrid_agent.py
MIT
def __init__(self, name: Optional[str] = None, max_iterations: int = 10, **kwargs): """ Initialize a ReactAgent instance. Args: name: Optional name for the agent. max_iterations: Maximum number of thought-action cycles to perform. **kwargs: Additional...
Initialize a ReactAgent instance. Args: name: Optional name for the agent. max_iterations: Maximum number of thought-action cycles to perform. **kwargs: Additional configuration options for the agent.
__init__
python
nikmcfly/ANUS
anus/core/agent/react_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/react_agent.py
MIT
def execute(self, task: str, **kwargs) -> Dict[str, Any]: """ Execute a task using the React paradigm. Args: task: The task description to execute. **kwargs: Additional parameters for task execution. Returns: A dictionary containi...
Execute a task using the React paradigm. Args: task: The task description to execute. **kwargs: Additional parameters for task execution. Returns: A dictionary containing the execution result and metadata.
execute
python
nikmcfly/ANUS
anus/core/agent/react_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/react_agent.py
MIT
def _generate_thought(self, context: Dict[str, Any]) -> str: """ Generate a thought based on the current context. Args: context: The current execution context. Returns: The thought string. """ # This should be implemented usin...
Generate a thought based on the current context. Args: context: The current execution context. Returns: The thought string.
_generate_thought
python
nikmcfly/ANUS
anus/core/agent/react_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/react_agent.py
MIT
def _decide_action(self, context: Dict[str, Any]) -> Tuple[str, Dict[str, Any]]: """ Decide on the next action to take. Args: context: The current execution context. Returns: A tuple of (action_name, action_input). """ # This ...
Decide on the next action to take. Args: context: The current execution context. Returns: A tuple of (action_name, action_input).
_decide_action
python
nikmcfly/ANUS
anus/core/agent/react_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/react_agent.py
MIT
def _execute_action(self, action_name: str, action_input: Dict[str, Any]) -> Dict[str, Any]: """ Execute an action and return the observation. Args: action_name: The name of the action to execute. action_input: The input parameters for the action. ...
Execute an action and return the observation. Args: action_name: The name of the action to execute. action_input: The input parameters for the action. Returns: The observation from executing the action.
_execute_action
python
nikmcfly/ANUS
anus/core/agent/react_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/react_agent.py
MIT
def _should_terminate(self, context: Dict[str, Any]) -> bool: """ Check if execution should terminate. Args: context: The current execution context. Returns: True if execution should terminate, False otherwise. """ # This shou...
Check if execution should terminate. Args: context: The current execution context. Returns: True if execution should terminate, False otherwise.
_should_terminate
python
nikmcfly/ANUS
anus/core/agent/react_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/react_agent.py
MIT
def _generate_final_answer(self, context: Dict[str, Any]) -> str: """ Generate a final answer based on the context. Args: context: The current execution context. Returns: The final answer string. """ # Check if we have any suc...
Generate a final answer based on the context. Args: context: The current execution context. Returns: The final answer string.
_generate_final_answer
python
nikmcfly/ANUS
anus/core/agent/react_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/react_agent.py
MIT
def __init__( self, name: Optional[str] = None, max_iterations: int = 10, tools: Optional[List[str]] = None, **kwargs ): """ Initialize a ToolAgent instance. Args: name: Optional name for the agent. max_iterations: M...
Initialize a ToolAgent instance. Args: name: Optional name for the agent. max_iterations: Maximum number of thought-action cycles to perform. tools: Optional list of tool names to load. **kwargs: Additional configuration options for the agent. ...
__init__
python
nikmcfly/ANUS
anus/core/agent/tool_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/tool_agent.py
MIT
def load_tool(self, tool_name: str) -> bool: """ Load a tool by name. Args: tool_name: The name of the tool to load. Returns: True if the tool was successfully loaded, False otherwise. """ try: # Dynamically import...
Load a tool by name. Args: tool_name: The name of the tool to load. Returns: True if the tool was successfully loaded, False otherwise.
load_tool
python
nikmcfly/ANUS
anus/core/agent/tool_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/tool_agent.py
MIT
def _decide_action(self, context: Dict[str, Any]) -> Tuple[str, Dict[str, Any]]: """ Decide on the next action to take based on the task. Args: context: The current execution context. Returns: A tuple of (action_name, action_input). "...
Decide on the next action to take based on the task. Args: context: The current execution context. Returns: A tuple of (action_name, action_input).
_decide_action
python
nikmcfly/ANUS
anus/core/agent/tool_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/tool_agent.py
MIT
def _execute_action(self, action_name: str, action_input: Dict[str, Any]) -> Dict[str, Any]: """ Execute an action using the appropriate tool. Args: action_name: The name of the action/tool to execute. action_input: The input parameters for the action. ...
Execute an action using the appropriate tool. Args: action_name: The name of the action/tool to execute. action_input: The input parameters for the action. Returns: The observation from executing the action.
_execute_action
python
nikmcfly/ANUS
anus/core/agent/tool_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/tool_agent.py
MIT
def list_available_tools(self) -> List[Dict[str, Any]]: """ List all available tools. Returns: A list of tool information dictionaries. """ tool_info = [] for name, tool in self.tools.items(): info = { "name": name, ...
List all available tools. Returns: A list of tool information dictionaries.
list_available_tools
python
nikmcfly/ANUS
anus/core/agent/tool_agent.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/agent/tool_agent.py
MIT
def __init__( self, storage_path: Optional[str] = None, index_in_memory: bool = True, **kwargs ): """ Initialize a LongTermMemory instance. Args: storage_path: Path to store memory files. If None, uses a default location. inde...
Initialize a LongTermMemory instance. Args: storage_path: Path to store memory files. If None, uses a default location. index_in_memory: Whether to keep an in-memory index for faster searches. **kwargs: Additional configuration options.
__init__
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def add(self, item: Dict[str, Any]) -> str: """ Add an item to memory and return its identifier. Args: item: The item to add to memory. Returns: A string identifier for the added item. """ # Generate a unique identifier ...
Add an item to memory and return its identifier. Args: item: The item to add to memory. Returns: A string identifier for the added item.
add
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def get(self, identifier: str) -> Optional[Dict[str, Any]]: """ Retrieve an item from memory by its identifier. Args: identifier: The identifier of the item to retrieve. Returns: The retrieved item, or None if not found. """ #...
Retrieve an item from memory by its identifier. Args: identifier: The identifier of the item to retrieve. Returns: The retrieved item, or None if not found.
get
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def update(self, identifier: str, item: Dict[str, Any]) -> bool: """ Update an item in memory. Args: identifier: The identifier of the item to update. item: The updated item. Returns: True if the update was successful, False other...
Update an item in memory. Args: identifier: The identifier of the item to update. item: The updated item. Returns: True if the update was successful, False otherwise.
update
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def delete(self, identifier: str) -> bool: """ Delete an item from memory. Args: identifier: The identifier of the item to delete. Returns: True if the deletion was successful, False otherwise. """ item_path = self._get_item_p...
Delete an item from memory. Args: identifier: The identifier of the item to delete. Returns: True if the deletion was successful, False otherwise.
delete
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def get_stats(self) -> Dict[str, Any]: """ Get statistics about the memory system. Returns: A dictionary containing memory statistics. """ # Count the number of items if self.index_in_memory: item_count = len(self.index) else: ...
Get statistics about the memory system. Returns: A dictionary containing memory statistics.
get_stats
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def _save_item(self, identifier: str, item: Dict[str, Any]) -> None: """ Save an item to disk. Args: identifier: The identifier of the item. item: The item to save. """ item_path = self._get_item_path(identifier) try: ...
Save an item to disk. Args: identifier: The identifier of the item. item: The item to save.
_save_item
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def _matches_query(self, item: Dict[str, Any], query: Dict[str, Any]) -> bool: """ Check if an item matches a query. Args: item: The item to check. query: The query to match against. Returns: True if the item matches the query, Fa...
Check if an item matches a query. Args: item: The item to check. query: The query to match against. Returns: True if the item matches the query, False otherwise.
_matches_query
python
nikmcfly/ANUS
anus/core/memory/long_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/long_term.py
MIT
def __init__( self, capacity: int = 1000, ttl: int = 3600, # Time to live in seconds **kwargs ): """ Initialize a ShortTermMemory instance. Args: capacity: Maximum number of items to store. ttl: Time to live for items in sec...
Initialize a ShortTermMemory instance. Args: capacity: Maximum number of items to store. ttl: Time to live for items in seconds. **kwargs: Additional configuration options.
__init__
python
nikmcfly/ANUS
anus/core/memory/short_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/short_term.py
MIT
def add(self, item: Dict[str, Any]) -> str: """ Add an item to memory and return its identifier. If the memory is at capacity, the least recently used item will be evicted. Args: item: The item to add to memory. Returns: A st...
Add an item to memory and return its identifier. If the memory is at capacity, the least recently used item will be evicted. Args: item: The item to add to memory. Returns: A string identifier for the added item.
add
python
nikmcfly/ANUS
anus/core/memory/short_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/short_term.py
MIT
def get(self, identifier: str) -> Optional[Dict[str, Any]]: """ Retrieve an item from memory by its identifier. Updates the access time of the item to prevent it from being evicted. Args: identifier: The identifier of the item to retrieve. ...
Retrieve an item from memory by its identifier. Updates the access time of the item to prevent it from being evicted. Args: identifier: The identifier of the item to retrieve. Returns: The retrieved item, or None if not found. ...
get
python
nikmcfly/ANUS
anus/core/memory/short_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/short_term.py
MIT
def _prune_expired(self) -> None: """ Remove items that have exceeded their time to live. """ current_time = time.time() expired_identifiers = [] for identifier, creation_time in self.creation_times.items(): if current_time - creation_time > self.ttl:...
Remove items that have exceeded their time to live.
_prune_expired
python
nikmcfly/ANUS
anus/core/memory/short_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/short_term.py
MIT
def _evict_lru(self) -> None: """ Evict the least recently used item from memory. """ while self.lru_queue: _, identifier = heapq.heappop(self.lru_queue) # Skip if the item has been deleted if identifier not in self.items: ...
Evict the least recently used item from memory.
_evict_lru
python
nikmcfly/ANUS
anus/core/memory/short_term.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/memory/short_term.py
MIT
def __init__(self, model: BaseModel, **kwargs): """ Initialize a TaskPlanner instance. Args: model: The language model to use for planning. **kwargs: Additional configuration options for the planner. """ super().__init__(**kwargs) self.mod...
Initialize a TaskPlanner instance. Args: model: The language model to use for planning. **kwargs: Additional configuration options for the planner.
__init__
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def create_plan(self, task: str, context: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: """ Create a plan for executing a task using the language model. Args: task: The task description. context: Optional context for planning. Returns: ...
Create a plan for executing a task using the language model. Args: task: The task description. context: Optional context for planning. Returns: A plan dictionary with steps and metadata.
create_plan
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def replan(self, plan: Dict[str, Any], feedback: Dict[str, Any]) -> Dict[str, Any]: """ Update a plan based on execution feedback. Args: plan: The current plan. feedback: Feedback from execution. Returns: The updated plan. ...
Update a plan based on execution feedback. Args: plan: The current plan. feedback: Feedback from execution. Returns: The updated plan.
replan
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def get_next_step(self, plan: Dict[str, Any]) -> Optional[Dict[str, Any]]: """ Get the next step to execute from a plan. Args: plan: The current plan. Returns: The next step to execute, or None if the plan is complete. """ ste...
Get the next step to execute from a plan. Args: plan: The current plan. Returns: The next step to execute, or None if the plan is complete.
get_next_step
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def mark_step_complete(self, plan: Dict[str, Any], step_id: str, result: Dict[str, Any]) -> Dict[str, Any]: """ Mark a step as complete in a plan. Args: plan: The current plan. step_id: The ID of the completed step. result: The result of the step exec...
Mark a step as complete in a plan. Args: plan: The current plan. step_id: The ID of the completed step. result: The result of the step execution. Returns: The updated plan.
mark_step_complete
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def _create_planning_prompt(self, task: str, context: Dict[str, Any]) -> str: """ Create a prompt for generating a plan. Args: task: The task description. context: Context information. Returns: A prompt string. """ ...
Create a prompt for generating a plan. Args: task: The task description. context: Context information. Returns: A prompt string.
_create_planning_prompt
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def _create_replanning_prompt(self, task: str, plan: Dict[str, Any], feedback: Dict[str, Any]) -> str: """ Create a prompt for replanning. Args: task: The task description. plan: The current plan. feedback: Feedback from execution. ...
Create a prompt for replanning. Args: task: The task description. plan: The current plan. feedback: Feedback from execution. Returns: A prompt string.
_create_replanning_prompt
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def _process_plan_data(self, task: str, plan_data: Dict[str, Any]) -> Dict[str, Any]: """ Process raw plan data into a structured plan. Args: task: The task description. plan_data: Raw plan data from the model. Returns: A structur...
Process raw plan data into a structured plan. Args: task: The task description. plan_data: Raw plan data from the model. Returns: A structured plan dictionary.
_process_plan_data
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def _get_remaining_steps(self, plan: Dict[str, Any]) -> List[Dict[str, Any]]: """ Get the remaining steps from a plan. Args: plan: The current plan. Returns: A list of remaining steps. """ steps = plan.get("steps", []) ...
Get the remaining steps from a plan. Args: plan: The current plan. Returns: A list of remaining steps.
_get_remaining_steps
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def _find_executable_step(self, plan: Dict[str, Any]) -> Optional[Dict[str, Any]]: """ Find a step that can be executed (all dependencies satisfied). Args: plan: The current plan. Returns: An executable step, or None if none found. ""...
Find a step that can be executed (all dependencies satisfied). Args: plan: The current plan. Returns: An executable step, or None if none found.
_find_executable_step
python
nikmcfly/ANUS
anus/core/planning/task_planner.py
https://github.com/nikmcfly/ANUS/blob/master/anus/core/planning/task_planner.py
MIT
def __init__(self, default_model_config: Optional[Dict[str, Any]] = None): """ Initialize a ModelRouter instance. Args: default_model_config: Configuration for the default model. """ self.models: Dict[str, BaseModel] = {} self.model_classes: Dict[str,...
Initialize a ModelRouter instance. Args: default_model_config: Configuration for the default model.
__init__
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT
def register_model(self, name: str, model: BaseModel) -> None: """ Register a model instance. Args: name: A unique name for the model. model: The model instance to register. """ self.models[name] = model logging.info(f"Registered model: {n...
Register a model instance. Args: name: A unique name for the model. model: The model instance to register.
register_model
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT
def register_model_class(self, provider: str, model_class: Type[BaseModel]) -> None: """ Register a model class for a provider. Args: provider: The model provider name. model_class: The model class to register. """ self.model_classes[provider] = m...
Register a model class for a provider. Args: provider: The model provider name. model_class: The model class to register.
register_model_class
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT
def get_model(self, name_or_config: Union[str, Dict[str, Any]]) -> BaseModel: """ Get a model instance by name or create one from config. Args: name_or_config: Either a model name or a model configuration dictionary. Returns: A model instance...
Get a model instance by name or create one from config. Args: name_or_config: Either a model name or a model configuration dictionary. Returns: A model instance.
get_model
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT
def get_default_model(self) -> BaseModel: """ Get the default model, creating it if necessary. Returns: The default model instance. """ if self.default_model is None: self.default_model = self._create_model_from_config(self.default_model_config) ...
Get the default model, creating it if necessary. Returns: The default model instance.
get_default_model
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT
def select_model_for_task(self, task: str, requirements: Dict[str, Any] = None) -> BaseModel: """ Select an appropriate model for a given task. Args: task: The task description. requirements: Optional requirements for the model. Returns: ...
Select an appropriate model for a given task. Args: task: The task description. requirements: Optional requirements for the model. Returns: The selected model instance.
select_model_for_task
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT
def _create_model_from_config(self, config: Dict[str, Any]) -> BaseModel: """ Create a model instance from a configuration dictionary. Args: config: The model configuration. Returns: A model instance. """ # Get the provider ...
Create a model instance from a configuration dictionary. Args: config: The model configuration. Returns: A model instance.
_create_model_from_config
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT
def list_available_models(self) -> List[Dict[str, Any]]: """ List all available models. Returns: A list of model information dictionaries. """ models_info = [] # Add instantiated models for name, model in self.models.items(): ...
List all available models. Returns: A list of model information dictionaries.
list_available_models
python
nikmcfly/ANUS
anus/models/model_router.py
https://github.com/nikmcfly/ANUS/blob/master/anus/models/model_router.py
MIT