mirror of
https://github.com/InternLM/InternBootcamp.git
synced 2026-04-19 12:58:04 +00:00
- Rename puzzle configuration files for consistency (e.g., InChI2logP_test.json) - Standardize class names to PascalCase (e.g., InChI2MRBootCamp -> InChI2MRbootCamp) - Improve code structure in various bootcamp modules for better readability and maintainability - Update import statements and file references to reflect new naming conventions - Enhance setup.py to include rdkit dependency
32 lines
No EOL
1.3 KiB
Python
Executable file
32 lines
No EOL
1.3 KiB
Python
Executable file
from internbootcamp.bootcamp.base import Basebootcamp
|
|
from internbootcamp.libs.chemStructure2Property.ChemStructureGenerator import SMILESGenerator
|
|
from .utils import last_boxed_only_string, remove_boxed
|
|
from rdkit import Chem
|
|
from rdkit.Chem import Crippen
|
|
|
|
from .SMILES2logPBootCamp import SMILES2logPbootcamp
|
|
|
|
class SMILES2MRbootCamp(SMILES2logPbootcamp):
|
|
|
|
def prompt_func(self, SMILES) -> str:
|
|
|
|
instruction = f"Given the SMILES, determine the Molar Refractivity (MR) value of the material. The SMILES is: {SMILES}"
|
|
instruction_following = """Let's think step by step and output the final answer within \\boxed{}.The final answer should be one float number. For example "Final Answer: \\boxed{afloat}"."""
|
|
|
|
prompt = instruction + '\n' + instruction_following
|
|
return prompt
|
|
|
|
|
|
@classmethod
|
|
def _verify_correction(cls, solution, SMILES)->bool:
|
|
"""
|
|
Verify the correction of the solution.
|
|
"""
|
|
mol = Chem.MolFromSmiles(SMILES)
|
|
true_MR = Crippen.MolMR(mol)
|
|
solution_float = float(solution)
|
|
if true_MR == 0:
|
|
return abs(solution_float) <= 0.01 # Just check if solution is close to 0
|
|
else:
|
|
return abs(true_MR - solution_float)/abs(true_MR) <= 0.01
|
|
|