Skip to content

add docking score calculation in chemist agent - #176

Merged
SoloWayG merged 6 commits into
mainfrom
feature-175
Mar 5, 2026
Merged

add docking score calculation in chemist agent#176
SoloWayG merged 6 commits into
mainfrom
feature-175

Conversation

@RodionGolovinsky

Copy link
Copy Markdown
Collaborator

ChemOCR tools were transferred to Chemist agent and docking score tool was added

@RodionGolovinsky RodionGolovinsky self-assigned this Jan 13, 2026
Comment thread ChemCoScientist/chemical_utils/chemical_functions.py
Comment thread ChemCoScientist/chemical_utils/chemical_functions.py Outdated
Comment thread ChemCoScientist/chemical_utils/ocr_pipeline.py Outdated
Comment thread ChemCoScientist/frontend/chat.py Outdated
Comment thread ChemCoScientist/frontend/chat.py
Comment thread ChemCoScientist/frontend/chat.py
Comment thread ChemCoScientist/tools/chemist_tools.py Outdated
Comment thread ChemCoScientist/tools/chemist_tools.py Outdated
Comment thread ChemCoScientist/tools/chemist_tools.py Outdated
Comment thread ChemCoScientist/chemical_utils/chemical_functions.py Outdated
@SoloWayG SoloWayG self-assigned this Feb 26, 2026
@SoloWayG
SoloWayG self-requested a review February 26, 2026 07:18
import logging
from pathlib import Path
import os
from ChemCoScientist.chemical_utils.ocr_pipeline import *

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно ли перенести все утилиты, которые импортируются из ChemCoSci в папку с MCP, чтобы можно было создать изолированное окружение только для этого сервера.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

предлагаешь пока что скопировать все в папку с mcp?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все что требуется для самостоятельного запуска MCP сервера да. Будем пока так пробовать

Comment thread ChemCoScientist/mcp/chemical_server.py Outdated


@mcp.tool()
def python_repl_tool(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это тул для написания кода просто? Если это просто про возможность агентом писать код и через этот тул его вызывать - то можно упразднить здесь данный тулл, так как будет отдельный тулл для кодогенерации. А здесь он просто лишний контекст жрет и путаницу наводит.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалил

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Общее замечание. Сформировать MCP сервера в отдельные директории и с отдельными pyproject.toml файлами и зависимостями. И отдебажить чтобы ставилось отдельное окружение через uv.

Вот пример из AutoMas как нужно организовать директории с MCP:

Adding a new MCP server

  1. Create a directory under mcp-servers/:
mcp-servers/my-server/
  pyproject.toml
  src/
    my_server/
      server.py
  1. In pyproject.toml, add the standard project metadata and a [tool.fedotmas.mcp] section:
[project]
name = "my-mcp-server"
version = "0.1.0"
dependencies = ["fastmcp>=2.14.5"]

[project.scripts]
my-mcp-server = "my_server.server:main"

[tool.fedotmas.mcp]
name = "my-server"
description = "Short description of what the server does — the meta-agent reads this to decide when to use it."
tags = ["relevant", "tags"]

После этого, можно будет написать DockerFile для этого всего.

Comment thread ChemCoScientist/mcp/chemical_server.py Outdated

Args:
smiles (str): The SMILES string representing the molecule to visualize.
config (RunnableConfig): Configuration object containing necessary settings,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config нигде дальше не используется, там грузится стейт и он тоже не используется. Значит можно это удалить.

Более того, RunnableConfig для агента, когда он сделает запрос к MCP серверу, вернется просто как аргумент, без пояснения что это какой-то нужный формат конфига. Так что это нужно просто убрать, так как с точки зрения MCP сервера не дает информации.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошо, убрал

Comment thread ChemCoScientist/mcp/chemical_server.py Outdated
state = config["configurable"].get("state")
# tool_call_id: Annotated[str, InjectedToolCallId] = state['messages'][-1]["tool_calls"][0]['id']

path_to_results = os.path.join(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут же путь сохраняется через переменную окружения.

Сделай пока на прямую агрумент с передачей пути сохранения изображения строкой, проверку на успешность сохранения, и при успешности сохранения - функция будет возвращать этот же путь, куда сохранена картинка.

В дальнейшем будем переводить все на S3.

PS Получается импорты langchain больше не нужны.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрал переменные окружения, когда переносил не было понимания, что это будет отдельный контейнер

Returns:
response (dict): Dictionary containing docking score for the molecule and the HTML file.
"""
response = calculate_docking_score(smiles, pdb_id)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Расчет докинг скора в итоге в отдельном контейнере? И оно еще не работает?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, в отдельном, запущено на каком-то из серваков

return data
except asyncio.CancelledError:
raise
except Exception:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логируется ли это?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отдельный вопрос как ты это тестировал, тестировал ли через ClientMCP - https://gofastmcp.com/development/tests#clear-intent

Вот простейший пример как я лично тетсирую свой сервак на предмет его работоспособности и что он возвращает.

import asyncio
from fastmcp import Client, FastMCP

# In-memory server (ideal for testing)
server = FastMCP("TestServer")
client = Client(server)



# Local Python script
client = Client("http://10.32.2.2:8883/mcp")

async def main():
    async with client:
        # Basic server interaction
        await client.ping()

        # List available operations
        tools = await client.list_tools()
        resources = await client.list_resources()
        prompts = await client.list_prompts()
        print(tools,resources,prompts)
        # Execute operations
        result = await client.call_tool("generate_alzheimer_mols", {"num":2})
        print(result)

asyncio.run(main())

Comment thread ChemCoScientist/mcp/chemical_server.py Outdated
standardized affinity type filtering.

Args:
source (str): Name of data source ("bindingdb" or "chembl").

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нужен ли здесь путь?

or a "couldn't obtain smiles" message if the name is invalid.
"""
max_attempts = 3
for attempts in range(max_attempts):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужны ли здесь попытки вообще? Если смайлс не конвертится - то он и за 3 попытки не сконвертится?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

есть шанс, что пабкем лагает, поэтому было добавлено, но писалось не мной изначально

@RodionGolovinsky

Copy link
Copy Markdown
Collaborator Author

@SoloWayG учел все правки, осталось только составить Dockerfile, решить вопрос по поводу того, копировать ли все utils из ChemCoScientist, а еще после заполню pyproject.toml

@SoloWayG
SoloWayG merged commit 1a69d08 into main Mar 5, 2026
0 of 2 checks passed
@RodionGolovinsky
RodionGolovinsky deleted the feature-175 branch March 18, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants