← Về thư mục
skills/retrosynthesis_planning/kernel.py
- ReactionEvidenceProvider · class · L44-L58 — class ReactionEvidenceProvider(Protocol)
- fetch_reaction_evidence · method · L55-L58 — def fetch_reaction_evidence( self, reaction_briefs: list[dict[str, Any]] ) -> dict[str, Any] | list[dict[str, Any]]
- StaticReactionEvidenceProvider · class · L61-L73 — class StaticReactionEvidenceProvider
- init · method · L66-L67 — def init(self, evidence: dict[str, Any] | list[dict[str, Any]]) -> None
- fetch_reaction_evidence · method · L69-L73 — def fetch_reaction_evidence( self, reaction_briefs: list[dict[str, Any]] ) -> dict[str, Any] | list[dict[str, Any]]
- OpenAI4SLLMReactionEvidenceProvider · class · L76-L214 — class OpenAI4SLLMReactionEvidenceProvider
- init · method · L95-L118 — def init( self, *, llm: Any, search: Any, fetch: Any | None = None, doi_verifier: Any | None = None, max_reactions: int = 12, max_queries_per_reaction: int = 2, results_per_query: int = 5, fetch_top_results: int = 1, ) -> None
- fetch_reaction_evidence · method · L120-L147 — def fetch_reaction_evidence( self, reaction_briefs: list[dict[str, Any]] ) -> dict[str, list[dict[str, Any]]]
- _retrieve_sources · method · L149-L214 — def _retrieve_sources( self, briefs: list[dict[str, Any]], query_plan: dict[str, list[str]], ) -> list[dict[str, Any]]
- build_host_web_fetch_doi_verifier · function · L217-L263 — def build_host_web_fetch_doi_verifier(web_fetch: Any) -> Any
- verify · function · L227-L261 — def verify(dois: Iterable[str]) -> dict[str, dict[str, Any]]
- canonicalize_smiles · function · L266-L279 — def canonicalize_smiles(smiles: str) -> str
- reject_owned_switches · function · L291-L306 — def reject_owned_switches( extra_args: Iterable[str], *, owned: Iterable[str] = COMMAND_OWNED_SWITCHES ) -> None
- build_aizynth_command · function · L309-L333 — def build_aizynth_command( smiles: str, config_path: str, output_path: str | None = None, conda_env: str | None = None, extra_args: Iterable[str] | None = None, ) -> list[str]
- command_to_shell · function · L336-L338 — def command_to_shell(command: Iterable[str]) -> str
- load_aizynth_routes · function · L341-L344 — def load_aizynth_routes(path: str | Path) -> Any
- normalize_routes · function · L347-L352 — def normalize_routes(payload: Any) -> list[dict[str, Any]]
- rank_routes · function · L355-L405 — def rank_routes( routes: Iterable[dict[str, Any]], *, reaction_evidence: dict[str, Any] | list[dict[str, Any]] | None = None, constraints: dict[str, Any] | None = None, decision_weights: dict[str, float] | None = None, ) -> list[dict[str, Any]]
- key · function · L394-L400 — def key(route: dict[str, Any]) -> tuple
- normalize_route_constraints · function · L408-L461 — def normalize_route_constraints(constraints: dict[str, Any] | None) -> dict[str, Any]
- collect_reaction_evidence · function · L464-L494 — def collect_reaction_evidence( routes: Iterable[dict[str, Any]], providers: Iterable[ReactionEvidenceProvider | Any], ) -> dict[str, list[dict[str, Any]]]
- build_reaction_evidence_query_prompt · function · L497-L521 — def build_reaction_evidence_query_prompt( reaction_briefs: Iterable[dict[str, Any]], *, max_queries_per_reaction: int = 2 ) -> str
- build_reaction_evidence_selection_prompt · function · L524-L562 — def build_reaction_evidence_selection_prompt( reaction_briefs: Iterable[dict[str, Any]], sources: Iterable[dict[str, Any]] ) -> str
- _llm_reaction_evidence_queries · function · L565-L592 — def _llm_reaction_evidence_queries( llm: Any, briefs: list[dict[str, Any]], *, max_queries_per_reaction: int, ) -> dict[str, list[str]]
- _llm_select_reaction_evidence · function · L595-L606 — def _llm_select_reaction_evidence( llm: Any, briefs: list[dict[str, Any]], sources: list[dict[str, Any]], ) -> list[dict[str, Any]]
- _call_reaction_evidence_llm · function · L609-L629 — def _call_reaction_evidence_llm( llm: Any, prompt: str, *, purpose: str ) -> dict[str, Any]
- _call_openai4s_search · function · L632-L639 — def _call_openai4s_search(search: Any, query: str, *, results_per_query: int) -> Any
- _call_openai4s_fetch · function · L642-L649 — def _call_openai4s_fetch(fetch: Any, url: str) -> Any
- _search_result_items · function · L652-L657 — def _search_result_items(response: Any) -> list[dict[str, Any]]
- _web_fetch_text · function · L660-L666 — def _web_fetch_text(response: Any) -> str
- _source_linked_evidence_candidates · function · L669-L709 — def _source_linked_evidence_candidates( candidates: Iterable[dict[str, Any]], sources: Iterable[dict[str, Any]] ) -> dict[str, list[dict[str, Any]]]
- _mark_resolving_dois · function · L712-L742 — def _mark_resolving_dois( evidence: dict[str, list[dict[str, Any]]], verifier: Any | None ) -> None
- _valid_reaction_brief · function · L745-L748 — def _valid_reaction_brief(brief: Any) -> bool
- _public_reaction_brief · function · L751-L762 — def _public_reaction_brief(brief: dict[str, Any]) -> dict[str, Any]
- _fallback_reaction_evidence_query · function · L765-L776 — def _fallback_reaction_evidence_query(brief: dict[str, Any]) -> str
- _candidate_match_level · function · L779-L795 — def _candidate_match_level(value: Any) -> str
- _source_identifier · function · L798-L829 — def _source_identifier(source: dict[str, Any]) -> str
- _normalize_doi · function · L832-L841 — def _normalize_doi(value: Any) -> str
- _doi_from_canonical_url · function · L844-L854 — def _doi_from_canonical_url(url: str) -> str
- _looks_like_doi · function · L857-L863 — def _looks_like_doi(value: str) -> bool
- _source_type_from_url · function · L866-L891 — def _source_type_from_url(url: str) -> str
- _truncate_source_text · function · L894-L896 — def _truncate_source_text(value: Any, limit: int) -> str
- score_routes_for_execution · function · L899-L969 — def score_routes_for_execution( routes: Iterable[dict[str, Any]], *, reaction_evidence: dict[str, Any] | list[dict[str, Any]] | None = None, constraints: dict[str, Any] | None = None, decision_weights: dict[str, float] | None = None, ) -> list[dict[str, Any]]
- _normalize_decision_weights · function · L972-L1023 — def _normalize_decision_weights(weights: dict[str, float] | None) -> dict[str, float]
- _backend_score_percent · function · L1026-L1035 — def _backend_score_percent(score: Any) -> float
- _step_efficiency_percent · function · L1038-L1043 — def _step_efficiency_percent(steps: Any, *, complete_zero_step: bool = False) -> float
- _precursor_availability_percent · function · L1046-L1056 — def _precursor_availability_percent(route: dict[str, Any]) -> float
- _route_constraint_violations · function · L1059-L1114 — def _route_constraint_violations( route: dict[str, Any], constraints: dict[str, Any], evidence_coverage: float ) -> list[str]
- render_route_tree_html · function · L1117-L1436 — def render_route_tree_html( routes: Iterable[dict[str, Any]], target_smiles: str | None = None, max_routes: int = 10, annotations: dict[str, Any] | None = None, reaction_evidence: dict[str, Any] | list[dict[str, Any]] | None = None, constraints: dict[str, Any] | None = None, decision_weights: dict[str, float] | None = None, llm: Any | None = None, ) -> str
- build_markdown_report · function · L1439-L1511 — def build_markdown_report( routes: Iterable[dict[str, Any]], target_smiles: str | None = None, max_routes: int = 5, ) -> str
- collect_molecule_briefs · function · L1514-L1574 — def collect_molecule_briefs( routes: Iterable[dict[str, Any]], target_smiles: str | None = None, max_molecules: int = 24, ) -> list[dict[str, Any]]
- collect_reaction_briefs · function · L1577-L1615 — def collect_reaction_briefs( routes: Iterable[dict[str, Any]], max_reactions: int = 48 ) -> list[dict[str, Any]]
- normalize_reaction_evidence · function · L1618-L1668 — def normalize_reaction_evidence( evidence: dict[str, Any] | list[dict[str, Any]] | None, ) -> dict[str, list[dict[str, Any]]]
- _evidence_entries_from_item · function · L1671-L1678 — def _evidence_entries_from_item(item: dict[str, Any]) -> Any: # Presence matters here: an explicitly empty wrapper is an assertion that # no records exist, not an evidence record in its own right.
- build_pubchem_query_url · function · L1681-L1685 — def build_pubchem_query_url(smiles: str) -> str
- build_pubchem_structure_image_url · function · L1688-L1698 — def build_pubchem_structure_image_url( smiles: str, width: int = 260, height: int = 180 ) -> str
- _svg_data_uri · function · L1701-L1703 — def _svg_data_uri(svg: str) -> str
- _canonical_structure_src · function · L1706-L1722 — def _canonical_structure_src(source: Any) -> str
- _structure_src · function · L1725-L1741 — def _structure_src(smiles: str, width: int = 260, height: int = 180) -> str
- build_molecule_structure_src · function · L1745-L1758 — def build_molecule_structure_src( smiles: str, width: int = 260, height: int = 180 ) -> str
- build_molecule_fallback_structure_src · function · L1762-L1787 — def build_molecule_fallback_structure_src( smiles: str, width: int = 260, height: int = 180 ) -> str
- build_llm_annotation_prompt · function · L1790-L1875 — def build_llm_annotation_prompt( routes: Iterable[dict[str, Any]], target_smiles: str | None = None, max_routes: int = 8, ) -> str
- _first_json_object · function · L1878-L1903 — def _first_json_object(text: str) -> str
- parse_llm_annotations · function · L1906-L1933 — def parse_llm_annotations(raw: str | dict[str, Any]) -> dict[str, Any]
- annotate_routes_with_llm · function · L1936-L1971 — def annotate_routes_with_llm( routes: Iterable[dict[str, Any]], llm: Any, target_smiles: str | None = None, max_routes: int = 8, ) -> dict[str, Any]
- _route_candidates · function · L1974-L1997 — def _route_candidates(payload: Any) -> list[Any]
- _normalize_route · function · L2000-L2019 — def _normalize_route(candidate: Any, rank: int) -> dict[str, Any]
- _render_route_analysis · function · L2022-L2086 — def _render_route_analysis( route: dict[str, Any], annotations: dict[str, Any] | None = None ) -> str
- _render_route_step_evidence · function · L2089-L2135 — def _render_route_step_evidence( route: dict[str, Any], annotations: dict[str, Any] | None, reaction_evidence: dict[str, list[dict[str, Any]]], ) -> str
- _render_execution_assessment · function · L2138-L2184 — def _render_execution_assessment(route: dict[str, Any]) -> str
- _render_evidence_record · function · L2187-L2223 — def _render_evidence_record(record: dict[str, Any]) -> str
- _render_rich_value_html · function · L2226-L2242 — def _render_rich_value_html(value: Any) -> str
- _render_molecule_briefs_panel · function · L2245-L2297 — def _render_molecule_briefs_panel( briefs: list[dict[str, Any]], annotations: dict[str, Any] | None = None ) -> str
- _render_interactive_andor_tree · function · L2300-L2349 — def _render_interactive_andor_tree( routes: list[dict[str, Any]], target_smiles: str | None = None, annotations: dict[str, Any] | None = None, reaction_evidence: dict[str, list[dict[str, Any]]] | None = None, ) -> str
- _interactive_andor_payload · function · L2352-L2577 — def _interactive_andor_payload( routes: list[dict[str, Any]], target_smiles: str | None = None, annotations: dict[str, Any] | None = None, reaction_evidence: dict[str, list[dict[str, Any]]] | None = None, ) -> dict[str, Any]
- add_node · function · L2363-L2374 — def add_node(node: dict[str, Any]) -> dict[str, Any]
- add_edge · function · L2397-L2398 — def add_edge(source: str, target: str, route_rank: Any) -> None
- molecule_node · function · L2400-L2432 — def molecule_node( item: dict[str, Any], route_rank: Any, depth: int, is_target: bool = False ) -> dict[str, Any]
- reaction_node · function · L2434-L2544 — def reaction_node( item: dict[str, Any], parent_id: str, route_rank: Any, depth: int ) -> dict[str, Any]
- walk · function · L2546-L2560 — def walk( item: Any, parent_id: str, route_rank: Any, depth: int, is_root: bool = False ) -> None
- _reaction_info · function · L2580-L2621 — def _reaction_info(node: dict[str, Any]) -> dict[str, Any]
- _reaction_conditions_note · function · L2624-L2641 — def _reaction_conditions_note(node: dict[str, Any]) -> str
- _stable_id · function · L2644-L2645 — def _stable_id(value: str) -> str
- _annotation_for_molecule · function · L2648-L2650 — def _annotation_for_molecule(annotations: dict[str, Any], smiles: str) -> str
- _annotation_record_for_route · function · L2653-L2676 — def _annotation_record_for_route( annotations: dict[str, Any], route: dict[str, Any] ) -> dict[str, Any] | str
- _annotation_record_for_molecule · function · L2679-L2687 — def _annotation_record_for_molecule( annotations: dict[str, Any], smiles: str ) -> dict[str, Any] | str
- _annotation_record_for_reaction · function · L2690-L2701 — def _annotation_record_for_reaction( annotations: dict[str, Any], details: dict[str, Any] ) -> dict[str, Any] | str
- _reaction_annotation_key · function · L2704-L2715 — def _reaction_annotation_key(details: dict[str, Any]) -> str
- _legacy_reaction_annotation_key · function · L2718-L2721 — def _legacy_reaction_annotation_key(details: dict[str, Any]) -> str
- _legacy_reaction_key_core · function · L2724-L2732 — def _legacy_reaction_key_core(details: dict[str, Any]) -> dict[str, Any]
- _reaction_annotation_keys · function · L2735-L2745 — def _reaction_annotation_keys(details: dict[str, Any]) -> list[str]
- _reaction_details_with_context · function · L2748-L2766 — def _reaction_details_with_context( node: dict[str, Any], product_smiles: str = "" ) -> dict[str, Any]
- _iter_reaction_contexts · function · L2769-L2787 — def _iter_reaction_contexts( item: Any, product_smiles: str = "" ) -> Iterable[tuple[dict[str, Any], dict[str, Any]]]
- _iter_reaction_nodes · function · L2790-L2800 — def _iter_reaction_nodes(item: Any) -> Iterable[dict[str, Any]]
- _reaction_evidence_for_details · function · L2803-L2810 — def _reaction_evidence_for_details( evidence: dict[str, list[dict[str, Any]]], details: dict[str, Any] ) -> list[dict[str, Any]]
- _reaction_evidence_summary · function · L2813-L2873 — def _reaction_evidence_summary(records: list[dict[str, Any]]) -> dict[str, Any]
- _normalize_evidence_record · function · L2876-L2915 — def _normalize_evidence_record(record: dict[str, Any]) -> dict[str, Any]
- _explicit_bool · function · L2918-L2928 — def _explicit_bool(value: Any) -> bool
- _evidence_detail_record · function · L2931-L2953 — def _evidence_detail_record(record: dict[str, Any]) -> dict[str, Any]
- _as_string_list · function · L2956-L2961 — def _as_string_list(value: Any) -> list[str]
- _compact_evidence_value · function · L2964-L2969 — def _compact_evidence_value(value: Any) -> str
- _safe_http_url · function · L2972-L2973 — def _safe_http_url(value: str) -> str
- _annotation_description · function · L2976-L2986 — def _annotation_description(item: dict[str, Any] | str) -> str
- _annotation_reaction_type · function · L2989-L3000 — def _annotation_reaction_type(item: dict[str, Any] | str) -> str
- _annotation_value · function · L3003-L3010 — def _annotation_value(item: dict[str, Any] | str, *keys: str) -> Any
- _display_reaction_type · function · L3013-L3027 — def _display_reaction_type(classification: str, details: dict[str, Any]) -> str
- _molecule_panel_note · function · L3030-L3035 — def _molecule_panel_note(brief: dict[str, Any]) -> str
- _molecule_detail_note · function · L3038-L3042 — def _molecule_detail_note(role: str, stock_status: str) -> str
- _reaction_fallback_description · function · L3045-L3056 — def _reaction_fallback_description(backend_class: str, details: dict[str, Any]) -> str
- _backend_taxonomy_note · function · L3059-L3062 — def _backend_taxonomy_note(classification: str) -> str
- _is_unrecognized_class · function · L3065-L3071 — def _is_unrecognized_class(classification: str) -> bool
- _unrecognized_reaction_note · function · L3074-L3081 — def _unrecognized_reaction_note(classification: str) -> str
- _rdkit_molecule_svg · function · L3084-L3126 — def _rdkit_molecule_svg(smiles: str | None, width: int, height: int) -> str | None
- _extract_tree · function · L3129-L3133 — def _extract_tree(route: dict[str, Any]) -> Any
- _extract_score · function · L3136-L3149 — def _extract_score(route: dict[str, Any]) -> float | None
- _extract_solved · function · L3152-L3166 — def _extract_solved(route: dict[str, Any], tree: Any) -> bool
- _collect_starting_materials · function · L3169-L3187 — def _collect_starting_materials(node: Any) -> set[str]
- walk · function · L3172-L3184 — def walk(item: Any) -> None
- _iter_molecule_nodes · function · L3190-L3203 — def _iter_molecule_nodes(node: Any) -> Iterable[tuple[dict[str, Any], int]]
- walk · function · L3191-L3201 — def walk(item: Any, depth: int) -> Iterable[tuple[dict[str, Any], int]]
- _canonical_key · function · L3207-L3219 — def _canonical_key(smiles: str) -> str
- _molecule_role · function · L3222-L3235 — def _molecule_role( node: dict[str, Any], depth: int, target_smiles: str, is_target: bool = False ) -> str
- _role_sort_key · function · L3238-L3246 — def _role_sort_key(role: str) -> tuple[int, str]
- _stock_status_value · function · L3249-L3254 — def _stock_status_value(node: dict[str, Any]) -> str
- _summarize_stock · function · L3257-L3265 — def _summarize_stock(values: Iterable[str]) -> str
- _molecule_interpretation · function · L3268-L3277 — def _molecule_interpretation(role: str, stock_status: str) -> str
- _route_rationale · function · L3280-L3298 — def _route_rationale(route: dict[str, Any]) -> str
- _count_reactions · function · L3301-L3318 — def _count_reactions(node: Any) -> int
- walk · function · L3304-L3315 — def walk(item: Any) -> None
- _all_leaves_in_stock · function · L3321-L3340 — def _all_leaves_in_stock(node: Any) -> bool
- walk · function · L3324-L3335 — def walk(item: Any) -> None
- _render_route_table · function · L3343-L3376 — def _render_route_table(routes: list[dict[str, Any]]) -> str
- _material_chip · function · L3379-L3380 — def _material_chip(material: Any) -> str
- _render_svg_tree · function · L3383-L3411 — def _render_svg_tree(node: Any, route_id: Any) -> str
- _layout_svg_tree · function · L3414-L3486 — def _layout_svg_tree( node: Any, ) -> tuple[list[dict[str, Any]], list[tuple[dict[str, Any], dict[str, Any]]]]
- build · function · L3422-L3483 — def build( item: Any, depth: int, parent: dict[str, Any] | None = None ) -> dict[str, Any] | None
- _svg_node · function · L3489-L3528 — def _svg_node(item: dict[str, Any]) -> str
- _render_outline_tree · function · L3531-L3570 — def _render_outline_tree(node: Any) -> str
- label · function · L3535-L3551 — def label(item: Any) -> str
- walk · function · L3553-L3568 — def walk(item: Any) -> str
- _node_display_label · function · L3573-L3593 — def _node_display_label(node: dict[str, Any]) -> str
- _node_meta_label · function · L3596-L3613 — def _node_meta_label(node: dict[str, Any], depth: int) -> str
- _node_visual_class · function · L3616-L3627 — def _node_visual_class( node: dict[str, Any], depth: int, has_children: bool, is_target: bool = False ) -> str
- _short_label · function · L3630-L3634 — def _short_label(value: str, max_len: int) -> str
- _split_label · function · L3637-L3645 — def _split_label(value: str, max_len: int = 22, max_lines: int = 2) -> list[str]
- _children · function · L3648-L3656 — def _children(node: dict[str, Any]) -> list[Any]
- _node_smiles · function · L3659-L3669 — def _node_smiles(node: dict[str, Any]) -> str | None
- _is_molecule_node · function · L3672-L3676 — def _is_molecule_node(node: dict[str, Any]) -> bool
- _is_reaction_node · function · L3679-L3683 — def _is_reaction_node(node: dict[str, Any]) -> bool
- _looks_like_route · function · L3686-L3690 — def _looks_like_route(value: dict[str, Any]) -> bool
- _parse_finite_constraint_number · function · L3693-L3700 — def _parse_finite_constraint_number(value: Any, name: str) -> float
- _parse_explicit_bool · function · L3703-L3717 — def _parse_explicit_bool(value: Any, name: str) -> bool
- _flag_is_true · function · L3720-L3738 — def _flag_is_true(value: Any) -> bool
- _node_in_stock · function · L3741-L3747 — def _node_in_stock(node: dict[str, Any]) -> bool
- _execution_step_sort_value · function · L3750-L3755 — def _execution_step_sort_value(value: Any) -> float
- _as_float · function · L3758-L3762 — def _as_float(value: Any, default: float | None = None) -> float | None
- _as_int · function · L3765-L3773 — def _as_int(value: Any, default: int = 0) -> int
- _format_score · function · L4166-L4170 — def _format_score(value: Any) -> str
- _format_weight · function · L4173-L4177 — def _format_weight(value: Any) -> str