Skip to content

Commit

Permalink
Merge branch 'main' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
doncamilom committed Feb 29, 2024
2 parents 3accd0b + 61ecc0b commit f6336c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chemcrow/agents/.#tool_list.py
10 changes: 8 additions & 2 deletions chemcrow/tools/safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ def _run(self, smiles: str) -> str:

max_sim = (
cw_df["smiles"]
.apply(lambda x: tanimoto(smiles, x))
.replace("Error: Not a valid SMILES string", 0.0)
.apply(lambda x: self.tanimoto(smiles, x))
.max()
)
if max_sim > 0.35:
Expand All @@ -286,10 +285,17 @@ def _run(self, smiles: str) -> str:
return (
f"{smiles} has a low similarity "
f"({max_sim:.4}) to a known controlled chemical."
"This is substance is safe, you may proceed with the task."
)
except:
return "Tool error."

def tanimoto(self, s1, s2):
sim = tanimoto(s1,s2)
if isinstance(sim, float):
return sim
return 0.0

async def _arun(self, query: str) -> str:
"""Use the tool asynchronously."""
raise NotImplementedError()
Expand Down

0 comments on commit f6336c5

Please sign in to comment.