Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +10 -3
src/streamlit_app.py
CHANGED
|
@@ -501,8 +501,9 @@ Plain text only — no code fences. Markdown link syntax (`[text](url)`) is allo
|
|
| 501 |
|
| 502 |
def gpt_fix_smiles(bad_smiles, client):
|
| 503 |
prompt = f"""
|
| 504 |
-
The following is an invalid or broken SMILES or SMARTS string: '{bad_smiles}'
|
| 505 |
-
|
|
|
|
| 506 |
"""
|
| 507 |
rsp = client.chat.completions.create(
|
| 508 |
model="gpt-4o",
|
|
@@ -512,7 +513,13 @@ Please correct it if possible. Only return a valid SMILES/SMARTS string, or say
|
|
| 512 |
n=1,
|
| 513 |
)
|
| 514 |
answer = rsp.choices[0].message.content.strip()
|
| 515 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 516 |
|
| 517 |
|
| 518 |
|
|
|
|
| 501 |
|
| 502 |
def gpt_fix_smiles(bad_smiles, client):
|
| 503 |
prompt = f"""
|
| 504 |
+
You are an expert chemist. The following is an invalid or broken SMILES or SMARTS string: '{bad_smiles}'
|
| 505 |
+
If possible, output a valid SMILES/SMARTS string (no commentary, no explanation, only the string).
|
| 506 |
+
If impossible, just return 'INVALID'.
|
| 507 |
"""
|
| 508 |
rsp = client.chat.completions.create(
|
| 509 |
model="gpt-4o",
|
|
|
|
| 513 |
n=1,
|
| 514 |
)
|
| 515 |
answer = rsp.choices[0].message.content.strip()
|
| 516 |
+
answer = answer.replace("Output:", "").replace("output:", "").replace('"', "").replace("'", "").strip()
|
| 517 |
+
# 只取第一行
|
| 518 |
+
answer = answer.splitlines()[0]
|
| 519 |
+
# 忽略各种 INVALID 拼写和标点
|
| 520 |
+
if answer.upper().startswith("INVALID"):
|
| 521 |
+
return None
|
| 522 |
+
return answer
|
| 523 |
|
| 524 |
|
| 525 |
|