Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/FareedKhan-dev/ai-long-task
/ functions
Functions
222 in github.com/FareedKhan-dev/ai-long-task
⨍
Functions
222
◇
Types & classes
29
↓ 121 callers
Method
get
Get a program by ID Args: program_id: Program ID Returns: Program or None if not found
data/database.py:376
↓ 33 callers
Method
get_fragment
Get and format a smaller text fragment by name.
prompts/templates.py:210
↓ 19 callers
Function
get_fitness_score
Calculate the fitness score from a metrics dictionary, giving priority to 'combined_score' and excluding MAP-Elites feature dimensions from t
utils/metrics_utils.py:88
↓ 13 callers
Method
add
Add a program to the database Args: program: Program to add iteration: Current iteration (defaults to last_i
data/database.py:217
↓ 12 callers
Method
to_dict
Convert the Config object back to a dictionary.
config.py:441
↓ 8 callers
Method
get_template
Get a template by name.
prompts/templates.py:204
↓ 7 callers
Method
load
Load the database from disk Args: path: Path to load from
data/database.py:645
↓ 7 callers
Function
safe_numeric_average
Calculate the average of numeric values in a metrics dictionary, safely ignoring non-numeric values like strings. Args: metrics:
utils/metrics_utils.py:12
↓ 6 callers
Method
_process_evaluation_result
Process evaluation result to handle both dict and EvaluationResult returns Args: result: Raw result from evaluation func
evaluation/evaluator.py:357
↓ 6 callers
Method
run
Run the evolution process with improved parallel processing Args: iterations: Maximum number of iterations (uses config
core/controller.py:286
↓ 5 callers
Method
_sample_random_parent
Sample a completely random parent from all programs
data/database.py:1420
↓ 5 callers
Function
format_metrics_safe
Safely format a metrics dictionary for logging, handling both numeric and string values. Args: metrics: A dictionary of metric names
utils/format_utils.py:9
↓ 5 callers
Method
generate_with_context
Generate text using a system message and conversational context
llm/openai.py:70
↓ 5 callers
Method
has_artifacts
Check if this result contains any artifacts
evaluation/result.py:46
↓ 5 callers
Method
sample
Sample a program and inspirations for the next evolution step Args: num_inspirations: Number of inspiration programs to
data/database.py:388
↓ 4 callers
Method
_is_better
Determine if program1 has better FITNESS than program2 Uses fitness calculation that excludes MAP-Elites feature dimensions
data/database.py:1107
↓ 4 callers
Method
_scale_feature_value
Scale a feature value according to the configured scaling method Args: feature_name: Name of the feature dimension
data/database.py:2196
↓ 4 callers
Method
_update_feature_stats
Update statistics for a feature dimension Args: feature_name: Name of the feature dimension value: New value
data/database.py:2172
↓ 4 callers
Method
get_best_program
Get the best program based on a metric Args: metric: Metric to use for ranking (uses combined_score or average if None)
data/database.py:478
↓ 4 callers
Method
log_island_status
Log current status of all islands
data/database.py:2314
↓ 4 callers
Method
run
Run a coroutine within the pool's concurrency limit. Args: coro: The coroutine function to run. *args: Posit
utils/async_utils.py:218
↓ 4 callers
Method
update_model_params
Update parameters for all models in both evolution and evaluator ensembles.
config.py:206
↓ 3 callers
Method
_calculate_feature_coords
Calculate feature coordinates for the MAP-Elites grid Args: program: Program to calculate features for Returns:
data/database.py:840
↓ 3 callers
Method
_direct_evaluate
Directly evaluate a program using the evaluation function with timeout Args: program_path: Path to the program file
evaluation/evaluator.py:390
↓ 3 callers
Method
_fast_code_diversity
Fast approximation of code diversity using simple metrics Returns diversity score (higher = more diverse)
data/database.py:2045
↓ 3 callers
Method
_feature_coords_to_key
Convert feature coordinates to a string key Args: coords: Feature coordinates Returns: String key
data/database.py:962
↓ 3 callers
Method
_sample_exploration_parent
Sample a parent for exploration (from current island)
data/database.py:1296
↓ 3 callers
Method
_sample_from_island_weighted
Sample a parent from a specific island using fitness-weighted selection Args: island_id: The island to sample from
data/database.py:1431
↓ 3 callers
Method
build_prompt
Build a prompt for the LLM. Args: current_program: Current program code. parent_program: Parent program from
prompts/sampler.py:56
↓ 3 callers
Method
close
Close the tracer and flush remaining data
data/evolution_trace.py:284
↓ 3 callers
Method
evaluate_program
Evaluate a program and return scores Args: program_code: Code to evaluate program_id: Optional ID for loggin
evaluation/evaluator.py:153
↓ 3 callers
Function
export_traces_json
Export traces to a single JSON file with a metadata wrapper. Args: traces: A list of trace objects. output_path: The path wh
utils/trace_export_utils.py:65
↓ 3 callers
Function
extract_diffs
Extract all SEARCH/REPLACE diff blocks from a given text. Args: diff_text: The text containing diff blocks. diff_pattern: Th
utils/code_utils.py:90
↓ 3 callers
Method
get_top_programs
Get the top N programs based on a metric Args: n: Number of programs to return metric: Metric to use for ran
data/database.py:544
↓ 3 callers
Method
research_topic
Conducts autonomous web research to find the best algorithms or solutions for the task. Args: task_description:
core/researcher.py:39
↓ 3 callers
Function
run_evolution
Run evolution with flexible inputs - this is the main library API. Args: initial_program: Can be a path to a program file, the progr
api.py:36
↓ 2 callers
Method
_apply_security_filter
Apply security filtering to artifact text to remove sensitive info. Args: text: Input text. Returns:
prompts/sampler.py:613
↓ 2 callers
Method
_cleanup_stale_island_bests
Remove stale island best program references Cleans up references to programs that no longer exist in the database or are not
data/database.py:1926
↓ 2 callers
Method
_create_cascade_error_context
Create rich error context for cascade failures Args: stage: The stage where the error occurred error: The ex
evaluation/evaluator.py:703
↓ 2 callers
Method
_determine_program_type
Determine the type/category of an inspiration program Args: program: Program dictionary. feature_dimensions:
prompts/sampler.py:451
↓ 2 callers
Method
_load_from_directory
Load all templates (.txt files) and fragments (fragments.json) from a directory.
prompts/templates.py:185
↓ 2 callers
Method
_passes_threshold
Check if metrics pass a threshold Uses 'combined_score' if available (for consistency with evolution), otherwise falls back
evaluation/evaluator.py:727
↓ 2 callers
Method
_sample_model
Sample a model from the ensemble based on weights
llm/ensemble.py:90
↓ 2 callers
Method
_save_program
Save a program to disk Args: program: Program to save base_path: Base path to save to (uses config.db_path i
data/database.py:809
↓ 2 callers
Method
_submit_iteration
Submit an iteration to the process pool, optionally pinned to a specific island
core/process_parallel.py:823
↓ 2 callers
Function
apply_diff
Apply a diff to the original code using the specified SEARCH/REPLACE format. Args: original_code: The original source code string.
utils/code_utils.py:48
↓ 2 callers
Method
calculate_improvement
Calculate improvement deltas between parent and child metrics
data/evolution_trace.py:69
↓ 2 callers
Function
export_traces
A high-level wrapper to export traces to a specified format. Args: traces: A list of trace objects. output_path: The path to
utils/trace_export_utils.py:356
↓ 2 callers
Method
flush
Write buffered traces to file
data/evolution_trace.py:248
↓ 2 callers
Function
format_diff_summary
Create a human-readable summary of the changes in a list of diffs. Args: diff_blocks: A list of (search_text, replace_text) tuples.
utils/code_utils.py:139
↓ 2 callers
Function
format_feature_coordinates
Format the feature coordinates (values of MAP-Elites dimensions) for display in prompts. Args: metrics: The dictionary of all metric
utils/metrics_utils.py:148
↓ 2 callers
Method
generate
Generate text using a randomly selected model based on weights
llm/ensemble.py:74
↓ 2 callers
Method
get_artifacts
Retrieve all artifacts for a program Args: program_id: ID of the program Returns: Dictionary of art
data/database.py:2382
↓ 2 callers
Method
get_pending_artifacts
Get and clear pending artifacts for a program Args: program_id: Program ID Returns: Artifacts dicti
evaluation/evaluator.py:378
↓ 2 callers
Function
load_config
Load configuration from a YAML file, or create a default config.
config.py:451
↓ 2 callers
Method
log_prompt
Log a prompt for a program. Only logs if self.config.log_prompts is True. Args: program_id: ID of the program to log
data/database.py:2537
↓ 2 callers
Function
main
Main synchronous entry point for the script. Returns: The exit code from the asynchronous main function.
cli.py:201
↓ 2 callers
Function
parse_full_rewrite
Extract a complete code block from an LLM response for a full rewrite. Args: llm_response: The full text response from the LLM.
utils/code_utils.py:109
↓ 2 callers
Method
save
Save the database to disk Args: path: Path to save to (uses config.db_path if None) iteration: Current itera
data/database.py:596
↓ 2 callers
Method
set_templates
Set custom templates to use for this sampler instance. Args: system_template: Template name for system message.
prompts/sampler.py:42
↓ 2 callers
Method
to_dict
Convert to dictionary representation
data/database.py:97
↓ 1 callers
Method
_apply_template_variations
Apply stochastic variations to the template
prompts/sampler.py:546
↓ 1 callers
Method
_cache_diversity_value
Cache a diversity value with LRU eviction
data/database.py:2155
↓ 1 callers
Method
_calculate_complexity_bin
Calculate the bin index for a given complexity value using feature scaling. Args: complexity: The complexity value (code
data/database.py:908
↓ 1 callers
Method
_calculate_diversity_bin
Calculate the bin index for a given diversity value using feature scaling. Args: diversity: The average fast code divers
data/database.py:935
↓ 1 callers
Method
_calculate_island_diversity
Calculate diversity within an island (deterministic version)
data/database.py:2010
↓ 1 callers
Method
_call_api
Make the actual API call
llm/openai.py:168
↓ 1 callers
Method
_cascade_evaluate
Run cascade evaluation with increasingly challenging test cases Args: program_path: Path to the program file Re
evaluation/evaluator.py:420
↓ 1 callers
Method
_cleanup_old_artifacts
Remove artifact directories older than the configured retention period. Args: checkpoint_path: The path of the current c
data/database.py:2448
↓ 1 callers
Method
_cosine_similarity
Adapted from SakanaAI/ShinkaEvolve (Apache-2.0 License) Original source: https://github.com/SakanaAI/ShinkaEvolve/blob/main/shinka/da
data/database.py:974
↓ 1 callers
Method
_create_artifact_dir
Create artifact directory for a program
data/database.py:2434
↓ 1 callers
Method
_create_database_snapshot
Create a serializable snapshot of the database state
core/process_parallel.py:492
↓ 1 callers
Method
_deserialize_feature_stats
Deserialize feature_stats from loaded JSON Args: stats_dict: Dictionary loaded from JSON Returns: P
data/database.py:2282
↓ 1 callers
Method
_distribute_programs_to_islands
Distribute loaded programs across islands when no island metadata exists
data/database.py:795
↓ 1 callers
Method
_enforce_population_limit
Enforce the population size limit by removing worst programs if needed Args: exclude_program_id: Program ID to never rem
data/database.py:1682
↓ 1 callers
Method
_extract_unique_features
Extract unique features of an inspiration program Args: program: Program dictionary. Returns: Strin
prompts/sampler.py:484
↓ 1 callers
Method
_format_evolution_history
Format the evolution history section for the prompt
prompts/sampler.py:236
↓ 1 callers
Method
_format_inspirations_section
Format the inspirations section for the prompt Args: inspirations: List of inspiration programs. language: P
prompts/sampler.py:399
↓ 1 callers
Method
_format_metrics
Format metrics for the prompt using safe formatting
prompts/sampler.py:162
↓ 1 callers
Method
_get_artifact_size
Get size of an artifact value in bytes
data/database.py:2413
↓ 1 callers
Method
_get_cached_diversity
Get diversity score for a program using cache and reference set Args: program: The program to calculate diversity for
data/database.py:2073
↓ 1 callers
Method
_get_client_model
Initializes and returns the correct OpenAI or AzureOpenAI client and model name.
llm/embedding.py:57
↓ 1 callers
Method
_identify_improvement_areas
Identify improvement areas with proper fitness/feature separation
prompts/sampler.py:176
↓ 1 callers
Method
_is_novel
Determine if a program is novel based on diversity to existing programs Args: program_id: ID of Program to check
data/database.py:1064
↓ 1 callers
Function
_lazy_init_worker_components
Lazily initialize expensive components on first use
core/process_parallel.py:142
↓ 1 callers
Method
_llm_evaluate
Use LLM to evaluate code quality Args: program_code: Code to evaluate program_id: Optional ID for logging
evaluation/evaluator.py:608
↓ 1 callers
Method
_llm_judge_novelty
Use LLM to judge if a program is novel compared to a similar existing program
data/database.py:997
↓ 1 callers
Method
_load_artifact_dir
Load artifacts from a directory
data/database.py:2512
↓ 1 callers
Method
_load_checkpoint
Load state from a checkpoint directory
core/controller.py:583
↓ 1 callers
Method
_load_evaluation_function
Load the evaluation function from the evaluation file
evaluation/evaluator.py:83
↓ 1 callers
Method
_load_initial_program
Load the initial program from file
core/controller.py:279
↓ 1 callers
Function
_prepare_evaluator
Helper function to convert the flexible 'evaluator' input into a file path.
api.py:209
↓ 1 callers
Function
_prepare_program
Helper function to convert the flexible 'initial_program' input into a file path.
api.py:172
↓ 1 callers
Method
_reconstruct_islands
Reconstruct island assignments from saved metadata Args: saved_islands: List of island program ID lists from metadata
data/database.py:715
↓ 1 callers
Method
_render_artifacts
Render artifacts for prompt inclusion Args: artifacts: Dictionary of artifact name to content. Returns:
prompts/sampler.py:558
↓ 1 callers
Function
_resolve_env_var
Resolve ${VAR} environment variable reference in a string value. The pattern must match the entire string (e.g., "${OPENAI_API_KEY}"), no
config.py:25
↓ 1 callers
Function
_run_evolution_async
Asynchronous implementation of the run_evolution function.
api.py:64
↓ 1 callers
Method
_run_evolution_with_checkpoints
Run evolution with checkpoint saving support
core/controller.py:596
↓ 1 callers
Method
_safe_decode_artifact
Safely decode an artifact value to string Args: value: Artifact value (string or bytes). Returns: S
prompts/sampler.py:587
↓ 1 callers
Method
_sample_exploitation_parent
Sample a parent for exploitation (from archive/elite programs)
data/database.py:1380
next →
1–100 of 222, ranked by callers