Skip to content

Commit

Permalink
add utils
Browse files Browse the repository at this point in the history
  • Loading branch information
doncamilom committed Nov 9, 2023
1 parent dcbfa4c commit 29d5a72
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
12 changes: 2 additions & 10 deletions chemcrow/frontend/streamlit_callback_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
StreamlitCallbackHandler,
LLMThought,
)

from chemcrow.agents.prompts import FORMAT_INSTRUCTIONS, SUFFIX, QUESTION_PROMPT

from typing import TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Union

from langchain.callbacks.streamlit.mutable_expander import MutableExpander
from langchain.schema import AgentAction, AgentFinish, LLMResult

from typing import Any, Dict, List, Optional
from streamlit.delta_generator import DeltaGenerator

import ast
from .utils import cdk, is_valid_smiles
from .utils import cdk


class LLMThoughtChem(LLMThought):
Expand Down
25 changes: 25 additions & 0 deletions chemcrow/frontend/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import requests
from rdkit import Chem
from langchain import LLMChain, PromptTemplate
from langchain.chat_models import ChatOpenAI

def cdk(smiles):
"""
Get a depiction of some smiles.
"""

url = "https://www.simolecule.com/cdkdepict/depict/wob/svg"
headers = {'Content-Type': 'application/json'}
response = requests.get(
url,
headers=headers,
params={
"smi": smiles,
"annotate": "colmap",
"zoom": 2,
"w": 150,
"h": 80,
"abbr": "off",
}
)
return response.text

0 comments on commit 29d5a72

Please sign in to comment.