Skip to content

Remove any trace of resolving #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Tool selection remains when switching between pages.
- Propagate temperature to the api call and set the seed.

### Removed
- Brain region and mtype resolving.

## [v0.6.4] - 02.07.2025

### Added
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ docker compose up
docker exec -it neuroagent-minio-1 mc alias set myminio http://minio:9000 minioadmin minioadmin && docker exec -it neuroagent-minio-1 mc mb myminio/neuroagent
```

To enable the brain region resolving tool, retrieve your bearer token and make sure to run the following script:
```bash
python backend/src/neuroagent/scripts/embed_hierarchies.py $token -e https://staging.openbraininstitute.org/api/entitycore/ -u http://localhost:9000 -b neuroagent -a minioadmin -s minioadmin
```
which stores a json file in your minio/s3 instance.

4. Access the application at `http://localhost:3000`

Notes:
Expand Down
6 changes: 0 additions & 6 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ You'll need to create the `neuroagent` bucket. You can either:
docker exec <container_id> mc mb /data/neuroagent
```

You can compute and push the brain region hierarchy embedding to minio:
```bash
python src/neuroagent/scripts/embed_hierarchies.py $token -e https://staging.openbraininstitute.org/api/entitycore/ -u http://localhost:9000 -b neuroagent -a minioadmin -s minioadmin
```
You need to insert your bearer token corresponding to the environment defined in the `-e` arg.

4. (Optional) Set up Redis for rate limiting:
```bash
docker run -d -p 6379:6379 redis
Expand Down
1 change: 0 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies = [
"pyyaml",
"redis",
"semantic-router",
"scikit-learn",
"sqlalchemy[asyncio]",
"tavily-python",
"types-PyYAML",
Expand Down
20 changes: 0 additions & 20 deletions backend/src/neuroagent/app/app_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import json
import logging
import re
import uuid
from pathlib import Path
from typing import Any, Literal, Sequence
Expand Down Expand Up @@ -34,7 +33,6 @@
ToolCallPartVercel,
ToolCallVercel,
)
from neuroagent.schemas import EmbeddedBrainRegions
from neuroagent.tools.base_tool import BaseTool

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -226,24 +224,6 @@ async def commit_messages(
await session.close()


def get_br_embeddings(
s3_client: Any, bucket_name: str, folder: str
) -> list[EmbeddedBrainRegions]:
"""Retrieve brain regions embeddings from s3."""
file_list = s3_client.list_objects_v2(Bucket=bucket_name, Prefix=folder)
pattern = re.compile(rf"^{folder}/.*_hierarchy_embeddings.json$")
output: list[EmbeddedBrainRegions] = []

if "Contents" in file_list:
for obj in file_list["Contents"]:
key = obj["Key"]
if pattern.match(key):
file_obj = s3_client.get_object(Bucket=bucket_name, Key=key)
content = json.loads(file_obj["Body"].read().decode("utf-8"))
output.append(EmbeddedBrainRegions(**content))
return output


def format_messages_output(
db_messages: Sequence[Messages],
tool_hil_mapping: dict[str, bool],
Expand Down
6 changes: 0 additions & 6 deletions backend/src/neuroagent/app/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@
PlotMorphologyGetOneTool,
ReconstructionMorphologyGetAllTool,
ReconstructionMorphologyGetOneTool,
ResolveBrainRegionTool,
ResolveMtypeTool,
SCSGetAllTool,
SCSGetOneTool,
SCSPlotTool,
Expand Down Expand Up @@ -354,8 +352,6 @@ def get_tool_list(
LiteratureSearchTool,
ReconstructionMorphologyGetAllTool,
ReconstructionMorphologyGetOneTool,
ResolveBrainRegionTool,
ResolveMtypeTool,
MorphometricsGetOneTool,
EphysMetricsGetOneTool,
OrganizationGetAllTool,
Expand Down Expand Up @@ -578,7 +574,6 @@ def get_s3_client(


def get_context_variables(
request: Request,
settings: Annotated[Settings, Depends(get_settings)],
httpx_client: Annotated[AsyncClient, Depends(get_httpx_client)],
thread: Annotated[Threads, Depends(get_thread)],
Expand All @@ -589,7 +584,6 @@ def get_context_variables(
"""Get the context variables to feed the tool's metadata."""
return {
"bluenaas_url": settings.tools.bluenaas.url,
"brainregion_embeddings": request.app.state.br_embeddings,
"bucket_name": settings.storage.bucket_name,
"entitycore_url": settings.tools.entitycore.url,
"httpx_client": httpx_client,
Expand Down
10 changes: 0 additions & 10 deletions backend/src/neuroagent/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@

from neuroagent import __version__
from neuroagent.app.app_utils import (
get_br_embeddings,
get_semantic_router,
setup_engine,
)
from neuroagent.app.config import Settings
from neuroagent.app.dependencies import (
get_connection_string,
get_mcp_tool_list,
get_s3_client,
get_settings,
get_tool_list,
)
Expand Down Expand Up @@ -121,14 +119,6 @@ async def lifespan(fastapi_app: FastAPI) -> AsyncContextManager[None]: # type:
semantic_router = get_semantic_router(settings=app_settings)
fastapi_app.state.semantic_router = semantic_router

s3_client = get_s3_client(app_settings)
br_embeddings = get_br_embeddings(
s3_client=s3_client,
bucket_name=app_settings.storage.bucket_name,
folder="shared",
)
fastapi_app.state.br_embeddings = br_embeddings

async with aclosing(
AsyncAccountingSessionFactory(
base_url=app_settings.accounting.base_url,
Expand Down
16 changes: 0 additions & 16 deletions backend/src/neuroagent/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,3 @@ class JSONMultiLinechart(BaseObject):
default="solid", description="Line style (e.g., 'solid', 'dashed', 'dotted')"
)
line_color: str | None = Field(None, description="Hex color code for the line")


class EmbeddedBrainRegion(BaseModel):
"""Brain region schema."""

id: str
name: str
hierarchy_level: int
name_embedding: list[float] | None = None


class EmbeddedBrainRegions(BaseModel):
"""Schema for dumping."""

regions: list[EmbeddedBrainRegion]
hierarchy_id: str
187 changes: 0 additions & 187 deletions backend/src/neuroagent/scripts/embed_hierarchies.py

This file was deleted.

Loading