tooluniverse 1.0.5__py3-none-any.whl → 1.0.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tooluniverse might be problematic. Click here for more details.
- tooluniverse/__init__.py +70 -0
- tooluniverse/agentic_tool.py +121 -15
- tooluniverse/arxiv_tool.py +109 -0
- tooluniverse/base_tool.py +174 -25
- tooluniverse/biorxiv_tool.py +116 -0
- tooluniverse/cellosaurus_tool.py +1332 -0
- tooluniverse/compose_scripts/enhanced_multi_agent_literature_search.py +310 -0
- tooluniverse/compose_scripts/multi_agent_literature_search.py +794 -0
- tooluniverse/compose_scripts/tool_graph_generation.py +68 -35
- tooluniverse/compose_scripts/tool_metadata_generator.py +205 -105
- tooluniverse/compose_tool.py +93 -8
- tooluniverse/core_tool.py +155 -0
- tooluniverse/crossref_tool.py +158 -0
- tooluniverse/data/agentic_tools.json +1271 -1179
- tooluniverse/data/alphafold_tools.json +356 -105
- tooluniverse/data/arxiv_tools.json +94 -0
- tooluniverse/data/biorxiv_tools.json +75 -0
- tooluniverse/data/cellosaurus_tools.json +260 -0
- tooluniverse/data/chembl_tools.json +27 -12
- tooluniverse/data/clinicaltrials_gov_tools.json +377 -302
- tooluniverse/data/compose_tools.json +123 -16
- tooluniverse/data/core_tools.json +113 -0
- tooluniverse/data/crossref_tools.json +138 -0
- tooluniverse/data/dailymed_tools.json +17 -3
- tooluniverse/data/dataset_tools.json +1031 -588
- tooluniverse/data/dblp_tools.json +144 -0
- tooluniverse/data/disease_target_score_tools.json +20 -10
- tooluniverse/data/doaj_tools.json +140 -0
- tooluniverse/data/embedding_tools.json +362 -299
- tooluniverse/data/enrichr_tools.json +34 -27
- tooluniverse/data/europe_pmc_tools.json +108 -16
- tooluniverse/data/fatcat_tools.json +77 -0
- tooluniverse/data/fda_drug_adverse_event_tools.json +1061 -445
- tooluniverse/data/fda_drug_labeling_tools.json +6858 -6901
- tooluniverse/data/finder_tools.json +32 -37
- tooluniverse/data/gene_ontology_tools.json +19 -7
- tooluniverse/data/gwas_tools.json +1720 -959
- tooluniverse/data/hal_tools.json +75 -0
- tooluniverse/data/hpa_tools.json +53 -14
- tooluniverse/data/humanbase_tools.json +51 -43
- tooluniverse/data/idmap_tools.json +76 -70
- tooluniverse/data/literature_search_tools.json +306 -0
- tooluniverse/data/mcp_client_tools_example.json +122 -107
- tooluniverse/data/medlineplus_tools.json +50 -10
- tooluniverse/data/medrxiv_tools.json +75 -0
- tooluniverse/data/molecule_2d_tools.json +134 -0
- tooluniverse/data/molecule_3d_tools.json +164 -0
- tooluniverse/data/monarch_tools.json +112 -110
- tooluniverse/data/odphp_tools.json +389 -119
- tooluniverse/data/openaire_tools.json +95 -0
- tooluniverse/data/openalex_tools.json +100 -31
- tooluniverse/data/opentarget_tools.json +1457 -1372
- tooluniverse/data/osf_preprints_tools.json +81 -0
- tooluniverse/data/packages/bioinformatics_core_tools.json +40 -10
- tooluniverse/data/packages/cheminformatics_tools.json +20 -5
- tooluniverse/data/packages/genomics_tools.json +36 -9
- tooluniverse/data/packages/machine_learning_tools.json +36 -9
- tooluniverse/data/packages/scientific_computing_tools.json +20 -5
- tooluniverse/data/packages/single_cell_tools.json +20 -5
- tooluniverse/data/packages/structural_biology_tools.json +16 -4
- tooluniverse/data/packages/visualization_tools.json +20 -5
- tooluniverse/data/pmc_tools.json +117 -0
- tooluniverse/data/protein_structure_3d_tools.json +138 -0
- tooluniverse/data/pubchem_tools.json +37 -12
- tooluniverse/data/pubmed_tools.json +133 -0
- tooluniverse/data/pubtator_tools.json +68 -60
- tooluniverse/data/rcsb_pdb_tools.json +1532 -1221
- tooluniverse/data/semantic_scholar_tools.json +55 -22
- tooluniverse/data/special_tools.json +8 -6
- tooluniverse/data/tool_composition_tools.json +112 -82
- tooluniverse/data/unified_guideline_tools.json +707 -0
- tooluniverse/data/unpaywall_tools.json +86 -0
- tooluniverse/data/url_fetch_tools.json +102 -82
- tooluniverse/data/uspto_tools.json +49 -30
- tooluniverse/data/wikidata_sparql_tools.json +45 -0
- tooluniverse/data/xml_tools.json +3274 -3113
- tooluniverse/data/zenodo_tools.json +90 -0
- tooluniverse/dblp_tool.py +132 -0
- tooluniverse/default_config.py +30 -0
- tooluniverse/doaj_tool.py +183 -0
- tooluniverse/doctor.py +48 -0
- tooluniverse/europe_pmc_tool.py +132 -17
- tooluniverse/exceptions.py +170 -0
- tooluniverse/execute_function.py +825 -342
- tooluniverse/fatcat_tool.py +65 -0
- tooluniverse/generate_tools.py +198 -0
- tooluniverse/hal_tool.py +77 -0
- tooluniverse/llm_clients.py +283 -20
- tooluniverse/mcp_tool_registry.py +4 -1
- tooluniverse/medrxiv_tool.py +116 -0
- tooluniverse/memory_manager.py +166 -0
- tooluniverse/molecule_2d_tool.py +274 -0
- tooluniverse/molecule_3d_tool.py +441 -0
- tooluniverse/odphp_tool.py +49 -14
- tooluniverse/openaire_tool.py +130 -0
- tooluniverse/openalex_tool.py +34 -0
- tooluniverse/osf_preprints_tool.py +67 -0
- tooluniverse/pmc_tool.py +179 -0
- tooluniverse/protein_structure_3d_tool.py +295 -0
- tooluniverse/pubmed_tool.py +173 -0
- tooluniverse/remote/boltz/boltz_mcp_server.py +3 -1
- tooluniverse/remote/uspto_downloader/uspto_downloader_mcp_server.py +3 -1
- tooluniverse/semantic_scholar_tool.py +40 -10
- tooluniverse/smcp.py +228 -263
- tooluniverse/smcp_server.py +97 -55
- tooluniverse/tool_registry.py +35 -3
- tooluniverse/tools/ADMETAI_predict_BBB_penetrance.py +46 -0
- tooluniverse/tools/ADMETAI_predict_CYP_interactions.py +46 -0
- tooluniverse/tools/ADMETAI_predict_bioavailability.py +46 -0
- tooluniverse/tools/ADMETAI_predict_clearance_distribution.py +49 -0
- tooluniverse/tools/ADMETAI_predict_nuclear_receptor_activity.py +49 -0
- tooluniverse/tools/ADMETAI_predict_physicochemical_properties.py +49 -0
- tooluniverse/tools/ADMETAI_predict_solubility_lipophilicity_hydration.py +49 -0
- tooluniverse/tools/ADMETAI_predict_stress_response.py +46 -0
- tooluniverse/tools/ADMETAI_predict_toxicity.py +46 -0
- tooluniverse/tools/AdvancedCodeQualityAnalyzer.py +63 -0
- tooluniverse/tools/AdverseEventICDMapper.py +46 -0
- tooluniverse/tools/AdverseEventPredictionQuestionGenerator.py +52 -0
- tooluniverse/tools/AdverseEventPredictionQuestionGeneratorWithContext.py +59 -0
- tooluniverse/tools/ArXiv_search_papers.py +63 -0
- tooluniverse/tools/ArgumentDescriptionOptimizer.py +55 -0
- tooluniverse/tools/BioRxiv_search_preprints.py +52 -0
- tooluniverse/tools/BiomarkerDiscoveryWorkflow.py +55 -0
- tooluniverse/tools/CORE_search_papers.py +67 -0
- tooluniverse/tools/CallAgent.py +46 -0
- tooluniverse/tools/ChEMBL_search_similar_molecules.py +59 -0
- tooluniverse/tools/CodeOptimizer.py +55 -0
- tooluniverse/tools/CodeQualityAnalyzer.py +71 -0
- tooluniverse/tools/ComprehensiveDrugDiscoveryPipeline.py +49 -0
- tooluniverse/tools/Crossref_search_works.py +55 -0
- tooluniverse/tools/DBLP_search_publications.py +52 -0
- tooluniverse/tools/DOAJ_search_articles.py +55 -0
- tooluniverse/tools/DailyMed_get_spl_by_setid.py +52 -0
- tooluniverse/tools/DailyMed_search_spls.py +79 -0
- tooluniverse/tools/DataAnalysisValidityReviewer.py +49 -0
- tooluniverse/tools/DescriptionAnalyzer.py +55 -0
- tooluniverse/tools/DescriptionQualityEvaluator.py +59 -0
- tooluniverse/tools/DomainExpertValidator.py +63 -0
- tooluniverse/tools/DrugSafetyAnalyzer.py +59 -0
- tooluniverse/tools/EthicalComplianceReviewer.py +49 -0
- tooluniverse/tools/EuropePMC_Guidelines_Search.py +52 -0
- tooluniverse/tools/EuropePMC_search_articles.py +52 -0
- tooluniverse/tools/ExperimentalDesignScorer.py +55 -0
- tooluniverse/tools/FAERS_count_additive_administration_routes.py +52 -0
- tooluniverse/tools/FAERS_count_additive_adverse_reactions.py +71 -0
- tooluniverse/tools/FAERS_count_additive_event_reports_by_country.py +63 -0
- tooluniverse/tools/FAERS_count_additive_reaction_outcomes.py +63 -0
- tooluniverse/tools/FAERS_count_additive_reports_by_reporter_country.py +63 -0
- tooluniverse/tools/FAERS_count_additive_seriousness_classification.py +63 -0
- tooluniverse/tools/FAERS_count_country_by_drug_event.py +63 -0
- tooluniverse/tools/FAERS_count_death_related_by_drug.py +49 -0
- tooluniverse/tools/FAERS_count_drug_routes_by_event.py +52 -0
- tooluniverse/tools/FAERS_count_drugs_by_drug_event.py +63 -0
- tooluniverse/tools/FAERS_count_outcomes_by_drug_event.py +63 -0
- tooluniverse/tools/FAERS_count_patient_age_distribution.py +49 -0
- tooluniverse/tools/FAERS_count_reactions_by_drug_event.py +71 -0
- tooluniverse/tools/FAERS_count_reportercountry_by_drug_event.py +63 -0
- tooluniverse/tools/FAERS_count_seriousness_by_drug_event.py +63 -0
- tooluniverse/tools/FDA_get_abuse_dependence_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_abuse_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_accessories_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_active_ingredient_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_adverse_reactions_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_alarms_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_animal_pharmacology_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_assembly_installation_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_boxed_warning_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_brand_name_generic_name.py +52 -0
- tooluniverse/tools/FDA_get_calibration_instructions_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_carcinogenic_mutagenic_fertility_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_child_safety_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_clinical_pharmacology_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_clinical_studies_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_contact_for_questions_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_contraindications_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_controlled_substance_DEA_schedule_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_dear_health_care_provider_letter_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_dependence_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_disposal_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_do_not_use_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_document_id_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_dosage_and_storage_information_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_dosage_forms_and_strengths_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_drug_generic_name.py +46 -0
- tooluniverse/tools/FDA_get_drug_interactions_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_SPL_ID.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_adverse_reaction.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_calibration_instructions.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_dependence_info.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_document_id.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_dosage_info.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_environmental_warning.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_inactive_ingredient.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_info_on_conditions_for_doctor_consultation.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_labor_and_delivery_info.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_microbiology.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_other_safety_info.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_pharmacodynamics.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_pharmacogenomics.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_precautions.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_pregnancy_or_breastfeeding_info.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_principal_display_panel.py +59 -0
- tooluniverse/tools/FDA_get_drug_name_by_reference.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_set_id.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_stop_use_info.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_storage_and_handling_info.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_by_warnings.py +55 -0
- tooluniverse/tools/FDA_get_drug_name_from_patient_package_insert.py +59 -0
- tooluniverse/tools/FDA_get_drug_names_by_abuse_dependence_info.py +55 -0
- tooluniverse/tools/FDA_get_drug_names_by_abuse_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_accessories.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_active_ingredient.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_alarm.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_animal_pharmacology_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_application_number_NDC_number.py +59 -0
- tooluniverse/tools/FDA_get_drug_names_by_assembly_installation_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_boxed_warning.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_child_safety_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_clinical_pharmacology.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_clinical_studies.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_consulting_doctor_pharmacist_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_contraindications.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_controlled_substance_DEA_schedule.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_dear_health_care_provider_letter_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_disposal_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_dosage_forms_and_strengths_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_drug_interactions.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_effective_time.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_food_safety_warnings.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_general_precautions.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_geriatric_use.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_health_claim.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_indication.py +55 -0
- tooluniverse/tools/FDA_get_drug_names_by_info_for_nursing_mothers.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_information_for_owners_or_caregivers.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_ingredient.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_instructions_for_use.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_lab_test_interference.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_lab_tests.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_mechanism_of_action.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_medication_guide.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_nonclinical_toxicology_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_nonteratogenic_effects.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_overdosage_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_pediatric_use.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_pharmacokinetics.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_population_use.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_pregnancy_effects_info.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_residue_warning.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_risk.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_route.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_safe_handling_warning.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_safety_summary.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_spl_indexing_data_elements.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_teratogenic_effects.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_user_safety_warning.py +63 -0
- tooluniverse/tools/FDA_get_drug_names_by_warnings_and_cautions.py +63 -0
- tooluniverse/tools/FDA_get_drugs_by_carcinogenic_mutagenic_fertility.py +63 -0
- tooluniverse/tools/FDA_get_effective_time_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_environmental_warning_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_general_precautions_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_geriatric_use_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_health_claims_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_inactive_ingredient_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_indications_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_info_for_nursing_mothers_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_info_for_patients_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_info_on_conditions_for_doctor_consultation_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_info_on_consulting_doctor_pharmacist_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_information_for_owners_or_caregivers_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_ingredients_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_instructions_for_use_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_lab_test_interference_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_lab_tests_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_labor_and_delivery_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_manufacturer_name_NDC_number_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_mechanism_of_action_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_medication_guide_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_microbiology_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_nonclinical_toxicology_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_nonteratogenic_effects_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_other_safety_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_overdosage_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_patient_package_insert_from_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_pediatric_use_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_pharmacodynamics_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_pharmacogenomics_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_pharmacokinetics_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_population_use_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_precautions_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_pregnancy_effects_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_pregnancy_or_breastfeeding_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_principal_display_panel_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_purpose_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_recent_changes_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_reference_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_residue_warning_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_risk_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_route_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_safe_handling_warnings_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_safety_summary_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_spl_indexing_data_elements_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_spl_unclassified_section_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_stop_use_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_storage_and_handling_info_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_teratogenic_effects_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_user_safety_warning_by_drug_names.py +55 -0
- tooluniverse/tools/FDA_get_warnings_and_cautions_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_warnings_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_get_when_using_info.py +55 -0
- tooluniverse/tools/FDA_retrieve_device_use_by_drug_name.py +55 -0
- tooluniverse/tools/FDA_retrieve_drug_name_by_device_use.py +59 -0
- tooluniverse/tools/FDA_retrieve_drug_names_by_patient_medication_info.py +55 -0
- tooluniverse/tools/FDA_retrieve_patient_medication_info_by_drug_name.py +55 -0
- tooluniverse/tools/Fatcat_search_scholar.py +52 -0
- tooluniverse/tools/Finish.py +44 -0
- tooluniverse/tools/GO_get_annotations_for_gene.py +46 -0
- tooluniverse/tools/GO_get_genes_for_term.py +55 -0
- tooluniverse/tools/GO_get_term_by_id.py +46 -0
- tooluniverse/tools/GO_get_term_details.py +46 -0
- tooluniverse/tools/GO_search_terms.py +46 -0
- tooluniverse/tools/HAL_search_archive.py +52 -0
- tooluniverse/tools/HPA_get_biological_processes_by_gene.py +52 -0
- tooluniverse/tools/HPA_get_cancer_prognostics_by_gene.py +49 -0
- tooluniverse/tools/HPA_get_comparative_expression_by_gene_and_cellline.py +52 -0
- tooluniverse/tools/HPA_get_comprehensive_gene_details_by_ensembl_id.py +63 -0
- tooluniverse/tools/HPA_get_contextual_biological_process_analysis.py +52 -0
- tooluniverse/tools/HPA_get_disease_expression_by_gene_tissue_disease.py +59 -0
- tooluniverse/tools/HPA_get_gene_basic_info_by_ensembl_id.py +49 -0
- tooluniverse/tools/HPA_get_gene_tsv_data_by_ensembl_id.py +49 -0
- tooluniverse/tools/HPA_get_protein_interactions_by_gene.py +49 -0
- tooluniverse/tools/HPA_get_rna_expression_by_source.py +59 -0
- tooluniverse/tools/HPA_get_rna_expression_in_specific_tissues.py +52 -0
- tooluniverse/tools/HPA_get_subcellular_location.py +46 -0
- tooluniverse/tools/HPA_search_genes_by_query.py +49 -0
- tooluniverse/tools/HypothesisGenerator.py +63 -0
- tooluniverse/tools/LabelGenerator.py +67 -0
- tooluniverse/tools/LiteratureContextReviewer.py +55 -0
- tooluniverse/tools/LiteratureSearchTool.py +49 -0
- tooluniverse/tools/MedRxiv_search_preprints.py +52 -0
- tooluniverse/tools/MedicalLiteratureReviewer.py +71 -0
- tooluniverse/tools/MedicalTermNormalizer.py +46 -0
- tooluniverse/tools/MedlinePlus_connect_lookup_by_code.py +67 -0
- tooluniverse/tools/MedlinePlus_get_genetics_condition_by_name.py +52 -0
- tooluniverse/tools/MedlinePlus_get_genetics_gene_by_name.py +52 -0
- tooluniverse/tools/MedlinePlus_get_genetics_index.py +44 -0
- tooluniverse/tools/MedlinePlus_search_topics_by_keyword.py +55 -0
- tooluniverse/tools/MethodologyRigorReviewer.py +49 -0
- tooluniverse/tools/MultiAgentLiteratureSearch.py +59 -0
- tooluniverse/tools/NICE_Clinical_Guidelines_Search.py +52 -0
- tooluniverse/tools/NICE_Guideline_Full_Text.py +46 -0
- tooluniverse/tools/NoveltySignificanceReviewer.py +59 -0
- tooluniverse/tools/OSF_search_preprints.py +59 -0
- tooluniverse/tools/OSL_get_efo_id_by_disease_name.py +46 -0
- tooluniverse/tools/OpenAIRE_search_publications.py +55 -0
- tooluniverse/tools/OpenAlex_Guidelines_Search.py +63 -0
- tooluniverse/tools/OpenTargets_drug_pharmacogenomics_data.py +52 -0
- tooluniverse/tools/OpenTargets_get_approved_indications_by_drug_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_associated_diseases_by_drug_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_associated_drugs_by_disease_efoId.py +52 -0
- tooluniverse/tools/OpenTargets_get_associated_drugs_by_target_ensemblID.py +55 -0
- tooluniverse/tools/OpenTargets_get_associated_phenotypes_by_disease_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_associated_targets_by_disease_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_associated_targets_by_drug_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_biological_mouse_models_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_chemical_probes_by_target_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_disease_ancestors_parents_by_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_disease_descendants_children_by_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_disease_description_by_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_disease_id_description_by_name.py +49 -0
- tooluniverse/tools/OpenTargets_get_disease_ids_by_efoId.py +46 -0
- tooluniverse/tools/OpenTargets_get_disease_ids_by_name.py +46 -0
- tooluniverse/tools/OpenTargets_get_disease_locations_by_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_disease_synonyms_by_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_disease_therapeutic_areas_by_efoId.py +49 -0
- tooluniverse/tools/OpenTargets_get_diseases_phenotypes_by_target_ensembl.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_adverse_events_by_chemblId.py +52 -0
- tooluniverse/tools/OpenTargets_get_drug_approval_status_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_chembId_by_generic_name.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_description_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_id_description_by_name.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_indications_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_mechanisms_of_action_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_synonyms_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_trade_names_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_warnings_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_drug_withdrawn_blackbox_status_by_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_gene_ontology_terms_by_goID.py +49 -0
- tooluniverse/tools/OpenTargets_get_known_drugs_by_drug_chemblId.py +49 -0
- tooluniverse/tools/OpenTargets_get_parent_child_molecules_by_drug_chembl_ID.py +49 -0
- tooluniverse/tools/OpenTargets_get_publications_by_disease_efoId.py +71 -0
- tooluniverse/tools/OpenTargets_get_publications_by_drug_chemblId.py +71 -0
- tooluniverse/tools/OpenTargets_get_publications_by_target_ensemblID.py +71 -0
- tooluniverse/tools/OpenTargets_get_similar_entities_by_disease_efoId.py +55 -0
- tooluniverse/tools/OpenTargets_get_similar_entities_by_drug_chemblId.py +55 -0
- tooluniverse/tools/OpenTargets_get_similar_entities_by_target_ensemblID.py +55 -0
- tooluniverse/tools/OpenTargets_get_target_classes_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_constraint_info_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_enabling_packages_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_gene_ontology_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_genomic_location_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_homologues_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_id_description_by_name.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_interactions_by_ensemblID.py +52 -0
- tooluniverse/tools/OpenTargets_get_target_safety_profile_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_subcellular_locations_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_synonyms_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_get_target_tractability_by_ensemblID.py +49 -0
- tooluniverse/tools/OpenTargets_map_any_disease_id_to_all_other_ids.py +49 -0
- tooluniverse/tools/OpenTargets_multi_entity_search_by_query_string.py +59 -0
- tooluniverse/tools/OpenTargets_search_category_counts_by_query_string.py +49 -0
- tooluniverse/tools/OpenTargets_target_disease_evidence.py +52 -0
- tooluniverse/tools/OutputSummarizationComposer.py +71 -0
- tooluniverse/tools/PMC_search_papers.py +67 -0
- tooluniverse/tools/ProtocolOptimizer.py +49 -0
- tooluniverse/tools/PubChem_get_CID_by_SMILES.py +46 -0
- tooluniverse/tools/PubChem_get_CID_by_compound_name.py +46 -0
- tooluniverse/tools/PubChem_get_associated_patents_by_CID.py +46 -0
- tooluniverse/tools/PubChem_get_compound_2D_image_by_CID.py +52 -0
- tooluniverse/tools/PubChem_get_compound_properties_by_CID.py +46 -0
- tooluniverse/tools/PubChem_get_compound_synonyms_by_CID.py +46 -0
- tooluniverse/tools/PubChem_get_compound_xrefs_by_CID.py +52 -0
- tooluniverse/tools/PubChem_search_compounds_by_similarity.py +52 -0
- tooluniverse/tools/PubChem_search_compounds_by_substructure.py +49 -0
- tooluniverse/tools/PubMed_Guidelines_Search.py +55 -0
- tooluniverse/tools/PubMed_search_articles.py +55 -0
- tooluniverse/tools/PubTator3_EntityAutocomplete.py +59 -0
- tooluniverse/tools/PubTator3_LiteratureSearch.py +55 -0
- tooluniverse/tools/QuestionRephraser.py +52 -0
- tooluniverse/tools/Reactome_get_pathway_reactions.py +46 -0
- tooluniverse/tools/ReproducibilityTransparencyReviewer.py +49 -0
- tooluniverse/tools/ResultsInterpretationReviewer.py +55 -0
- tooluniverse/tools/ScientificTextSummarizer.py +59 -0
- tooluniverse/tools/SemanticScholar_search_papers.py +55 -0
- tooluniverse/tools/TRIP_Database_Guidelines_Search.py +55 -0
- tooluniverse/tools/TestCaseGenerator.py +46 -0
- tooluniverse/tools/ToolCompatibilityAnalyzer.py +59 -0
- tooluniverse/tools/ToolDescriptionOptimizer.py +67 -0
- tooluniverse/tools/ToolDiscover.py +63 -0
- tooluniverse/tools/ToolGraphComposer.py +71 -0
- tooluniverse/tools/ToolGraphGenerationPipeline.py +63 -0
- tooluniverse/tools/ToolImplementationGenerator.py +67 -0
- tooluniverse/tools/ToolMetadataGenerationPipeline.py +63 -0
- tooluniverse/tools/ToolMetadataGenerator.py +55 -0
- tooluniverse/tools/ToolMetadataStandardizer.py +52 -0
- tooluniverse/tools/ToolOptimizer.py +59 -0
- tooluniverse/tools/ToolOutputSummarizer.py +67 -0
- tooluniverse/tools/ToolQualityEvaluator.py +59 -0
- tooluniverse/tools/ToolRelationshipDetector.py +52 -0
- tooluniverse/tools/ToolSpecificationGenerator.py +67 -0
- tooluniverse/tools/ToolSpecificationOptimizer.py +63 -0
- tooluniverse/tools/Tool_Finder.py +67 -0
- tooluniverse/tools/Tool_Finder_Keyword.py +67 -0
- tooluniverse/tools/Tool_Finder_LLM.py +67 -0
- tooluniverse/tools/Tool_RAG.py +49 -0
- tooluniverse/tools/UniProt_get_alternative_names_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_disease_variants_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_entry_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_function_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_isoform_ids_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_organism_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_ptm_processing_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_recommended_name_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_sequence_by_accession.py +49 -0
- tooluniverse/tools/UniProt_get_subcellular_location_by_accession.py +49 -0
- tooluniverse/tools/Unpaywall_check_oa_status.py +52 -0
- tooluniverse/tools/WHO_Guideline_Full_Text.py +46 -0
- tooluniverse/tools/WHO_Guidelines_Search.py +52 -0
- tooluniverse/tools/Wikidata_SPARQL_query.py +52 -0
- tooluniverse/tools/WritingPresentationReviewer.py +49 -0
- tooluniverse/tools/Zenodo_search_records.py +59 -0
- tooluniverse/tools/__init__.py +1738 -0
- tooluniverse/tools/_shared_client.py +138 -0
- tooluniverse/tools/alphafold_get_annotations.py +52 -0
- tooluniverse/tools/alphafold_get_prediction.py +55 -0
- tooluniverse/tools/alphafold_get_summary.py +46 -0
- tooluniverse/tools/call_agentic_human.py +46 -0
- tooluniverse/tools/cancer_biomarkers_disease_target_score.py +52 -0
- tooluniverse/tools/cancer_gene_census_disease_target_score.py +52 -0
- tooluniverse/tools/cellosaurus_get_cell_line_info.py +55 -0
- tooluniverse/tools/cellosaurus_query_converter.py +52 -0
- tooluniverse/tools/cellosaurus_search_cell_lines.py +55 -0
- tooluniverse/tools/chembl_disease_target_score.py +52 -0
- tooluniverse/tools/dict_search.py +67 -0
- tooluniverse/tools/dili_search.py +67 -0
- tooluniverse/tools/diqt_search.py +67 -0
- tooluniverse/tools/disease_target_score.py +59 -0
- tooluniverse/tools/drugbank_filter_drugs_by_name.py +55 -0
- tooluniverse/tools/drugbank_full_search.py +67 -0
- tooluniverse/tools/drugbank_get_drug_basic_info_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_drug_chemistry_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_drug_interactions_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_drug_name_and_description_by_indication.py +63 -0
- tooluniverse/tools/drugbank_get_drug_name_and_description_by_pathway_name.py +63 -0
- tooluniverse/tools/drugbank_get_drug_name_and_description_by_target_name.py +63 -0
- tooluniverse/tools/drugbank_get_drug_name_description_pharmacology_by_mechanism_of_action.py +63 -0
- tooluniverse/tools/drugbank_get_drug_pathways_and_reactions_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_drug_products_by_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_drug_references_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_indications_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_pharmacology_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_safety_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_get_targets_by_drug_name_or_drugbank_id.py +63 -0
- tooluniverse/tools/drugbank_links_search.py +67 -0
- tooluniverse/tools/drugbank_vocab_filter.py +63 -0
- tooluniverse/tools/drugbank_vocab_search.py +67 -0
- tooluniverse/tools/embedding_database_add.py +63 -0
- tooluniverse/tools/embedding_database_create.py +71 -0
- tooluniverse/tools/embedding_database_load.py +63 -0
- tooluniverse/tools/embedding_database_search.py +67 -0
- tooluniverse/tools/embedding_sync_download.py +63 -0
- tooluniverse/tools/embedding_sync_upload.py +71 -0
- tooluniverse/tools/enrichr_gene_enrichment_analysis.py +52 -0
- tooluniverse/tools/europepmc_disease_target_score.py +52 -0
- tooluniverse/tools/eva_disease_target_score.py +52 -0
- tooluniverse/tools/eva_somatic_disease_target_score.py +52 -0
- tooluniverse/tools/expression_atlas_disease_target_score.py +52 -0
- tooluniverse/tools/extract_clinical_trial_adverse_events.py +59 -0
- tooluniverse/tools/extract_clinical_trial_outcomes.py +52 -0
- tooluniverse/tools/genomics_england_disease_target_score.py +52 -0
- tooluniverse/tools/get_HPO_ID_by_phenotype.py +55 -0
- tooluniverse/tools/get_albumentations_info.py +44 -0
- tooluniverse/tools/get_altair_info.py +44 -0
- tooluniverse/tools/get_anndata_info.py +49 -0
- tooluniverse/tools/get_arboreto_info.py +46 -0
- tooluniverse/tools/get_arxiv_info.py +46 -0
- tooluniverse/tools/get_ase_info.py +46 -0
- tooluniverse/tools/get_assembly_info_by_pdb_id.py +46 -0
- tooluniverse/tools/get_assembly_summary.py +46 -0
- tooluniverse/tools/get_astropy_info.py +44 -0
- tooluniverse/tools/get_binding_affinity_by_pdb_id.py +46 -0
- tooluniverse/tools/get_biopandas_info.py +49 -0
- tooluniverse/tools/get_biopython_info.py +49 -0
- tooluniverse/tools/get_bioservices_info.py +44 -0
- tooluniverse/tools/get_biotite_info.py +49 -0
- tooluniverse/tools/get_bokeh_info.py +44 -0
- tooluniverse/tools/get_brian2_info.py +44 -0
- tooluniverse/tools/get_cartopy_info.py +44 -0
- tooluniverse/tools/get_catboost_info.py +44 -0
- tooluniverse/tools/get_cellpose_info.py +49 -0
- tooluniverse/tools/get_cellrank_info.py +44 -0
- tooluniverse/tools/get_cellxgene_census_info.py +46 -0
- tooluniverse/tools/get_cftime_info.py +44 -0
- tooluniverse/tools/get_chem_comp_audit_info.py +46 -0
- tooluniverse/tools/get_chem_comp_charge_and_ambiguity.py +46 -0
- tooluniverse/tools/get_chembl_webresource_client_info.py +44 -0
- tooluniverse/tools/get_citation_info_by_pdb_id.py +46 -0
- tooluniverse/tools/get_clair3_info.py +46 -0
- tooluniverse/tools/get_clinical_trial_conditions_and_interventions.py +55 -0
- tooluniverse/tools/get_clinical_trial_descriptions.py +52 -0
- tooluniverse/tools/get_clinical_trial_eligibility_criteria.py +55 -0
- tooluniverse/tools/get_clinical_trial_locations.py +52 -0
- tooluniverse/tools/get_clinical_trial_outcome_measures.py +52 -0
- tooluniverse/tools/get_clinical_trial_references.py +52 -0
- tooluniverse/tools/get_clinical_trial_status_and_dates.py +52 -0
- tooluniverse/tools/get_cobra_info.py +46 -0
- tooluniverse/tools/get_cobrapy_info.py +46 -0
- tooluniverse/tools/get_cooler_info.py +49 -0
- tooluniverse/tools/get_core_refinement_statistics.py +46 -0
- tooluniverse/tools/get_cryosparc_tools_info.py +46 -0
- tooluniverse/tools/get_crystal_growth_conditions_by_pdb_id.py +49 -0
- tooluniverse/tools/get_crystallization_ph_by_pdb_id.py +46 -0
- tooluniverse/tools/get_crystallographic_properties_by_pdb_id.py +49 -0
- tooluniverse/tools/get_cupy_info.py +44 -0
- tooluniverse/tools/get_cyvcf2_info.py +49 -0
- tooluniverse/tools/get_dask_info.py +44 -0
- tooluniverse/tools/get_datamol_info.py +44 -0
- tooluniverse/tools/get_datashader_info.py +44 -0
- tooluniverse/tools/get_deepchem_info.py +49 -0
- tooluniverse/tools/get_deeppurpose_info.py +46 -0
- tooluniverse/tools/get_deeptools_info.py +46 -0
- tooluniverse/tools/get_deepxde_info.py +49 -0
- tooluniverse/tools/get_dendropy_info.py +44 -0
- tooluniverse/tools/get_descriptastorus_info.py +46 -0
- tooluniverse/tools/get_diffdock_info.py +46 -0
- tooluniverse/tools/get_dscribe_info.py +49 -0
- tooluniverse/tools/get_ec_number_by_entity_id.py +46 -0
- tooluniverse/tools/get_elephant_info.py +44 -0
- tooluniverse/tools/get_em_3d_fitting_and_reconstruction_details.py +49 -0
- tooluniverse/tools/get_emdb_ids_by_pdb_id.py +46 -0
- tooluniverse/tools/get_episcanpy_info.py +44 -0
- tooluniverse/tools/get_ete3_info.py +44 -0
- tooluniverse/tools/get_faiss_info.py +46 -0
- tooluniverse/tools/get_fanc_info.py +46 -0
- tooluniverse/tools/get_flask_info.py +46 -0
- tooluniverse/tools/get_flowio_info.py +46 -0
- tooluniverse/tools/get_flowkit_info.py +46 -0
- tooluniverse/tools/get_flowutils_info.py +46 -0
- tooluniverse/tools/get_freesasa_info.py +44 -0
- tooluniverse/tools/get_galpy_info.py +44 -0
- tooluniverse/tools/get_gene_name_by_entity_id.py +46 -0
- tooluniverse/tools/get_geopandas_info.py +44 -0
- tooluniverse/tools/get_gget_info.py +46 -0
- tooluniverse/tools/get_googlesearch_python_info.py +46 -0
- tooluniverse/tools/get_gseapy_info.py +49 -0
- tooluniverse/tools/get_h5py_info.py +46 -0
- tooluniverse/tools/get_harmony_pytorch_info.py +46 -0
- tooluniverse/tools/get_hmmlearn_info.py +46 -0
- tooluniverse/tools/get_holoviews_info.py +44 -0
- tooluniverse/tools/get_host_organism_by_pdb_id.py +46 -0
- tooluniverse/tools/get_htmd_info.py +44 -0
- tooluniverse/tools/get_hyperopt_info.py +49 -0
- tooluniverse/tools/get_igraph_info.py +49 -0
- tooluniverse/tools/get_imageio_info.py +44 -0
- tooluniverse/tools/get_imbalanced_learn_info.py +44 -0
- tooluniverse/tools/get_jcvi_info.py +46 -0
- tooluniverse/tools/get_joblib_info.py +44 -0
- tooluniverse/tools/get_joint_associated_diseases_by_HPO_ID_list.py +55 -0
- tooluniverse/tools/get_khmer_info.py +46 -0
- tooluniverse/tools/get_kipoiseq_info.py +44 -0
- tooluniverse/tools/get_lifelines_info.py +49 -0
- tooluniverse/tools/get_ligand_bond_count_by_pdb_id.py +46 -0
- tooluniverse/tools/get_ligand_smiles_by_chem_comp_id.py +49 -0
- tooluniverse/tools/get_lightgbm_info.py +44 -0
- tooluniverse/tools/get_loompy_info.py +46 -0
- tooluniverse/tools/get_mageck_info.py +46 -0
- tooluniverse/tools/get_matplotlib_info.py +49 -0
- tooluniverse/tools/get_mdanalysis_info.py +46 -0
- tooluniverse/tools/get_mdtraj_info.py +44 -0
- tooluniverse/tools/get_mne_info.py +44 -0
- tooluniverse/tools/get_molfeat_info.py +44 -0
- tooluniverse/tools/get_molvs_info.py +44 -0
- tooluniverse/tools/get_mordred_info.py +44 -0
- tooluniverse/tools/get_msprime_info.py +49 -0
- tooluniverse/tools/get_mudata_info.py +49 -0
- tooluniverse/tools/get_mutation_annotations_by_pdb_id.py +46 -0
- tooluniverse/tools/get_neo_info.py +44 -0
- tooluniverse/tools/get_netcdf4_info.py +44 -0
- tooluniverse/tools/get_networkx_info.py +46 -0
- tooluniverse/tools/get_nglview_info.py +44 -0
- tooluniverse/tools/get_nilearn_info.py +44 -0
- tooluniverse/tools/get_numba_info.py +46 -0
- tooluniverse/tools/get_numpy_info.py +46 -0
- tooluniverse/tools/get_oligosaccharide_descriptors_by_entity_id.py +49 -0
- tooluniverse/tools/get_openbabel_info.py +49 -0
- tooluniverse/tools/get_openchem_info.py +46 -0
- tooluniverse/tools/get_opencv_info.py +49 -0
- tooluniverse/tools/get_openmm_info.py +49 -0
- tooluniverse/tools/get_optlang_info.py +46 -0
- tooluniverse/tools/get_optuna_info.py +44 -0
- tooluniverse/tools/get_palantir_info.py +44 -0
- tooluniverse/tools/get_pandas_info.py +49 -0
- tooluniverse/tools/get_patsy_info.py +44 -0
- tooluniverse/tools/get_pdbfixer_info.py +46 -0
- tooluniverse/tools/get_phenotype_by_HPO_ID.py +46 -0
- tooluniverse/tools/get_pillow_info.py +44 -0
- tooluniverse/tools/get_plantcv_info.py +46 -0
- tooluniverse/tools/get_plip_info.py +46 -0
- tooluniverse/tools/get_plotly_info.py +44 -0
- tooluniverse/tools/get_poliastro_info.py +46 -0
- tooluniverse/tools/get_polymer_entity_annotations.py +49 -0
- tooluniverse/tools/get_polymer_entity_count_by_pdb_id.py +46 -0
- tooluniverse/tools/get_polymer_entity_ids_by_pdb_id.py +46 -0
- tooluniverse/tools/get_polymer_entity_type_by_entity_id.py +49 -0
- tooluniverse/tools/get_polymer_molecular_weight_by_entity_id.py +49 -0
- tooluniverse/tools/get_poretools_info.py +44 -0
- tooluniverse/tools/get_prody_info.py +46 -0
- tooluniverse/tools/get_protein_classification_by_pdb_id.py +49 -0
- tooluniverse/tools/get_protein_metadata_by_pdb_id.py +46 -0
- tooluniverse/tools/get_pubchempy_info.py +44 -0
- tooluniverse/tools/get_pybedtools_info.py +49 -0
- tooluniverse/tools/get_pybigwig_info.py +46 -0
- tooluniverse/tools/get_pydeseq2_info.py +46 -0
- tooluniverse/tools/get_pyensembl_info.py +44 -0
- tooluniverse/tools/get_pyephem_info.py +44 -0
- tooluniverse/tools/get_pyfaidx_info.py +49 -0
- tooluniverse/tools/get_pyfasta_info.py +44 -0
- tooluniverse/tools/get_pykalman_info.py +46 -0
- tooluniverse/tools/get_pyliftover_info.py +49 -0
- tooluniverse/tools/get_pymassspec_info.py +46 -0
- tooluniverse/tools/get_pymed_info.py +46 -0
- tooluniverse/tools/get_pymzml_info.py +46 -0
- tooluniverse/tools/get_pypdf2_info.py +46 -0
- tooluniverse/tools/get_pyranges_info.py +49 -0
- tooluniverse/tools/get_pyrosetta_info.py +44 -0
- tooluniverse/tools/get_pysam_info.py +46 -0
- tooluniverse/tools/get_pyscenic_info.py +46 -0
- tooluniverse/tools/get_pyscf_info.py +46 -0
- tooluniverse/tools/get_pyscreener_info.py +46 -0
- tooluniverse/tools/get_pytdc_info.py +46 -0
- tooluniverse/tools/get_python_libsbml_info.py +46 -0
- tooluniverse/tools/get_pytorch_info.py +49 -0
- tooluniverse/tools/get_pyvcf_info.py +44 -0
- tooluniverse/tools/get_pyvis_info.py +44 -0
- tooluniverse/tools/get_qutip_info.py +44 -0
- tooluniverse/tools/get_rasterio_info.py +44 -0
- tooluniverse/tools/get_rdkit_info.py +46 -0
- tooluniverse/tools/get_refinement_resolution_by_pdb_id.py +49 -0
- tooluniverse/tools/get_release_deposit_dates_by_pdb_id.py +49 -0
- tooluniverse/tools/get_reportlab_info.py +49 -0
- tooluniverse/tools/get_requests_info.py +49 -0
- tooluniverse/tools/get_ruptures_info.py +46 -0
- tooluniverse/tools/get_scanorama_info.py +44 -0
- tooluniverse/tools/get_scanpy_info.py +49 -0
- tooluniverse/tools/get_schnetpack_info.py +49 -0
- tooluniverse/tools/get_scholarly_info.py +46 -0
- tooluniverse/tools/get_scikit_bio_info.py +49 -0
- tooluniverse/tools/get_scikit_image_info.py +46 -0
- tooluniverse/tools/get_scikit_learn_info.py +49 -0
- tooluniverse/tools/get_scipy_info.py +46 -0
- tooluniverse/tools/get_scrublet_info.py +49 -0
- tooluniverse/tools/get_scvelo_info.py +49 -0
- tooluniverse/tools/get_scvi_tools_info.py +44 -0
- tooluniverse/tools/get_seaborn_info.py +49 -0
- tooluniverse/tools/get_sequence_by_pdb_id.py +46 -0
- tooluniverse/tools/get_sequence_lengths_by_pdb_id.py +46 -0
- tooluniverse/tools/get_sequence_positional_features_by_instance_id.py +49 -0
- tooluniverse/tools/get_skopt_info.py +44 -0
- tooluniverse/tools/get_souporcell_info.py +46 -0
- tooluniverse/tools/get_source_organism_by_pdb_id.py +46 -0
- tooluniverse/tools/get_space_group_by_pdb_id.py +46 -0
- tooluniverse/tools/get_statsmodels_info.py +49 -0
- tooluniverse/tools/get_structure_determination_software_by_pdb_id.py +49 -0
- tooluniverse/tools/get_structure_title_by_pdb_id.py +46 -0
- tooluniverse/tools/get_structure_validation_metrics_by_pdb_id.py +49 -0
- tooluniverse/tools/get_sunpy_info.py +44 -0
- tooluniverse/tools/get_sympy_info.py +46 -0
- tooluniverse/tools/get_target_cofactor_info.py +46 -0
- tooluniverse/tools/get_taxonomy_by_pdb_id.py +46 -0
- tooluniverse/tools/get_tiledb_info.py +46 -0
- tooluniverse/tools/get_tiledbsoma_info.py +46 -0
- tooluniverse/tools/get_torch_geometric_info.py +49 -0
- tooluniverse/tools/get_tqdm_info.py +46 -0
- tooluniverse/tools/get_trackpy_info.py +46 -0
- tooluniverse/tools/get_tskit_info.py +46 -0
- tooluniverse/tools/get_umap_learn_info.py +49 -0
- tooluniverse/tools/get_uniprot_accession_by_entity_id.py +49 -0
- tooluniverse/tools/get_velocyto_info.py +44 -0
- tooluniverse/tools/get_viennarna_info.py +49 -0
- tooluniverse/tools/get_webpage_text_from_url.py +52 -0
- tooluniverse/tools/get_webpage_title.py +49 -0
- tooluniverse/tools/get_xarray_info.py +44 -0
- tooluniverse/tools/get_xesmf_info.py +44 -0
- tooluniverse/tools/get_xgboost_info.py +44 -0
- tooluniverse/tools/get_zarr_info.py +44 -0
- tooluniverse/tools/gwas_get_association_by_id.py +49 -0
- tooluniverse/tools/gwas_get_associations_for_snp.py +67 -0
- tooluniverse/tools/gwas_get_associations_for_study.py +55 -0
- tooluniverse/tools/gwas_get_associations_for_trait.py +55 -0
- tooluniverse/tools/gwas_get_snp_by_id.py +46 -0
- tooluniverse/tools/gwas_get_snps_for_gene.py +55 -0
- tooluniverse/tools/gwas_get_studies_for_trait.py +75 -0
- tooluniverse/tools/gwas_get_study_by_id.py +46 -0
- tooluniverse/tools/gwas_get_variants_for_trait.py +55 -0
- tooluniverse/tools/gwas_search_associations.py +75 -0
- tooluniverse/tools/gwas_search_snps.py +63 -0
- tooluniverse/tools/gwas_search_studies.py +75 -0
- tooluniverse/tools/humanbase_ppi_analysis.py +67 -0
- tooluniverse/tools/mesh_get_subjects_by_pharmacological_action.py +63 -0
- tooluniverse/tools/mesh_get_subjects_by_subject_id.py +63 -0
- tooluniverse/tools/mesh_get_subjects_by_subject_name.py +63 -0
- tooluniverse/tools/mesh_get_subjects_by_subject_scope_or_definition.py +63 -0
- tooluniverse/tools/odphp_itemlist.py +49 -0
- tooluniverse/tools/odphp_myhealthfinder.py +67 -0
- tooluniverse/tools/odphp_outlink_fetch.py +59 -0
- tooluniverse/tools/odphp_topicsearch.py +67 -0
- tooluniverse/tools/openalex_literature_search.py +67 -0
- tooluniverse/tools/reactome_disease_target_score.py +52 -0
- tooluniverse/tools/search_clinical_trials.py +67 -0
- tooluniverse/tools/visualize_molecule_2d.py +83 -0
- tooluniverse/tools/visualize_molecule_3d.py +91 -0
- tooluniverse/tools/visualize_protein_structure_3d.py +79 -0
- tooluniverse/unified_guideline_tools.py +1210 -0
- tooluniverse/unpaywall_tool.py +62 -0
- tooluniverse/utils.py +71 -2
- tooluniverse/visualization_tool.py +897 -0
- tooluniverse/wikidata_sparql_tool.py +60 -0
- tooluniverse/zenodo_tool.py +72 -0
- {tooluniverse-1.0.5.dist-info → tooluniverse-1.0.7.dist-info}/METADATA +12 -2
- tooluniverse-1.0.7.dist-info/RECORD +855 -0
- {tooluniverse-1.0.5.dist-info → tooluniverse-1.0.7.dist-info}/entry_points.txt +4 -0
- tooluniverse/test/list_azure_openai_models.py +0 -210
- tooluniverse/test/mcp_server_test.py +0 -0
- tooluniverse/test/test_admetai_tool.py +0 -370
- tooluniverse/test/test_agentic_tool.py +0 -129
- tooluniverse/test/test_agentic_tool_azure_models.py +0 -91
- tooluniverse/test/test_alphafold_tool.py +0 -108
- tooluniverse/test/test_api_key_validation_min.py +0 -64
- tooluniverse/test/test_chem_tool.py +0 -37
- tooluniverse/test/test_claude_sdk.py +0 -86
- tooluniverse/test/test_compose_lieraturereview.py +0 -63
- tooluniverse/test/test_compose_tool.py +0 -448
- tooluniverse/test/test_dailymed.py +0 -69
- tooluniverse/test/test_dataset_tool.py +0 -200
- tooluniverse/test/test_disease_target_score.py +0 -56
- tooluniverse/test/test_drugbank_filter_examples.py +0 -179
- tooluniverse/test/test_efo.py +0 -31
- tooluniverse/test/test_enrichr_tool.py +0 -21
- tooluniverse/test/test_europe_pmc_tool.py +0 -20
- tooluniverse/test/test_fda_adv.py +0 -95
- tooluniverse/test/test_fda_drug_labeling.py +0 -91
- tooluniverse/test/test_gene_ontology_tools.py +0 -66
- tooluniverse/test/test_global_fallback.py +0 -288
- tooluniverse/test/test_gwas_tool.py +0 -139
- tooluniverse/test/test_hooks_direct.py +0 -219
- tooluniverse/test/test_hpa.py +0 -625
- tooluniverse/test/test_humanbase_tool.py +0 -20
- tooluniverse/test/test_idmap_tools.py +0 -61
- tooluniverse/test/test_list_built_in_tools.py +0 -33
- tooluniverse/test/test_mcp_server.py +0 -211
- tooluniverse/test/test_mcp_tool.py +0 -247
- tooluniverse/test/test_medlineplus.py +0 -220
- tooluniverse/test/test_odphp_tool.py +0 -166
- tooluniverse/test/test_openalex_tool.py +0 -32
- tooluniverse/test/test_openrouter_client.py +0 -288
- tooluniverse/test/test_opentargets.py +0 -28
- tooluniverse/test/test_pubchem_tool.py +0 -116
- tooluniverse/test/test_pubtator_tool.py +0 -37
- tooluniverse/test/test_rcsb_pdb_tool.py +0 -86
- tooluniverse/test/test_reactome.py +0 -54
- tooluniverse/test/test_semantic_scholar_tool.py +0 -24
- tooluniverse/test/test_software_tools.py +0 -147
- tooluniverse/test/test_stdio_hooks.py +0 -285
- tooluniverse/test/test_tool_description_optimizer.py +0 -49
- tooluniverse/test/test_tool_finder.py +0 -26
- tooluniverse/test/test_tool_finder_llm.py +0 -252
- tooluniverse/test/test_tools_find.py +0 -195
- tooluniverse/test/test_uniprot_tools.py +0 -74
- tooluniverse/test/test_uspto_tool.py +0 -72
- tooluniverse/test/test_xml_tool.py +0 -113
- tooluniverse-1.0.5.dist-info/RECORD +0 -198
- {tooluniverse-1.0.5.dist-info → tooluniverse-1.0.7.dist-info}/WHEEL +0 -0
- {tooluniverse-1.0.5.dist-info → tooluniverse-1.0.7.dist-info}/licenses/LICENSE +0 -0
- {tooluniverse-1.0.5.dist-info → tooluniverse-1.0.7.dist-info}/top_level.txt +0 -0
tooluniverse/execute_function.py
CHANGED
|
@@ -25,17 +25,30 @@ Constants:
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
import copy
|
|
28
|
+
import inspect
|
|
28
29
|
import json
|
|
29
30
|
import random
|
|
30
31
|
import string
|
|
31
32
|
import os
|
|
32
33
|
import time
|
|
34
|
+
import hashlib
|
|
35
|
+
import warnings
|
|
36
|
+
from typing import Any, Dict, List, Optional
|
|
33
37
|
from .utils import read_json_list, evaluate_function_call, extract_function_call_json
|
|
38
|
+
from .exceptions import (
|
|
39
|
+
ToolError,
|
|
40
|
+
ToolUnavailableError,
|
|
41
|
+
ToolValidationError,
|
|
42
|
+
ToolConfigError,
|
|
43
|
+
ToolServerError,
|
|
44
|
+
)
|
|
34
45
|
from .tool_registry import (
|
|
35
46
|
auto_discover_tools,
|
|
36
47
|
get_tool_registry,
|
|
37
48
|
register_external_tool,
|
|
38
49
|
get_tool_class_lazy,
|
|
50
|
+
get_tool_errors,
|
|
51
|
+
mark_tool_unavailable,
|
|
39
52
|
)
|
|
40
53
|
from .logging_config import (
|
|
41
54
|
get_logger,
|
|
@@ -80,6 +93,82 @@ for _tool_name, _tool_class in sorted(tool_type_mappings.items()):
|
|
|
80
93
|
debug(f" - {_tool_name}: {_tool_class.__name__}")
|
|
81
94
|
|
|
82
95
|
|
|
96
|
+
class ToolCallable:
|
|
97
|
+
"""
|
|
98
|
+
A callable wrapper for a tool that validates kwargs and calls run_one_function.
|
|
99
|
+
|
|
100
|
+
This class provides the dynamic function interface for tools, allowing
|
|
101
|
+
them to be called like regular Python functions with keyword arguments.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
def __init__(self, engine: "ToolUniverse", tool_name: str):
|
|
105
|
+
self.engine = engine
|
|
106
|
+
self.tool_name = tool_name
|
|
107
|
+
self.schema = engine.all_tool_dict[tool_name]["parameter"]
|
|
108
|
+
self.__doc__ = engine.all_tool_dict[tool_name].get("description", tool_name)
|
|
109
|
+
|
|
110
|
+
def __call__(
|
|
111
|
+
self, *, stream_callback=None, use_cache=False, validate=True, **kwargs
|
|
112
|
+
):
|
|
113
|
+
"""
|
|
114
|
+
Execute the tool with the provided keyword arguments.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
stream_callback: Optional callback for streaming responses
|
|
118
|
+
use_cache: Whether to use result caching
|
|
119
|
+
validate: Whether to validate parameters against schema
|
|
120
|
+
**kwargs: Tool-specific arguments
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
Tool execution result
|
|
124
|
+
"""
|
|
125
|
+
function_call = {"name": self.tool_name, "arguments": kwargs}
|
|
126
|
+
return self.engine.run_one_function(
|
|
127
|
+
function_call,
|
|
128
|
+
stream_callback=stream_callback,
|
|
129
|
+
use_cache=use_cache,
|
|
130
|
+
validate=validate,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class ToolNamespace:
|
|
135
|
+
"""
|
|
136
|
+
Dynamic namespace for accessing tools as callable functions.
|
|
137
|
+
|
|
138
|
+
This class provides the `tu.tools.tool_name(**kwargs)` interface,
|
|
139
|
+
dynamically creating ToolCallable instances for each available tool.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
def __init__(self, engine: "ToolUniverse"):
|
|
143
|
+
self.engine = engine
|
|
144
|
+
|
|
145
|
+
def __getattr__(self, name: str) -> ToolCallable:
|
|
146
|
+
"""Return a ToolCallable for the requested tool name."""
|
|
147
|
+
if name in self.engine.all_tool_dict:
|
|
148
|
+
return ToolCallable(self.engine, name)
|
|
149
|
+
raise AttributeError(f"Tool '{name}' not found")
|
|
150
|
+
|
|
151
|
+
def __len__(self) -> int:
|
|
152
|
+
"""Return the number of available tools."""
|
|
153
|
+
return len(self.engine.all_tool_dict)
|
|
154
|
+
|
|
155
|
+
def __iter__(self):
|
|
156
|
+
"""Iterate over tool names."""
|
|
157
|
+
return iter(self.engine.all_tool_dict.keys())
|
|
158
|
+
|
|
159
|
+
def __contains__(self, name: str) -> bool:
|
|
160
|
+
"""Check if a tool exists."""
|
|
161
|
+
return name in self.engine.all_tool_dict
|
|
162
|
+
|
|
163
|
+
def refresh(self):
|
|
164
|
+
"""Refresh tool discovery (re-discover MCP/remote tools)."""
|
|
165
|
+
self.engine.refresh_tools()
|
|
166
|
+
|
|
167
|
+
def eager_load(self, names: Optional[List[str]] = None):
|
|
168
|
+
"""Pre-instantiate tools to reduce first-call latency."""
|
|
169
|
+
self.engine.eager_load_tools(names)
|
|
170
|
+
|
|
171
|
+
|
|
83
172
|
class ToolUniverse:
|
|
84
173
|
"""
|
|
85
174
|
A comprehensive tool management system for loading, organizing, and executing various scientific and data tools.
|
|
@@ -129,9 +218,9 @@ class ToolUniverse:
|
|
|
129
218
|
self.logger = get_logger("ToolUniverse")
|
|
130
219
|
|
|
131
220
|
# Initialize any necessary attributes here FIRST
|
|
132
|
-
self.all_tools = []
|
|
133
|
-
self.all_tool_dict = {}
|
|
134
|
-
self.tool_category_dicts = {}
|
|
221
|
+
self.all_tools: List[Dict[str, Any]] = []
|
|
222
|
+
self.all_tool_dict: Dict[str, Dict[str, Any]] = {}
|
|
223
|
+
self.tool_category_dicts: Dict[str, List[Dict[str, Any]]] = {}
|
|
135
224
|
self.tool_finder = None
|
|
136
225
|
if tool_files is None:
|
|
137
226
|
tool_files = default_tool_files
|
|
@@ -171,6 +260,16 @@ class ToolUniverse:
|
|
|
171
260
|
self.hook_manager = None
|
|
172
261
|
self.logger.debug("Output hooks disabled")
|
|
173
262
|
|
|
263
|
+
# Initialize new attributes for enhanced functionality
|
|
264
|
+
self._cache = {} # Simple cache for tool results
|
|
265
|
+
self._cache_size = int(os.getenv("TOOLUNIVERSE_CACHE_SIZE", "100"))
|
|
266
|
+
self._strict_validation = os.getenv(
|
|
267
|
+
"TOOLUNIVERSE_STRICT_VALIDATION", "false"
|
|
268
|
+
).lower() in ("true", "1", "yes")
|
|
269
|
+
|
|
270
|
+
# Initialize dynamic tools namespace
|
|
271
|
+
self.tools = ToolNamespace(self)
|
|
272
|
+
|
|
174
273
|
def register_custom_tool(self, tool_class, tool_name=None, tool_config=None):
|
|
175
274
|
"""
|
|
176
275
|
Register a custom tool class at runtime.
|
|
@@ -902,104 +1001,6 @@ class ToolUniverse:
|
|
|
902
1001
|
)
|
|
903
1002
|
self.logger.debug("_process_mcp_auto_loaders completed")
|
|
904
1003
|
|
|
905
|
-
def select_tools(
|
|
906
|
-
self,
|
|
907
|
-
include_names=None,
|
|
908
|
-
exclude_names=None,
|
|
909
|
-
include_categories=None,
|
|
910
|
-
exclude_categories=None,
|
|
911
|
-
):
|
|
912
|
-
"""
|
|
913
|
-
Select tools based on tool names and/or categories (tool_files keys).
|
|
914
|
-
|
|
915
|
-
Args:
|
|
916
|
-
include_names (list, optional): List of tool names to include. If None, include all.
|
|
917
|
-
exclude_names (list, optional): List of tool names to exclude.
|
|
918
|
-
include_categories (list, optional): List of categories (tool_files keys) to include.
|
|
919
|
-
If None, include all.
|
|
920
|
-
exclude_categories (list, optional): List of categories (tool_files keys) to exclude.
|
|
921
|
-
|
|
922
|
-
Returns:
|
|
923
|
-
list: List of selected tool configurations.
|
|
924
|
-
"""
|
|
925
|
-
selected_tools = []
|
|
926
|
-
# If categories are specified, use self.tool_category_dicts to filter
|
|
927
|
-
categories = set(self.tool_category_dicts.keys())
|
|
928
|
-
if include_categories is not None:
|
|
929
|
-
categories &= set(include_categories)
|
|
930
|
-
if exclude_categories is not None:
|
|
931
|
-
categories -= set(exclude_categories)
|
|
932
|
-
# Gather tools from selected categories
|
|
933
|
-
for cat in categories:
|
|
934
|
-
selected_tools.extend(self.tool_category_dicts[cat])
|
|
935
|
-
# Further filter by names if needed
|
|
936
|
-
if include_names is not None:
|
|
937
|
-
selected_tools = [
|
|
938
|
-
tool for tool in selected_tools if tool["name"] in include_names
|
|
939
|
-
]
|
|
940
|
-
if exclude_names is not None:
|
|
941
|
-
selected_tools = [
|
|
942
|
-
tool for tool in selected_tools if tool["name"] not in exclude_names
|
|
943
|
-
]
|
|
944
|
-
return selected_tools
|
|
945
|
-
|
|
946
|
-
def filter_tool_lists(
|
|
947
|
-
self,
|
|
948
|
-
tool_name_list,
|
|
949
|
-
tool_desc_list,
|
|
950
|
-
include_names=None,
|
|
951
|
-
exclude_names=None,
|
|
952
|
-
include_categories=None,
|
|
953
|
-
exclude_categories=None,
|
|
954
|
-
):
|
|
955
|
-
"""
|
|
956
|
-
Directly filter tool name and description lists based on names and/or categories.
|
|
957
|
-
|
|
958
|
-
This method takes existing tool name and description lists and filters them according
|
|
959
|
-
to the specified criteria using the select_tools method for category-based filtering.
|
|
960
|
-
|
|
961
|
-
Args:
|
|
962
|
-
tool_name_list (list): List of tool names to filter.
|
|
963
|
-
tool_desc_list (list): List of tool descriptions to filter (must correspond to tool_name_list).
|
|
964
|
-
include_names (list, optional): List of tool names to include.
|
|
965
|
-
exclude_names (list, optional): List of tool names to exclude.
|
|
966
|
-
include_categories (list, optional): List of categories to include.
|
|
967
|
-
exclude_categories (list, optional): List of categories to exclude.
|
|
968
|
-
|
|
969
|
-
Returns:
|
|
970
|
-
tuple: A tuple containing (filtered_tool_name_list, filtered_tool_desc_list).
|
|
971
|
-
"""
|
|
972
|
-
# Build a set of allowed tool names using select_tools for category filtering
|
|
973
|
-
allowed_names = set()
|
|
974
|
-
if any([include_names, exclude_names, include_categories, exclude_categories]):
|
|
975
|
-
filtered_tools = self.select_tools(
|
|
976
|
-
include_names=include_names,
|
|
977
|
-
exclude_names=exclude_names,
|
|
978
|
-
include_categories=include_categories,
|
|
979
|
-
exclude_categories=exclude_categories,
|
|
980
|
-
)
|
|
981
|
-
allowed_names = set(tool["name"] for tool in filtered_tools)
|
|
982
|
-
else:
|
|
983
|
-
allowed_names = set(tool_name_list)
|
|
984
|
-
|
|
985
|
-
# Filter lists by allowed_names
|
|
986
|
-
filtered_tool_name_list = []
|
|
987
|
-
filtered_tool_desc_list = []
|
|
988
|
-
for name, desc in zip(tool_name_list, tool_desc_list):
|
|
989
|
-
if name in allowed_names:
|
|
990
|
-
filtered_tool_name_list.append(name)
|
|
991
|
-
filtered_tool_desc_list.append(desc)
|
|
992
|
-
return filtered_tool_name_list, filtered_tool_desc_list
|
|
993
|
-
|
|
994
|
-
def return_all_loaded_tools(self):
|
|
995
|
-
"""
|
|
996
|
-
Return a deep copy of all loaded tools.
|
|
997
|
-
|
|
998
|
-
Returns:
|
|
999
|
-
list: A deep copy of the all_tools list to prevent external modification.
|
|
1000
|
-
"""
|
|
1001
|
-
return copy.deepcopy(self.all_tools)
|
|
1002
|
-
|
|
1003
1004
|
def list_built_in_tools(self, mode="config", scan_all=False):
|
|
1004
1005
|
"""
|
|
1005
1006
|
List all built-in tool categories and their statistics with different modes.
|
|
@@ -1210,6 +1211,39 @@ class ToolUniverse:
|
|
|
1210
1211
|
|
|
1211
1212
|
return result
|
|
1212
1213
|
|
|
1214
|
+
def _read_tools_from_file(self, file_path):
|
|
1215
|
+
"""
|
|
1216
|
+
Read tools from a single JSON file with error handling.
|
|
1217
|
+
|
|
1218
|
+
Args:
|
|
1219
|
+
file_path (str): Path to the JSON file
|
|
1220
|
+
|
|
1221
|
+
Returns:
|
|
1222
|
+
list: List of tool configurations from the file
|
|
1223
|
+
"""
|
|
1224
|
+
try:
|
|
1225
|
+
tools_in_file = read_json_list(file_path)
|
|
1226
|
+
|
|
1227
|
+
# Handle different data formats
|
|
1228
|
+
if isinstance(tools_in_file, dict):
|
|
1229
|
+
# Convert dict of tools to list of tools
|
|
1230
|
+
tools_in_file = list(tools_in_file.values())
|
|
1231
|
+
elif not isinstance(tools_in_file, list):
|
|
1232
|
+
# Skip files that don't contain tool configurations
|
|
1233
|
+
return []
|
|
1234
|
+
|
|
1235
|
+
# Validate tools have required fields
|
|
1236
|
+
valid_tools = []
|
|
1237
|
+
for tool in tools_in_file:
|
|
1238
|
+
if isinstance(tool, dict) and "name" in tool:
|
|
1239
|
+
valid_tools.append(tool)
|
|
1240
|
+
|
|
1241
|
+
return valid_tools
|
|
1242
|
+
|
|
1243
|
+
except Exception as e:
|
|
1244
|
+
warning(f"Warning: Could not read tools from {file_path}: {e}")
|
|
1245
|
+
return []
|
|
1246
|
+
|
|
1213
1247
|
def _scan_predefined_files(self):
|
|
1214
1248
|
"""
|
|
1215
1249
|
Scan predefined tool files (original behavior).
|
|
@@ -1222,39 +1256,23 @@ class ToolUniverse:
|
|
|
1222
1256
|
all_tool_names = set()
|
|
1223
1257
|
|
|
1224
1258
|
# Read tools from each category file
|
|
1225
|
-
for
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
all_tools.extend(tools_in_category)
|
|
1230
|
-
all_tool_names.update([tool["name"] for tool in tools_in_category])
|
|
1231
|
-
except Exception as e:
|
|
1232
|
-
warning(
|
|
1233
|
-
f"Warning: Could not read tools from {category} ({file_path}): {e}"
|
|
1234
|
-
)
|
|
1259
|
+
for _category, file_path in self.tool_files.items():
|
|
1260
|
+
tools_in_category = self._read_tools_from_file(file_path)
|
|
1261
|
+
all_tools.extend(tools_in_category)
|
|
1262
|
+
all_tool_names.update([tool["name"] for tool in tools_in_category])
|
|
1235
1263
|
|
|
1236
1264
|
# Also include remote tools
|
|
1237
1265
|
try:
|
|
1238
1266
|
remote_dir = os.path.join(current_dir, "data", "remote_tools")
|
|
1239
1267
|
if os.path.isdir(remote_dir):
|
|
1240
|
-
remote_tools = []
|
|
1241
1268
|
for fname in os.listdir(remote_dir):
|
|
1242
1269
|
if not fname.lower().endswith(".json"):
|
|
1243
1270
|
continue
|
|
1244
1271
|
fpath = os.path.join(remote_dir, fname)
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
if isinstance(tools_in_file, list):
|
|
1250
|
-
remote_tools.extend(tools_in_file)
|
|
1251
|
-
except Exception as e:
|
|
1252
|
-
warning(
|
|
1253
|
-
f"Warning: Could not read remote tools from {fpath}: {e}"
|
|
1254
|
-
)
|
|
1255
|
-
if remote_tools:
|
|
1256
|
-
all_tools.extend(remote_tools)
|
|
1257
|
-
all_tool_names.update([tool["name"] for tool in remote_tools])
|
|
1272
|
+
remote_tools = self._read_tools_from_file(fpath)
|
|
1273
|
+
if remote_tools:
|
|
1274
|
+
all_tools.extend(remote_tools)
|
|
1275
|
+
all_tool_names.update([tool["name"] for tool in remote_tools])
|
|
1258
1276
|
except Exception as e:
|
|
1259
1277
|
warning(f"Warning: Failed to scan remote tools directory: {e}")
|
|
1260
1278
|
|
|
@@ -1287,31 +1305,14 @@ class ToolUniverse:
|
|
|
1287
1305
|
|
|
1288
1306
|
self.logger.debug(f"Found {len(json_files)} JSON files to scan")
|
|
1289
1307
|
|
|
1290
|
-
# Read tools from each JSON file
|
|
1308
|
+
# Read tools from each JSON file using the common method
|
|
1291
1309
|
for json_file in json_files:
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
if isinstance(tools_in_file, dict):
|
|
1297
|
-
# Convert dict of tools to list of tools
|
|
1298
|
-
tools_in_file = list(tools_in_file.values())
|
|
1299
|
-
elif not isinstance(tools_in_file, list):
|
|
1300
|
-
# Skip files that don't contain tool configurations
|
|
1301
|
-
continue
|
|
1302
|
-
|
|
1303
|
-
# Add tools to our collection
|
|
1304
|
-
for tool in tools_in_file:
|
|
1305
|
-
if isinstance(tool, dict) and "name" in tool:
|
|
1306
|
-
all_tools.append(tool)
|
|
1307
|
-
all_tool_names.add(tool["name"])
|
|
1308
|
-
|
|
1310
|
+
tools_in_file = self._read_tools_from_file(json_file)
|
|
1311
|
+
if tools_in_file:
|
|
1312
|
+
all_tools.extend(tools_in_file)
|
|
1313
|
+
all_tool_names.update([tool["name"] for tool in tools_in_file])
|
|
1309
1314
|
self.logger.debug(f"Loaded {len(tools_in_file)} tools from {json_file}")
|
|
1310
1315
|
|
|
1311
|
-
except Exception as e:
|
|
1312
|
-
warning(f"Warning: Could not read tools from {json_file}: {e}")
|
|
1313
|
-
continue
|
|
1314
|
-
|
|
1315
1316
|
self.logger.info(
|
|
1316
1317
|
f"Scanned {len(json_files)} JSON files, found {len(all_tools)} tools"
|
|
1317
1318
|
)
|
|
@@ -1386,63 +1387,42 @@ class ToolUniverse:
|
|
|
1386
1387
|
del tool[key]
|
|
1387
1388
|
return tool
|
|
1388
1389
|
|
|
1389
|
-
def prepare_tool_prompts(self, tool_list):
|
|
1390
|
-
"""
|
|
1391
|
-
Prepare a list of tool configurations for prompt usage.
|
|
1392
|
-
|
|
1393
|
-
Args:
|
|
1394
|
-
tool_list (list): List of tool configuration dictionaries.
|
|
1395
|
-
|
|
1396
|
-
Returns:
|
|
1397
|
-
list: List of tool configurations with only essential keys for prompting.
|
|
1398
|
-
"""
|
|
1399
|
-
copied_list = []
|
|
1400
|
-
for tool in tool_list:
|
|
1401
|
-
copied_list.append(self.prepare_one_tool_prompt(tool))
|
|
1402
|
-
return copied_list
|
|
1403
|
-
|
|
1404
|
-
def remove_keys(self, tool_list, invalid_keys):
|
|
1390
|
+
def prepare_tool_prompts(self, tool_list, mode="prompt", valid_keys=None):
|
|
1405
1391
|
"""
|
|
1406
|
-
|
|
1392
|
+
Prepare a list of tool configurations for different usage modes.
|
|
1407
1393
|
|
|
1408
1394
|
Args:
|
|
1409
1395
|
tool_list (list): List of tool configuration dictionaries.
|
|
1410
|
-
|
|
1396
|
+
mode (str): Preparation mode. Options:
|
|
1397
|
+
- 'prompt': Keep essential keys for prompting (name, description, parameter, required)
|
|
1398
|
+
- 'example': Keep extended keys for examples (name, description, parameter, required, query_schema, fields, label, type)
|
|
1399
|
+
- 'custom': Use custom valid_keys parameter
|
|
1400
|
+
valid_keys (list, optional): Custom list of keys to keep when mode='custom'.
|
|
1411
1401
|
|
|
1412
1402
|
Returns:
|
|
1413
|
-
list:
|
|
1414
|
-
"""
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1403
|
+
list: List of tool configurations with only specified keys.
|
|
1404
|
+
"""
|
|
1405
|
+
if mode == "prompt":
|
|
1406
|
+
valid_keys = ["name", "description", "parameter", "required"]
|
|
1407
|
+
elif mode == "example":
|
|
1408
|
+
valid_keys = [
|
|
1409
|
+
"name",
|
|
1410
|
+
"description",
|
|
1411
|
+
"parameter",
|
|
1412
|
+
"required",
|
|
1413
|
+
"query_schema",
|
|
1414
|
+
"fields",
|
|
1415
|
+
"label",
|
|
1416
|
+
"type",
|
|
1417
|
+
]
|
|
1418
|
+
elif mode == "custom":
|
|
1419
|
+
if valid_keys is None:
|
|
1420
|
+
raise ValueError("valid_keys must be provided when mode='custom'")
|
|
1421
|
+
else:
|
|
1422
|
+
raise ValueError(
|
|
1423
|
+
f"Invalid mode: {mode}. Must be 'prompt', 'example', or 'custom'"
|
|
1424
|
+
)
|
|
1432
1425
|
|
|
1433
|
-
Returns:
|
|
1434
|
-
list: Deep copy of tool list with only example-relevant keys.
|
|
1435
|
-
"""
|
|
1436
|
-
valid_keys = [
|
|
1437
|
-
"name",
|
|
1438
|
-
"description",
|
|
1439
|
-
"parameter",
|
|
1440
|
-
"required",
|
|
1441
|
-
"query_schema",
|
|
1442
|
-
"fields",
|
|
1443
|
-
"label",
|
|
1444
|
-
"type",
|
|
1445
|
-
]
|
|
1446
1426
|
copied_list = copy.deepcopy(tool_list)
|
|
1447
1427
|
for tool in copied_list:
|
|
1448
1428
|
# Create a list of keys to avoid modifying the dictionary during iteration
|
|
@@ -1471,21 +1451,6 @@ class ToolUniverse:
|
|
|
1471
1451
|
picked_tool_list.append(tool_spec)
|
|
1472
1452
|
return picked_tool_list
|
|
1473
1453
|
|
|
1474
|
-
def get_tool_by_name(self, tool_names, format="default"):
|
|
1475
|
-
"""
|
|
1476
|
-
Retrieve tool configurations by their names.
|
|
1477
|
-
|
|
1478
|
-
Args:
|
|
1479
|
-
tool_names (list): List of tool names to retrieve.
|
|
1480
|
-
format (str, optional): Output format. Options: 'default', 'openai'.
|
|
1481
|
-
If 'openai', returns OpenAI function calling format. Defaults to 'default'.
|
|
1482
|
-
|
|
1483
|
-
Returns:
|
|
1484
|
-
list: List of tool configurations for the specified names.
|
|
1485
|
-
Tools not found will be reported but not included in the result.
|
|
1486
|
-
"""
|
|
1487
|
-
return self.get_tool_specification_by_names(tool_names, format=format)
|
|
1488
|
-
|
|
1489
1454
|
def get_one_tool_by_one_name(self, tool_name, return_prompt=True):
|
|
1490
1455
|
"""
|
|
1491
1456
|
Retrieve a single tool specification by name, optionally prepared for prompting.
|
|
@@ -1520,65 +1485,58 @@ class ToolUniverse:
|
|
|
1520
1485
|
Returns:
|
|
1521
1486
|
dict or None: Tool configuration if found, None otherwise.
|
|
1522
1487
|
"""
|
|
1523
|
-
if tool_name in self.all_tool_dict:
|
|
1524
|
-
tool_config = self.all_tool_dict[tool_name]
|
|
1525
|
-
|
|
1526
|
-
if format == "openai":
|
|
1527
|
-
parameters = tool_config.get("parameter", {})
|
|
1528
|
-
if isinstance(parameters, dict):
|
|
1529
|
-
# 修复 required 字段格式
|
|
1530
|
-
if "properties" in parameters:
|
|
1531
|
-
for _prop_name, prop_config in parameters["properties"].items():
|
|
1532
|
-
if (
|
|
1533
|
-
isinstance(prop_config, dict)
|
|
1534
|
-
and "required" in prop_config
|
|
1535
|
-
):
|
|
1536
|
-
del prop_config["required"]
|
|
1537
|
-
|
|
1538
|
-
if "required" in parameters and not isinstance(
|
|
1539
|
-
parameters["required"], list
|
|
1540
|
-
):
|
|
1541
|
-
if parameters["required"] is True:
|
|
1542
|
-
required_list = []
|
|
1543
|
-
if "properties" in parameters:
|
|
1544
|
-
for prop_name, prop_config in parameters[
|
|
1545
|
-
"properties"
|
|
1546
|
-
].items():
|
|
1547
|
-
if (
|
|
1548
|
-
isinstance(prop_config, dict)
|
|
1549
|
-
and prop_config.get("required") is True
|
|
1550
|
-
):
|
|
1551
|
-
required_list.append(prop_name)
|
|
1552
|
-
parameters["required"] = required_list
|
|
1553
|
-
else:
|
|
1554
|
-
parameters["required"] = []
|
|
1555
|
-
|
|
1556
|
-
return {
|
|
1557
|
-
"name": tool_config["name"],
|
|
1558
|
-
"description": tool_config["description"],
|
|
1559
|
-
"parameters": parameters,
|
|
1560
|
-
}
|
|
1561
|
-
elif return_prompt:
|
|
1562
|
-
return self.prepare_one_tool_prompt(tool_config)
|
|
1563
|
-
else:
|
|
1564
|
-
return tool_config
|
|
1565
|
-
else:
|
|
1488
|
+
if tool_name not in self.all_tool_dict:
|
|
1566
1489
|
warning(f"Tool name {tool_name} not found in the loaded tools.")
|
|
1567
1490
|
return None
|
|
1568
1491
|
|
|
1569
|
-
|
|
1570
|
-
"""
|
|
1571
|
-
Get the description of a tool by its name.
|
|
1492
|
+
tool_config = self.all_tool_dict[tool_name]
|
|
1572
1493
|
|
|
1573
|
-
|
|
1494
|
+
if return_prompt:
|
|
1495
|
+
return self.prepare_one_tool_prompt(tool_config)
|
|
1574
1496
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1497
|
+
# Process parameter schema based on format
|
|
1498
|
+
if "parameter" in tool_config and isinstance(tool_config["parameter"], dict):
|
|
1499
|
+
import copy
|
|
1577
1500
|
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1501
|
+
processed_config = copy.deepcopy(tool_config)
|
|
1502
|
+
parameter_schema = processed_config["parameter"]
|
|
1503
|
+
|
|
1504
|
+
if (
|
|
1505
|
+
"properties" in parameter_schema
|
|
1506
|
+
and parameter_schema["properties"] is not None
|
|
1507
|
+
):
|
|
1508
|
+
required_properties = parameter_schema.get("required", [])
|
|
1509
|
+
|
|
1510
|
+
if format == "openai":
|
|
1511
|
+
# For OpenAI format: remove property-level required fields
|
|
1512
|
+
for _prop_name, prop_config in parameter_schema[
|
|
1513
|
+
"properties"
|
|
1514
|
+
].items():
|
|
1515
|
+
if isinstance(prop_config, dict) and "required" in prop_config:
|
|
1516
|
+
del prop_config["required"]
|
|
1517
|
+
|
|
1518
|
+
# Ensure required is a list
|
|
1519
|
+
if not isinstance(parameter_schema.get("required"), list):
|
|
1520
|
+
parameter_schema["required"] = (
|
|
1521
|
+
required_properties if required_properties else []
|
|
1522
|
+
)
|
|
1523
|
+
|
|
1524
|
+
return {
|
|
1525
|
+
"name": processed_config["name"],
|
|
1526
|
+
"description": processed_config["description"],
|
|
1527
|
+
"parameters": parameter_schema,
|
|
1528
|
+
}
|
|
1529
|
+
else:
|
|
1530
|
+
# For default format: add required fields to properties
|
|
1531
|
+
for prop_name, prop_config in parameter_schema[
|
|
1532
|
+
"properties"
|
|
1533
|
+
].items():
|
|
1534
|
+
if isinstance(prop_config, dict):
|
|
1535
|
+
prop_config["required"] = prop_name in required_properties
|
|
1536
|
+
|
|
1537
|
+
return processed_config
|
|
1538
|
+
|
|
1539
|
+
return tool_config
|
|
1582
1540
|
|
|
1583
1541
|
def get_tool_type_by_name(self, tool_name):
|
|
1584
1542
|
"""
|
|
@@ -1595,6 +1553,15 @@ class ToolUniverse:
|
|
|
1595
1553
|
"""
|
|
1596
1554
|
return self.all_tool_dict[tool_name]["type"]
|
|
1597
1555
|
|
|
1556
|
+
def call_id_gen(self):
|
|
1557
|
+
"""
|
|
1558
|
+
Generate a random call ID for function calls.
|
|
1559
|
+
|
|
1560
|
+
Returns:
|
|
1561
|
+
str: A random 9-character string composed of letters and digits.
|
|
1562
|
+
"""
|
|
1563
|
+
return "".join(random.choices(string.ascii_letters + string.digits, k=9))
|
|
1564
|
+
|
|
1598
1565
|
def tool_to_str(self, tool_list):
|
|
1599
1566
|
"""
|
|
1600
1567
|
Convert a list of tool configurations to a formatted string.
|
|
@@ -1629,16 +1596,23 @@ class ToolUniverse:
|
|
|
1629
1596
|
lst, return_message=return_message, verbose=verbose, format=format
|
|
1630
1597
|
)
|
|
1631
1598
|
|
|
1632
|
-
def
|
|
1599
|
+
def return_all_loaded_tools(self):
|
|
1633
1600
|
"""
|
|
1634
|
-
|
|
1601
|
+
Return a deep copy of all loaded tools.
|
|
1635
1602
|
|
|
1636
1603
|
Returns:
|
|
1637
|
-
|
|
1604
|
+
list: A deep copy of the all_tools list to prevent external modification.
|
|
1638
1605
|
"""
|
|
1639
|
-
return
|
|
1606
|
+
return copy.deepcopy(self.all_tools)
|
|
1640
1607
|
|
|
1641
|
-
def run(
|
|
1608
|
+
def run(
|
|
1609
|
+
self,
|
|
1610
|
+
fcall_str,
|
|
1611
|
+
return_message=False,
|
|
1612
|
+
verbose=True,
|
|
1613
|
+
format="llama",
|
|
1614
|
+
stream_callback=None,
|
|
1615
|
+
):
|
|
1642
1616
|
"""
|
|
1643
1617
|
Execute function calls from input string or data.
|
|
1644
1618
|
|
|
@@ -1671,7 +1645,9 @@ class ToolUniverse:
|
|
|
1671
1645
|
# return the function call+result message with call id.
|
|
1672
1646
|
call_results = []
|
|
1673
1647
|
for i in range(len(function_call_json)):
|
|
1674
|
-
call_result = self.run_one_function(
|
|
1648
|
+
call_result = self.run_one_function(
|
|
1649
|
+
function_call_json[i], stream_callback=stream_callback
|
|
1650
|
+
)
|
|
1675
1651
|
call_id = self.call_id_gen()
|
|
1676
1652
|
function_call_json[i]["call_id"] = call_id
|
|
1677
1653
|
call_results.append(
|
|
@@ -1691,12 +1667,16 @@ class ToolUniverse:
|
|
|
1691
1667
|
] + call_results
|
|
1692
1668
|
return revised_messages
|
|
1693
1669
|
else:
|
|
1694
|
-
return self.run_one_function(
|
|
1670
|
+
return self.run_one_function(
|
|
1671
|
+
function_call_json, stream_callback=stream_callback
|
|
1672
|
+
)
|
|
1695
1673
|
else:
|
|
1696
1674
|
error("Not a function call")
|
|
1697
1675
|
return None
|
|
1698
1676
|
|
|
1699
|
-
def run_one_function(
|
|
1677
|
+
def run_one_function(
|
|
1678
|
+
self, function_call_json, stream_callback=None, use_cache=False, validate=True
|
|
1679
|
+
):
|
|
1700
1680
|
"""
|
|
1701
1681
|
Execute a single function call.
|
|
1702
1682
|
|
|
@@ -1706,49 +1686,137 @@ class ToolUniverse:
|
|
|
1706
1686
|
|
|
1707
1687
|
Args:
|
|
1708
1688
|
function_call_json (dict): Dictionary containing function name and arguments.
|
|
1689
|
+
stream_callback (callable, optional): Callback for streaming responses.
|
|
1690
|
+
use_cache (bool, optional): Whether to use result caching. Defaults to False.
|
|
1691
|
+
validate (bool, optional): Whether to validate parameters against schema. Defaults to True.
|
|
1709
1692
|
|
|
1710
1693
|
Returns:
|
|
1711
1694
|
str or dict: Result from the tool execution, or error message if validation fails.
|
|
1712
1695
|
"""
|
|
1713
|
-
check_status, check_message = self.check_function_call(function_call_json)
|
|
1714
|
-
if check_status is False:
|
|
1715
|
-
return (
|
|
1716
|
-
"Invalid function call: " + check_message
|
|
1717
|
-
) # + " You must correct your invalid function call!"
|
|
1718
1696
|
function_name = function_call_json["name"]
|
|
1719
1697
|
arguments = function_call_json["arguments"]
|
|
1720
1698
|
|
|
1699
|
+
# Check cache first if enabled
|
|
1700
|
+
if use_cache:
|
|
1701
|
+
cache_key = self._make_cache_key(function_name, arguments)
|
|
1702
|
+
if cache_key in self._cache:
|
|
1703
|
+
self.logger.debug(f"Cache hit for {function_name}")
|
|
1704
|
+
return self._cache[cache_key]
|
|
1705
|
+
|
|
1706
|
+
# Validate parameters if requested
|
|
1707
|
+
if validate:
|
|
1708
|
+
validation_error = self._validate_parameters(function_name, arguments)
|
|
1709
|
+
if validation_error:
|
|
1710
|
+
return self._create_dual_format_error(validation_error)
|
|
1711
|
+
|
|
1712
|
+
# Check function call format (existing validation)
|
|
1713
|
+
check_status, check_message = self.check_function_call(function_call_json)
|
|
1714
|
+
if check_status is False:
|
|
1715
|
+
error_msg = "Invalid function call: " + check_message
|
|
1716
|
+
return self._create_dual_format_error(
|
|
1717
|
+
ToolValidationError(error_msg, details={"check_message": check_message})
|
|
1718
|
+
)
|
|
1719
|
+
|
|
1721
1720
|
# Execute the tool
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1721
|
+
tool_instance = None
|
|
1722
|
+
tool_arguments = arguments
|
|
1723
|
+
try:
|
|
1724
|
+
# Get or create tool instance (optimized to avoid duplication)
|
|
1725
|
+
tool_instance = self._get_tool_instance(function_name, cache=True)
|
|
1726
|
+
|
|
1727
|
+
if tool_instance:
|
|
1728
|
+
result, tool_arguments = self._execute_tool_with_stream(
|
|
1729
|
+
tool_instance, arguments, stream_callback, use_cache, validate
|
|
1731
1730
|
)
|
|
1732
|
-
result = tool.run(arguments)
|
|
1733
1731
|
else:
|
|
1734
|
-
|
|
1732
|
+
error_msg = f"Tool '{function_name}' not found"
|
|
1733
|
+
return self._create_dual_format_error(
|
|
1734
|
+
ToolUnavailableError(
|
|
1735
|
+
error_msg,
|
|
1736
|
+
next_steps=[
|
|
1737
|
+
"Check tool name spelling",
|
|
1738
|
+
"Run tu.tools.refresh()",
|
|
1739
|
+
],
|
|
1740
|
+
)
|
|
1741
|
+
)
|
|
1742
|
+
except Exception as e:
|
|
1743
|
+
# Classify and return structured error
|
|
1744
|
+
classified_error = self._classify_exception(e, function_name, arguments)
|
|
1745
|
+
return self._create_dual_format_error(classified_error)
|
|
1735
1746
|
|
|
1736
1747
|
# Apply output hooks if enabled
|
|
1737
1748
|
if self.hook_manager:
|
|
1738
1749
|
context = {
|
|
1739
1750
|
"tool_name": function_name,
|
|
1740
1751
|
"tool_type": (
|
|
1741
|
-
|
|
1752
|
+
tool_instance.__class__.__name__
|
|
1753
|
+
if tool_instance is not None
|
|
1754
|
+
else "unknown"
|
|
1742
1755
|
),
|
|
1743
1756
|
"execution_time": time.time(),
|
|
1744
|
-
"arguments":
|
|
1757
|
+
"arguments": tool_arguments,
|
|
1745
1758
|
}
|
|
1746
1759
|
result = self.hook_manager.apply_hooks(
|
|
1747
|
-
result, function_name,
|
|
1760
|
+
result, function_name, tool_arguments, context
|
|
1748
1761
|
)
|
|
1749
1762
|
|
|
1763
|
+
# Cache result if enabled
|
|
1764
|
+
if use_cache:
|
|
1765
|
+
cache_key = self._make_cache_key(function_name, arguments)
|
|
1766
|
+
self._cache[cache_key] = result
|
|
1767
|
+
# Simple cache size management
|
|
1768
|
+
if len(self._cache) > self._cache_size:
|
|
1769
|
+
# Remove oldest entries (simple FIFO)
|
|
1770
|
+
oldest_key = next(iter(self._cache))
|
|
1771
|
+
del self._cache[oldest_key]
|
|
1772
|
+
|
|
1750
1773
|
return result
|
|
1751
1774
|
|
|
1775
|
+
def _execute_tool_with_stream(
|
|
1776
|
+
self, tool_instance, arguments, stream_callback, use_cache=False, validate=True
|
|
1777
|
+
):
|
|
1778
|
+
"""Invoke a tool, forwarding stream callbacks and other parameters when supported."""
|
|
1779
|
+
|
|
1780
|
+
tool_arguments = arguments
|
|
1781
|
+
stream_flag_key = (
|
|
1782
|
+
getattr(tool_instance, "STREAM_FLAG_KEY", None) if stream_callback else None
|
|
1783
|
+
)
|
|
1784
|
+
|
|
1785
|
+
if isinstance(arguments, dict):
|
|
1786
|
+
tool_arguments = dict(arguments)
|
|
1787
|
+
|
|
1788
|
+
if (
|
|
1789
|
+
stream_callback
|
|
1790
|
+
and stream_flag_key
|
|
1791
|
+
and stream_flag_key not in tool_arguments
|
|
1792
|
+
):
|
|
1793
|
+
tool_arguments[stream_flag_key] = True
|
|
1794
|
+
|
|
1795
|
+
# Try to pass all available parameters to the tool
|
|
1796
|
+
try:
|
|
1797
|
+
signature = inspect.signature(tool_instance.run)
|
|
1798
|
+
params = signature.parameters
|
|
1799
|
+
|
|
1800
|
+
# Build kwargs based on what the tool accepts
|
|
1801
|
+
kwargs = {}
|
|
1802
|
+
|
|
1803
|
+
# Always include arguments as first positional argument
|
|
1804
|
+
if stream_callback is not None and "stream_callback" in params:
|
|
1805
|
+
kwargs["stream_callback"] = stream_callback
|
|
1806
|
+
if "use_cache" in params:
|
|
1807
|
+
kwargs["use_cache"] = use_cache
|
|
1808
|
+
if "validate" in params:
|
|
1809
|
+
kwargs["validate"] = validate
|
|
1810
|
+
|
|
1811
|
+
# Call with all supported parameters
|
|
1812
|
+
return tool_instance.run(tool_arguments, **kwargs), tool_arguments
|
|
1813
|
+
|
|
1814
|
+
except (ValueError, TypeError) as e:
|
|
1815
|
+
# If inspection fails or tool doesn't accept extra params,
|
|
1816
|
+
# fall back to simple execution with just arguments
|
|
1817
|
+
self.logger.debug(f"Falling back to simple run() call: {e}")
|
|
1818
|
+
return tool_instance.run(tool_arguments), tool_arguments
|
|
1819
|
+
|
|
1752
1820
|
def toggle_hooks(self, enabled: bool):
|
|
1753
1821
|
"""
|
|
1754
1822
|
Enable or disable output hooks globally.
|
|
@@ -1784,65 +1852,215 @@ class ToolUniverse:
|
|
|
1784
1852
|
add_to_cache (bool, optional): Whether to cache the initialized tool. Defaults to True.
|
|
1785
1853
|
|
|
1786
1854
|
Returns:
|
|
1787
|
-
object: Initialized tool instance.
|
|
1855
|
+
object: Initialized tool instance or None if initialization fails.
|
|
1788
1856
|
|
|
1789
1857
|
Raises:
|
|
1790
1858
|
KeyError: If the tool type is not found in tool_type_mappings.
|
|
1791
1859
|
"""
|
|
1792
1860
|
global tool_type_mappings
|
|
1793
1861
|
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
if "
|
|
1817
|
-
|
|
1862
|
+
try:
|
|
1863
|
+
if tool_name is not None:
|
|
1864
|
+
# Use lazy loading to get the tool class
|
|
1865
|
+
tool_class = get_tool_class_lazy(tool_name)
|
|
1866
|
+
if tool_class is None:
|
|
1867
|
+
raise KeyError(f"Tool type '{tool_name}' not found in registry")
|
|
1868
|
+
new_tool = tool_class()
|
|
1869
|
+
else:
|
|
1870
|
+
tool_type = tool["type"]
|
|
1871
|
+
tool_name = tool["name"]
|
|
1872
|
+
|
|
1873
|
+
# Use lazy loading to get the tool class
|
|
1874
|
+
tool_class = get_tool_class_lazy(tool_type)
|
|
1875
|
+
if tool_class is None:
|
|
1876
|
+
# Fallback to old method if lazy loading fails
|
|
1877
|
+
if tool_type not in tool_type_mappings:
|
|
1878
|
+
# Refresh registry and try again
|
|
1879
|
+
tool_type_mappings = get_tool_registry()
|
|
1880
|
+
if tool_type not in tool_type_mappings:
|
|
1881
|
+
raise KeyError(f"Tool type '{tool_type}' not found in registry")
|
|
1882
|
+
tool_class = tool_type_mappings[tool_type]
|
|
1883
|
+
|
|
1884
|
+
if "OpentargetToolDrugNameMatch" == tool_type:
|
|
1885
|
+
if (
|
|
1818
1886
|
"FDADrugLabelGetDrugGenericNameTool"
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
drug_tool_class =
|
|
1887
|
+
not in self.callable_functions
|
|
1888
|
+
):
|
|
1889
|
+
drug_tool_class = get_tool_class_lazy(
|
|
1890
|
+
"FDADrugLabelGetDrugGenericNameTool"
|
|
1891
|
+
)
|
|
1892
|
+
if drug_tool_class is None:
|
|
1893
|
+
drug_tool_class = tool_type_mappings[
|
|
1894
|
+
"FDADrugLabelGetDrugGenericNameTool"
|
|
1895
|
+
]
|
|
1896
|
+
self.callable_functions[
|
|
1822
1897
|
"FDADrugLabelGetDrugGenericNameTool"
|
|
1823
|
-
]
|
|
1824
|
-
|
|
1825
|
-
|
|
1898
|
+
] = drug_tool_class()
|
|
1899
|
+
new_tool = tool_class(
|
|
1900
|
+
tool_config=tool,
|
|
1901
|
+
drug_generic_tool=self.callable_functions[
|
|
1902
|
+
"FDADrugLabelGetDrugGenericNameTool"
|
|
1903
|
+
],
|
|
1826
1904
|
)
|
|
1827
|
-
|
|
1828
|
-
tool_config=tool,
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1905
|
+
elif "ToolFinderEmbedding" == tool_type:
|
|
1906
|
+
new_tool = tool_class(tool_config=tool, tooluniverse=self)
|
|
1907
|
+
elif "ComposeTool" == tool_type:
|
|
1908
|
+
new_tool = tool_class(tool_config=tool, tooluniverse=self)
|
|
1909
|
+
elif "ToolFinderLLM" == tool_type:
|
|
1910
|
+
new_tool = tool_class(tool_config=tool, tooluniverse=self)
|
|
1911
|
+
elif "ToolFinderKeyword" == tool_type:
|
|
1912
|
+
new_tool = tool_class(tool_config=tool, tooluniverse=self)
|
|
1913
|
+
else:
|
|
1914
|
+
new_tool = tool_class(tool_config=tool)
|
|
1915
|
+
|
|
1916
|
+
if add_to_cache:
|
|
1917
|
+
self.callable_functions[tool_name] = new_tool
|
|
1918
|
+
return new_tool
|
|
1919
|
+
|
|
1920
|
+
except Exception as e:
|
|
1921
|
+
tool_type = tool_name if tool_name else tool.get("type")
|
|
1922
|
+
mark_tool_unavailable(tool_type, e)
|
|
1923
|
+
self.logger.warning(f"Failed to initialize '{tool_type}': {e}")
|
|
1924
|
+
return None # Return None instead of raising
|
|
1925
|
+
|
|
1926
|
+
def _get_tool_instance(self, function_name: str, cache: bool = True):
|
|
1927
|
+
"""Get or create tool instance with optional caching."""
|
|
1928
|
+
# Check cache first
|
|
1929
|
+
if function_name in self.callable_functions:
|
|
1930
|
+
return self.callable_functions[function_name]
|
|
1931
|
+
|
|
1932
|
+
# Check if known unavailable
|
|
1933
|
+
tool_errors = get_tool_errors()
|
|
1934
|
+
if function_name in tool_errors:
|
|
1935
|
+
self.logger.debug(f"Tool {function_name} is unavailable")
|
|
1936
|
+
return None
|
|
1937
|
+
|
|
1938
|
+
# Try to initialize
|
|
1939
|
+
if function_name in self.all_tool_dict:
|
|
1940
|
+
return self.init_tool(self.all_tool_dict[function_name], add_to_cache=cache)
|
|
1941
|
+
|
|
1942
|
+
return None
|
|
1943
|
+
|
|
1944
|
+
def _make_cache_key(self, function_name: str, arguments: dict) -> str:
|
|
1945
|
+
"""Generate cache key by delegating to BaseTool."""
|
|
1946
|
+
tool_instance = self._get_tool_instance(function_name, cache=False)
|
|
1947
|
+
|
|
1948
|
+
if tool_instance:
|
|
1949
|
+
return tool_instance.get_cache_key(arguments)
|
|
1950
|
+
|
|
1951
|
+
# Fallback: simple hash-based key
|
|
1952
|
+
serialized = json.dumps(
|
|
1953
|
+
{"name": function_name, "args": arguments}, sort_keys=True
|
|
1954
|
+
)
|
|
1955
|
+
return hashlib.md5(serialized.encode()).hexdigest()
|
|
1956
|
+
|
|
1957
|
+
def _validate_parameters(
|
|
1958
|
+
self, function_name: str, arguments: dict
|
|
1959
|
+
) -> Optional[ToolError]:
|
|
1960
|
+
"""Validate parameters by delegating to BaseTool."""
|
|
1961
|
+
if function_name not in self.all_tool_dict:
|
|
1962
|
+
return ToolUnavailableError(f"Tool '{function_name}' not found")
|
|
1963
|
+
|
|
1964
|
+
tool_instance = self._get_tool_instance(function_name, cache=False)
|
|
1965
|
+
if not tool_instance:
|
|
1966
|
+
return ToolConfigError("Failed to initialize tool for validation")
|
|
1967
|
+
|
|
1968
|
+
# Check if tool has validate_parameters method (for backward compatibility)
|
|
1969
|
+
if hasattr(tool_instance, "validate_parameters"):
|
|
1970
|
+
return tool_instance.validate_parameters(arguments)
|
|
1971
|
+
else:
|
|
1972
|
+
# Fallback for old-style tools without validate_parameters
|
|
1973
|
+
# Just return None (no validation) to maintain backward compatibility
|
|
1974
|
+
return None
|
|
1975
|
+
|
|
1976
|
+
def _check_basic_type(self, value: Any, expected_type: str) -> bool:
|
|
1977
|
+
"""Check if value matches expected basic type."""
|
|
1978
|
+
type_mapping = {
|
|
1979
|
+
"string": str,
|
|
1980
|
+
"integer": int,
|
|
1981
|
+
"number": (int, float),
|
|
1982
|
+
"boolean": bool,
|
|
1983
|
+
"object": dict,
|
|
1984
|
+
"array": list,
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
if expected_type not in type_mapping:
|
|
1988
|
+
return True # Unknown type, skip validation
|
|
1989
|
+
|
|
1990
|
+
expected_python_type = type_mapping[expected_type]
|
|
1991
|
+
return isinstance(value, expected_python_type)
|
|
1992
|
+
|
|
1993
|
+
def _classify_exception(
|
|
1994
|
+
self, exception: Exception, function_name: str, arguments: dict
|
|
1995
|
+
) -> ToolError:
|
|
1996
|
+
"""Classify exception by delegating to BaseTool."""
|
|
1997
|
+
tool_instance = self._get_tool_instance(function_name, cache=False)
|
|
1998
|
+
|
|
1999
|
+
if tool_instance:
|
|
2000
|
+
return tool_instance.handle_error(exception)
|
|
2001
|
+
|
|
2002
|
+
# Fallback for tool instance creation failure
|
|
2003
|
+
return ToolServerError(f"Unexpected error calling {function_name}: {exception}")
|
|
2004
|
+
|
|
2005
|
+
def _create_dual_format_error(self, error: ToolError) -> dict:
|
|
2006
|
+
"""Create dual-format error response for backward compatibility."""
|
|
2007
|
+
return {
|
|
2008
|
+
"error": str(error), # Backward compatible string
|
|
2009
|
+
"error_details": error.to_dict(), # New structured format
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
def refresh_tools(self):
|
|
2013
|
+
"""Refresh tool discovery (re-discover MCP/remote tools, reload configs)."""
|
|
2014
|
+
# TODO: Implement MCP tool re-discovery
|
|
2015
|
+
# For now, just reload tool configurations
|
|
2016
|
+
self.logger.info("Refreshing tool configurations...")
|
|
2017
|
+
# This could be extended to re-discover MCP tools, reload configs, etc.
|
|
2018
|
+
self.logger.info("Tool refresh completed")
|
|
2019
|
+
|
|
2020
|
+
def eager_load_tools(self, names: Optional[List[str]] = None):
|
|
2021
|
+
"""Pre-instantiate tools to reduce first-call latency."""
|
|
2022
|
+
tool_names = names or list(self.all_tool_dict.keys())
|
|
2023
|
+
self.logger.info(f"Eager loading {len(tool_names)} tools...")
|
|
2024
|
+
|
|
2025
|
+
for tool_name in tool_names:
|
|
2026
|
+
if (
|
|
2027
|
+
tool_name in self.all_tool_dict
|
|
2028
|
+
and tool_name not in self.callable_functions
|
|
2029
|
+
):
|
|
2030
|
+
try:
|
|
2031
|
+
self.init_tool(self.all_tool_dict[tool_name], add_to_cache=True)
|
|
2032
|
+
self.logger.debug(f"Eager loaded: {tool_name}")
|
|
2033
|
+
except Exception as e:
|
|
2034
|
+
self.logger.warning(f"Failed to eager load {tool_name}: {e}")
|
|
2035
|
+
|
|
2036
|
+
self.logger.info(
|
|
2037
|
+
f"Eager loading completed. {len(self.callable_functions)} tools cached."
|
|
2038
|
+
)
|
|
2039
|
+
|
|
2040
|
+
def clear_cache(self):
|
|
2041
|
+
"""Clear the result cache."""
|
|
2042
|
+
self._cache.clear()
|
|
2043
|
+
self.logger.info("Result cache cleared")
|
|
2044
|
+
|
|
2045
|
+
def get_tool_health(self, tool_name: str = None) -> dict:
|
|
2046
|
+
"""Get health status for tool(s)."""
|
|
2047
|
+
tool_errors = get_tool_errors()
|
|
2048
|
+
|
|
2049
|
+
if tool_name:
|
|
2050
|
+
if tool_name in tool_errors:
|
|
2051
|
+
return tool_errors[tool_name]
|
|
2052
|
+
elif tool_name in self.all_tool_dict:
|
|
2053
|
+
return {"available": True}
|
|
2054
|
+
return {"available": False, "error": "Not found"}
|
|
2055
|
+
|
|
2056
|
+
# Summary for all tools
|
|
2057
|
+
return {
|
|
2058
|
+
"total": len(self.all_tool_dict),
|
|
2059
|
+
"available": len(self.all_tool_dict) - len(tool_errors),
|
|
2060
|
+
"unavailable": len(tool_errors),
|
|
2061
|
+
"unavailable_list": list(tool_errors.keys()),
|
|
2062
|
+
"details": tool_errors,
|
|
2063
|
+
}
|
|
1846
2064
|
|
|
1847
2065
|
def check_function_call(self, fcall_str, function_config=None, format="llama"):
|
|
1848
2066
|
"""
|
|
@@ -1925,6 +2143,66 @@ class ToolUniverse:
|
|
|
1925
2143
|
self.logger.error(f"Error exporting tool names to {output_file}: {e}")
|
|
1926
2144
|
return []
|
|
1927
2145
|
|
|
2146
|
+
def filter_tools(
|
|
2147
|
+
self,
|
|
2148
|
+
include_tools=None,
|
|
2149
|
+
exclude_tools=None,
|
|
2150
|
+
include_tool_types=None,
|
|
2151
|
+
exclude_tool_types=None,
|
|
2152
|
+
):
|
|
2153
|
+
"""
|
|
2154
|
+
Filter tools based on inclusion/exclusion criteria.
|
|
2155
|
+
|
|
2156
|
+
Args:
|
|
2157
|
+
include_tools (set, optional): Set of tool names to include
|
|
2158
|
+
exclude_tools (set, optional): Set of tool names to exclude
|
|
2159
|
+
include_tool_types (set, optional): Set of tool types to include
|
|
2160
|
+
exclude_tool_types (set, optional): Set of tool types to exclude
|
|
2161
|
+
|
|
2162
|
+
Returns:
|
|
2163
|
+
list: Filtered list of tool configurations
|
|
2164
|
+
"""
|
|
2165
|
+
if not hasattr(self, "all_tools") or not self.all_tools:
|
|
2166
|
+
self.logger.warning("No tools loaded. Call load_tools() first.")
|
|
2167
|
+
return []
|
|
2168
|
+
|
|
2169
|
+
filtered_tools = []
|
|
2170
|
+
for tool in self.all_tools:
|
|
2171
|
+
tool_name = tool.get("name", "")
|
|
2172
|
+
tool_type = tool.get("type", "")
|
|
2173
|
+
|
|
2174
|
+
# Check inclusion/exclusion criteria
|
|
2175
|
+
if include_tools and tool_name not in include_tools:
|
|
2176
|
+
continue
|
|
2177
|
+
if exclude_tools and tool_name in exclude_tools:
|
|
2178
|
+
continue
|
|
2179
|
+
if include_tool_types and tool_type not in include_tool_types:
|
|
2180
|
+
continue
|
|
2181
|
+
if exclude_tool_types and tool_type in exclude_tool_types:
|
|
2182
|
+
continue
|
|
2183
|
+
|
|
2184
|
+
filtered_tools.append(tool)
|
|
2185
|
+
|
|
2186
|
+
return filtered_tools
|
|
2187
|
+
|
|
2188
|
+
def get_required_parameters(self, tool_name):
|
|
2189
|
+
"""
|
|
2190
|
+
Get required parameters for a specific tool.
|
|
2191
|
+
|
|
2192
|
+
Args:
|
|
2193
|
+
tool_name (str): Name of the tool
|
|
2194
|
+
|
|
2195
|
+
Returns:
|
|
2196
|
+
list: List of required parameter names
|
|
2197
|
+
"""
|
|
2198
|
+
if tool_name not in self.all_tool_dict:
|
|
2199
|
+
self.logger.warning(f"Tool '{tool_name}' not found")
|
|
2200
|
+
return []
|
|
2201
|
+
|
|
2202
|
+
tool_config = self.all_tool_dict[tool_name]
|
|
2203
|
+
parameter_schema = tool_config.get("parameter", {})
|
|
2204
|
+
return parameter_schema.get("required", [])
|
|
2205
|
+
|
|
1928
2206
|
def get_available_tools(self, category_filter=None, name_only=True):
|
|
1929
2207
|
"""
|
|
1930
2208
|
Get available tools, optionally filtered by category.
|
|
@@ -1996,10 +2274,209 @@ class ToolUniverse:
|
|
|
1996
2274
|
)
|
|
1997
2275
|
return matching_tools
|
|
1998
2276
|
|
|
2277
|
+
# ============ DEPRECATED METHODS (Kept for backward compatibility) ============
|
|
2278
|
+
# These methods are deprecated and will be removed in v2.0. Use the recommended
|
|
2279
|
+
# alternatives instead. All methods below maintain backward compatibility but
|
|
2280
|
+
# issue deprecation warnings when called.
|
|
2281
|
+
|
|
2282
|
+
def get_tool_by_name(self, tool_names, format="default"):
|
|
2283
|
+
"""
|
|
2284
|
+
Retrieve tool configurations by their names.
|
|
2285
|
+
|
|
2286
|
+
DEPRECATED: Use tool_specification() instead.
|
|
2287
|
+
|
|
2288
|
+
Args:
|
|
2289
|
+
tool_names (list): List of tool names to retrieve.
|
|
2290
|
+
format (str, optional): Output format. Options: 'default', 'openai'.
|
|
2291
|
+
If 'openai', returns OpenAI function calling format. Defaults to 'default'.
|
|
2292
|
+
|
|
2293
|
+
Returns:
|
|
2294
|
+
list: List of tool configurations for the specified names.
|
|
2295
|
+
Tools not found will be reported but not included in the result.
|
|
2296
|
+
"""
|
|
2297
|
+
warnings.warn(
|
|
2298
|
+
"get_tool_by_name() is deprecated and will be removed in v2.0. "
|
|
2299
|
+
"Use tool_specification() instead.",
|
|
2300
|
+
DeprecationWarning,
|
|
2301
|
+
stacklevel=2,
|
|
2302
|
+
)
|
|
2303
|
+
return self.get_tool_specification_by_names(tool_names, format=format)
|
|
2304
|
+
|
|
2305
|
+
def get_tool_description(self, tool_name):
|
|
2306
|
+
"""
|
|
2307
|
+
Get the description of a tool by its name.
|
|
2308
|
+
|
|
2309
|
+
DEPRECATED: Use tool_specification() instead.
|
|
2310
|
+
|
|
2311
|
+
Args:
|
|
2312
|
+
tool_name (str): Name of the tool.
|
|
2313
|
+
|
|
2314
|
+
Returns:
|
|
2315
|
+
dict or None: Tool configuration if found, None otherwise.
|
|
2316
|
+
"""
|
|
2317
|
+
warnings.warn(
|
|
2318
|
+
"get_tool_description() is deprecated and will be removed in v2.0. "
|
|
2319
|
+
"Use tool_specification() instead.",
|
|
2320
|
+
DeprecationWarning,
|
|
2321
|
+
stacklevel=2,
|
|
2322
|
+
)
|
|
2323
|
+
return self.get_one_tool_by_one_name(tool_name)
|
|
2324
|
+
|
|
2325
|
+
def remove_keys(self, tool_list, invalid_keys):
|
|
2326
|
+
"""
|
|
2327
|
+
Remove specified keys from a list of tool configurations.
|
|
2328
|
+
|
|
2329
|
+
DEPRECATED: Use prepare_tool_prompts(mode='custom', valid_keys=...) instead.
|
|
2330
|
+
|
|
2331
|
+
Args:
|
|
2332
|
+
tool_list (list): List of tool configuration dictionaries.
|
|
2333
|
+
invalid_keys (list): List of keys to remove from each tool configuration.
|
|
2334
|
+
|
|
2335
|
+
Returns:
|
|
2336
|
+
list: Deep copy of tool list with specified keys removed.
|
|
2337
|
+
"""
|
|
2338
|
+
warnings.warn(
|
|
2339
|
+
"remove_keys() is deprecated and will be removed in v2.0. "
|
|
2340
|
+
"Use prepare_tool_prompts(mode='custom', valid_keys=...) instead.",
|
|
2341
|
+
DeprecationWarning,
|
|
2342
|
+
stacklevel=2,
|
|
2343
|
+
)
|
|
2344
|
+
copied_list = copy.deepcopy(tool_list)
|
|
2345
|
+
for tool in copied_list:
|
|
2346
|
+
# Create a list of keys to avoid modifying the dictionary during iteration
|
|
2347
|
+
for key in list(tool.keys()):
|
|
2348
|
+
if key in invalid_keys:
|
|
2349
|
+
del tool[key]
|
|
2350
|
+
return copied_list
|
|
2351
|
+
|
|
2352
|
+
def prepare_tool_examples(self, tool_list):
|
|
2353
|
+
"""
|
|
2354
|
+
Prepare tool configurations for example usage by keeping extended set of keys.
|
|
2355
|
+
|
|
2356
|
+
DEPRECATED: Use prepare_tool_prompts(mode='example') instead.
|
|
2357
|
+
|
|
2358
|
+
Args:
|
|
2359
|
+
tool_list (list): List of tool configuration dictionaries.
|
|
2360
|
+
|
|
2361
|
+
Returns:
|
|
2362
|
+
list: Deep copy of tool list with only example-relevant keys.
|
|
2363
|
+
"""
|
|
2364
|
+
warnings.warn(
|
|
2365
|
+
"prepare_tool_examples() is deprecated and will be removed in v2.0. "
|
|
2366
|
+
"Use prepare_tool_prompts(mode='example') instead.",
|
|
2367
|
+
DeprecationWarning,
|
|
2368
|
+
stacklevel=2,
|
|
2369
|
+
)
|
|
2370
|
+
return self.prepare_tool_prompts(tool_list, mode="example")
|
|
2371
|
+
|
|
2372
|
+
def select_tools(
|
|
2373
|
+
self,
|
|
2374
|
+
include_names=None,
|
|
2375
|
+
exclude_names=None,
|
|
2376
|
+
include_categories=None,
|
|
2377
|
+
exclude_categories=None,
|
|
2378
|
+
):
|
|
2379
|
+
"""
|
|
2380
|
+
Select tools based on tool names and/or categories (tool_files keys).
|
|
2381
|
+
|
|
2382
|
+
DEPRECATED: Use filter_tools() instead.
|
|
2383
|
+
|
|
2384
|
+
Args:
|
|
2385
|
+
include_names (list, optional): List of tool names to include. If None, include all.
|
|
2386
|
+
exclude_names (list, optional): List of tool names to exclude.
|
|
2387
|
+
include_categories (list, optional): List of categories (tool_files keys) to include.
|
|
2388
|
+
If None, include all.
|
|
2389
|
+
exclude_categories (list, optional): List of categories (tool_files keys) to exclude.
|
|
2390
|
+
|
|
2391
|
+
Returns:
|
|
2392
|
+
list: List of selected tool configurations.
|
|
2393
|
+
"""
|
|
2394
|
+
warnings.warn(
|
|
2395
|
+
"select_tools() is deprecated and will be removed in v2.0. "
|
|
2396
|
+
"Use filter_tools() instead.",
|
|
2397
|
+
DeprecationWarning,
|
|
2398
|
+
stacklevel=2,
|
|
2399
|
+
)
|
|
2400
|
+
selected_tools = []
|
|
2401
|
+
# If categories are specified, use self.tool_category_dicts to filter
|
|
2402
|
+
categories = set(self.tool_category_dicts.keys())
|
|
2403
|
+
if include_categories is not None:
|
|
2404
|
+
categories &= set(include_categories)
|
|
2405
|
+
if exclude_categories is not None:
|
|
2406
|
+
categories -= set(exclude_categories)
|
|
2407
|
+
# Gather tools from selected categories
|
|
2408
|
+
for cat in categories:
|
|
2409
|
+
selected_tools.extend(self.tool_category_dicts[cat])
|
|
2410
|
+
# Further filter by names if needed
|
|
2411
|
+
if include_names is not None:
|
|
2412
|
+
selected_tools = [
|
|
2413
|
+
tool for tool in selected_tools if tool["name"] in include_names
|
|
2414
|
+
]
|
|
2415
|
+
if exclude_names is not None:
|
|
2416
|
+
selected_tools = [
|
|
2417
|
+
tool for tool in selected_tools if tool["name"] not in exclude_names
|
|
2418
|
+
]
|
|
2419
|
+
return selected_tools
|
|
2420
|
+
|
|
2421
|
+
def filter_tool_lists(
|
|
2422
|
+
self,
|
|
2423
|
+
tool_name_list,
|
|
2424
|
+
tool_desc_list,
|
|
2425
|
+
include_names=None,
|
|
2426
|
+
exclude_names=None,
|
|
2427
|
+
include_categories=None,
|
|
2428
|
+
exclude_categories=None,
|
|
2429
|
+
):
|
|
2430
|
+
"""
|
|
2431
|
+
Directly filter tool name and description lists based on names and/or categories.
|
|
2432
|
+
|
|
2433
|
+
DEPRECATED: Use filter_tools() and manual list filtering instead.
|
|
2434
|
+
|
|
2435
|
+
Args:
|
|
2436
|
+
tool_name_list (list): List of tool names to filter.
|
|
2437
|
+
tool_desc_list (list): List of tool descriptions to filter (must correspond to tool_name_list).
|
|
2438
|
+
include_names (list, optional): List of tool names to include.
|
|
2439
|
+
exclude_names (list, optional): List of tool names to exclude.
|
|
2440
|
+
include_categories (list, optional): List of categories to include.
|
|
2441
|
+
exclude_categories (list, optional): List of categories to exclude.
|
|
2442
|
+
|
|
2443
|
+
Returns:
|
|
2444
|
+
tuple: A tuple containing (filtered_tool_name_list, filtered_tool_desc_list).
|
|
2445
|
+
"""
|
|
2446
|
+
warnings.warn(
|
|
2447
|
+
"filter_tool_lists() is deprecated and will be removed in v2.0. "
|
|
2448
|
+
"Use filter_tools() and manual list filtering instead.",
|
|
2449
|
+
DeprecationWarning,
|
|
2450
|
+
stacklevel=2,
|
|
2451
|
+
)
|
|
2452
|
+
# Build a set of allowed tool names using select_tools for category filtering
|
|
2453
|
+
allowed_names = set()
|
|
2454
|
+
if any([include_names, exclude_names, include_categories, exclude_categories]):
|
|
2455
|
+
filtered_tools = self.select_tools(
|
|
2456
|
+
include_names=include_names,
|
|
2457
|
+
exclude_names=exclude_names,
|
|
2458
|
+
include_categories=include_categories,
|
|
2459
|
+
exclude_categories=exclude_categories,
|
|
2460
|
+
)
|
|
2461
|
+
allowed_names = set(tool["name"] for tool in filtered_tools)
|
|
2462
|
+
else:
|
|
2463
|
+
allowed_names = set(tool_name_list)
|
|
2464
|
+
|
|
2465
|
+
# Filter lists by allowed_names
|
|
2466
|
+
filtered_tool_name_list = []
|
|
2467
|
+
filtered_tool_desc_list = []
|
|
2468
|
+
for name, desc in zip(tool_name_list, tool_desc_list):
|
|
2469
|
+
if name in allowed_names:
|
|
2470
|
+
filtered_tool_name_list.append(name)
|
|
2471
|
+
filtered_tool_desc_list.append(desc)
|
|
2472
|
+
return filtered_tool_name_list, filtered_tool_desc_list
|
|
2473
|
+
|
|
1999
2474
|
def load_tools_from_names_list(self, tool_names, clear_existing=True):
|
|
2000
2475
|
"""
|
|
2001
2476
|
Load only specific tools by their names.
|
|
2002
2477
|
|
|
2478
|
+
DEPRECATED: Use load_tools(include_tools=...) instead.
|
|
2479
|
+
|
|
2003
2480
|
Args:
|
|
2004
2481
|
tool_names (list): List of tool names to load
|
|
2005
2482
|
clear_existing (bool): Whether to clear existing tools first
|
|
@@ -2007,6 +2484,12 @@ class ToolUniverse:
|
|
|
2007
2484
|
Returns:
|
|
2008
2485
|
int: Number of tools successfully loaded
|
|
2009
2486
|
"""
|
|
2487
|
+
warnings.warn(
|
|
2488
|
+
"load_tools_from_names_list() is deprecated and will be removed in v2.0. "
|
|
2489
|
+
"Use load_tools(include_tools=...) instead.",
|
|
2490
|
+
DeprecationWarning,
|
|
2491
|
+
stacklevel=2,
|
|
2492
|
+
)
|
|
2010
2493
|
if clear_existing:
|
|
2011
2494
|
self.all_tools = []
|
|
2012
2495
|
self.all_tool_dict = {}
|