Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
66fae35
adding some debugging messages for get_biomodels function
reeshapatel12 Mar 1, 2026
619c56c
debugging messages for vcell specific service.py and testing BIOMODEL…
reeshapatel12 Mar 1, 2026
7d78aac
update system prompt for better formatting guidelines and consistency…
reeshapatel12 Mar 1, 2026
00cc3e9
add a test function for connecting BioModels API from frontend chat t…
reeshapatel12 Mar 1, 2026
c1047e4
add debugging messages to see how backend calls/process works
reeshapatel12 Mar 1, 2026
64d1645
update admin settings with the proper links/steps for setting up the …
reeshapatel12 Mar 1, 2026
7b6c039
In BioModel search, add a real biomodelID (270051643) as the default …
reeshapatel12 Mar 1, 2026
f332874
edit BioModels search html setup for results page specific to model
reeshapatel12 Mar 1, 2026
5c71e1c
edit main chat page to add new function button at the bottom of display
reeshapatel12 Mar 1, 2026
2cea464
add new search box for querying BioModels Databa
reeshapatel12 Mar 1, 2026
1c16a64
format the biomodel-specific page for results from BioModels database…
reeshapatel12 Mar 1, 2026
15d48ae
add another section of buttons at the bottom of the main chat page, i…
reeshapatel12 Mar 1, 2026
fd9ab57
rename vcelldb_service to databases_service to generalize for adding …
reeshapatel12 Mar 5, 2026
6dfef94
update to add bmdb-specifc tools for connecting llm to bmdb
reeshapatel12 Mar 5, 2026
69670d9
update with paths to connect bmdb to backend llm response functions
reeshapatel12 Mar 5, 2026
05ba323
Pass string instead of a bool for the database key, currently either …
reeshapatel12 Mar 5, 2026
7971cd3
add links to bmdb formatted response: one to the original database an…
reeshapatel12 Mar 5, 2026
7b136fd
add ai analysis tab to biomodel specific page for bmdb models
reeshapatel12 Mar 9, 2026
ed9903e
add new tool to handle getting results from xml files for bmdb specif…
reeshapatel12 Mar 9, 2026
a301b40
edit system prompt to make it less vcell specific
reeshapatel12 Mar 9, 2026
1a12e95
add radio swtich buttons for each database instead of two search boxe…
reeshapatel12 Mar 9, 2026
e9b6750
remove extra buttons on bottom of chat page
reeshapatel12 Mar 11, 2026
be96691
edit system prompt to fix formatting for both database responses
reeshapatel12 Mar 11, 2026
fffa419
connect all buttons to the chatbox
reeshapatel12 Mar 11, 2026
177e60b
change the quickaction buttons and add switch for vcell specific and …
reeshapatel12 Mar 11, 2026
c3e6f5a
add an option to query multiple databases at once and render the results
reeshapatel12 Mar 11, 2026
17465bf
update loading history in sidebar to only load once per chat and upda…
reeshapatel12 Mar 23, 2026
a800a98
wrap SearchParams in Suspense to build with docker without error
reeshapatel12 Mar 24, 2026
49bbfb5
updated config settings
reeshapatel12 Mar 24, 2026
d88b73d
push updated docker_compose settings
reeshapatel12 Mar 24, 2026
6f047da
try separating into two format guideline sections for each database
reeshapatel12 Mar 24, 2026
d6871d1
force consistent formatting in system prompt
reeshapatel12 Mar 24, 2026
8296613
introduce various changes to try and speed up llm response time
reeshapatel12 Mar 24, 2026
d994109
update summarize tool function and add clearer timing logs
reeshapatel12 Mar 25, 2026
9da8524
add comments for each new implementation of a suggestion for speeding…
reeshapatel12 Mar 26, 2026
2b8032e
implement several suggestions for improving llm response time: separa…
reeshapatel12 Mar 26, 2026
6e41b2b
remove some link formatting from system_prompt and add rules for long…
reeshapatel12 Mar 28, 2026
5a965ff
remove specific link formatting
reeshapatel12 Mar 28, 2026
4c9ac12
define a function to format a link to the database for each biomodel …
reeshapatel12 Mar 28, 2026
0b90dc3
change the summarize tool function to only shorten results without ch…
reeshapatel12 Mar 28, 2026
372202b
when querying two databases, keep the "AI is thinking" box until both…
reeshapatel12 Mar 28, 2026
96ee74d
editing system prompt to fix link formatting for biomodel names.
reeshapatel12 Mar 29, 2026
734af8f
add a tool summary to output to show how long the query/all tools too…
reeshapatel12 Apr 2, 2026
3001e0d
update /search/page.tsx to allow for both databases to be selected an…
reeshapatel12 Apr 6, 2026
113b3ce
change all references (in all files) for Biomodels Database to be BM…
reeshapatel12 Apr 6, 2026
7a09ecf
update BMDB processing to include biomodels that start with both MODE…
reeshapatel12 Apr 6, 2026
26f1b1c
change all references to biomodels database to be BMDB for consistency
reeshapatel12 Apr 8, 2026
126b73d
move biomodels endpoint to its own router file
reeshapatel12 Apr 8, 2026
74d3f8a
create a new section on /local/docs page for all BMDB endpoints
reeshapatel12 Apr 8, 2026
986915b
fix quickAction logic so that it shows the queries from the buttons o…
reeshapatel12 Apr 8, 2026
a477884
create BMDB router and controller files for those specific endpoints/…
reeshapatel12 Apr 8, 2026
6172777
Separate BMDB and VCDB routes and controllers; moved LLM BMDB query t…
vcellmike Apr 8, 2026
460c472
update quickAction handling so it only appears once in the chat screen
reeshapatel12 Apr 9, 2026
89a78ab
change all references to public_next_url2 to be a bmdb specific name
reeshapatel12 Apr 9, 2026
9318e99
update the handle search function name to be bmdb specific
reeshapatel12 Apr 9, 2026
c61d47f
in /search change text of visible prompt ask about vcell model/ask ab…
reeshapatel12 Apr 12, 2026
937e5ee
create more endpoints for BMDB API calls, including for getting xml f…
reeshapatel12 Apr 12, 2026
517dbf9
log the number of rows fetched for list of biomodels in the frontend …
reeshapatel12 Apr 17, 2026
5db77db
split system prompt into three separate prompts and improve each indi…
reeshapatel12 Apr 18, 2026
3a2ab97
add to system prompt that all model elements that have links leading …
reeshapatel12 Apr 18, 2026
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
54 changes: 54 additions & 0 deletions backend/app/controllers/bmdb_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import httpx
from typing import List
from fastapi import HTTPException, Response
from app.schemas.bmdb_schema import BMDBRequestParams
from app.services.databases_service import (
get_xml_file,
fetch_bmdb_models,
get_bmdb_model_info,
)


async def get_bmdb_models_controller(params: BMDBRequestParams) -> dict:
"""
Controller function to retrieve biomodels based on filters and sorting.
Raises:
HTTPException: If the BMDB API request fails.
"""
try:
biomodels = await fetch_bmdb_models(params)
return biomodels
except httpx.HTTPStatusError as e:
raise HTTPException(
status_code=e.response.status_code, detail="Error fetching biomodels."
)
except httpx.RequestError as e:
raise HTTPException(
status_code=500, detail="Error communicating with BMDB API."
)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))


async def get_xml_controller(bmdbID: str, truncate: bool = False) -> str:
"""
Controller function to fetch the contents of the XML file for a bmdb biomodel.
Raises:
HTTPException: If the URL cannot be generated.
"""
try:
return await get_xml_file(bmdbID, truncate)
except Exception as e:
raise HTTPException(status_code=500, detail="Error fetching XML file.")


async def get_bmdb_model_info_controller(bmdbID: str) -> dict:
"""
Controller function to fetch information about a specific BMDB model.
Raises:
HTTPException: If the URL cannot be generated.
"""
try:
return await get_bmdb_model_info(bmdbID)
except Exception as e:
raise HTTPException(status_code=500, detail="Error fetching BMDB model info.")
7 changes: 4 additions & 3 deletions backend/app/controllers/llms_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)


async def get_llm_response(conversation_history: list[dict]) -> tuple[str, list]:
async def get_llm_response(conversation_history: list[dict], database: str) -> tuple[str, list]:
"""
Controller function to interact with the LLM service.
Args:
Expand All @@ -16,8 +16,9 @@ async def get_llm_response(conversation_history: list[dict]) -> tuple[str, list]
tuple[str, list]: A tuple containing the final response and bmkeys list.
"""
try:
result, bmkeys = await get_response_with_tools(conversation_history)
return result, bmkeys
print("DEBUG20: BMDB POST: get_llm_response")
result, bmkeys, tool_summary = await get_response_with_tools(conversation_history, database)
return result, bmkeys, tool_summary
except Exception as e:
raise HTTPException(status_code=500, detail=f"Error: {str(e)}")

Expand Down
6 changes: 5 additions & 1 deletion backend/app/controllers/vcelldb_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List
from fastapi import HTTPException, Response
from app.schemas.vcelldb_schema import BiomodelRequestParams, SimulationRequestParams
from app.services.vcelldb_service import (
from app.services.databases_service import (
fetch_biomodels,
fetch_simulation_details,
get_vcml_file,
Expand All @@ -21,7 +21,9 @@ async def get_biomodels_controller(params: BiomodelRequestParams) -> dict:
HTTPException: If the VCell API request fails.
"""
try:
print("About to call fetch_biomodels()")
biomodels = await fetch_biomodels(params)
print("fetch_biomodels() completed successfully")
return biomodels
except httpx.HTTPStatusError as e:
raise HTTPException(
Expand Down Expand Up @@ -142,7 +144,9 @@ async def get_publications_controller() -> List[dict]:
HTTPException: If the VCell API request fails.
"""
try:
print("About to call fetch_publications()")
publications = await fetch_publications()
print("fetch_publications() completed successfully")
return publications
except httpx.HTTPStatusError as e:
raise HTTPException(
Expand Down
8 changes: 7 additions & 1 deletion backend/app/core/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic_settings import BaseSettings
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
Expand All @@ -24,4 +24,10 @@ class Settings(BaseSettings):
LANGFUSE_PUBLIC_KEY: str
LANGFUSE_HOST: str

model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
)

settings = Settings()
2 changes: 2 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from app.routes.llms_router import router as llms_router
from app.routes.qdrant_router import router as qdrant_router
from app.routes.knowledge_base_router import router as knowledge_base_router
from app.routes.bmdb_router import router as bmdb_router

ascii_art = """
╔════════════════════════════════════════════════════════════════════════════════════╗
Expand Down Expand Up @@ -54,6 +55,7 @@ async def startup_event():
# Including the routers
app.include_router(knowledge_base_router, tags=["Knowledge Base"], prefix="/kb")
app.include_router(llms_router, tags=["LLM with Tool Calling"])
app.include_router(bmdb_router, tags=["BMDB API Wrapper"])
app.include_router(vcelldb_router, tags=["VCellDB API Wrapper"])
app.include_router(qdrant_router, tags=["Qdrant Vector DB"], prefix="/qdrant")

Expand Down
42 changes: 42 additions & 0 deletions backend/app/routes/bmdb_router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from fastapi import APIRouter, Depends, HTTPException
from app.schemas.bmdb_schema import BMDBRequestParams
from app.controllers.bmdb_controller import (
get_bmdb_models_controller,
get_xml_controller,
get_bmdb_model_info_controller,
)

router = APIRouter()


@router.get("/search", response_model=dict)
async def get_biomodels(params: BMDBRequestParams = Depends()):
"""
Endpoint to retrieve bmdb models based on provided parameters.
"""
try:
return await get_bmdb_models_controller(params)
except HTTPException as e:
raise e


@router.get("/get-xml", response_model=str)
async def get_xml(bmdbID: str, truncate: bool = False):
"""
Endpoint to get XML file contents for a given biomodel.
"""
try:
return await get_xml_controller(bmdbID, truncate)
except HTTPException as e:
raise e


@router.get("/model-info", response_model=dict)
async def get_model_info(bmdbID: str):
"""
Endpoint to get information about a specific BMDB model.
"""
try:
return await get_bmdb_model_info_controller(bmdbID)
except HTTPException as e:
raise e
34 changes: 30 additions & 4 deletions backend/app/routes/llms_router.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from fastapi import APIRouter
from multiprocessing import process
from fastapi import APIRouter, Depends, HTTPException, Response
from typing import List
from app.schemas.bmdb_schema import BMDBRequestParams
from app.schemas.vcelldb_schema import BiomodelRequestParams
import httpx
import requests
from app.controllers.llms_controller import (
get_llm_response,
analyse_biomodel_controller,
Expand All @@ -8,20 +14,40 @@

router = APIRouter()

# For BioModelsDB search using BioModelsDB API
@router.post("/bmdb-search")
async def search_llm(conversation_history: dict):
"""
Endpoint to query the LLM and execute the necessary tools.
Args:
conversation_history (dict): The conversation history containing user prompts and responses.
database (str): The database to query - bmdb in this case.
Returns:
dict: The final response after processing the prompt with the tools.
"""

print("DEBUG20: BMDB POST: ROUTER")
result, bmdbkeys, tool_summary = await get_llm_response(
conversation_history.get("conversation_history", []), database="bmdb"
)
return {"response": result, "bmkeys": bmdbkeys, "tool_summary": tool_summary}



@router.post("/query")
async def query_llm(conversation_history: dict):
"""
Endpoint to query the LLM and execute the necessary tools.
Args:
conversation_history (dict): The conversation history containing user prompts and responses.
database (str): The database to query - vcdb in this case.
Returns:
dict: The final response after processing the prompt with the tools.
"""
result, bmkeys = await get_llm_response(
conversation_history.get("conversation_history", [])
result, bmkeys, tool_summary = await get_llm_response(
conversation_history.get("conversation_history", []), database="vcdb"
)
return {"response": result, "bmkeys": bmkeys}
return {"response": result, "bmkeys": bmkeys, "tool_summary": tool_summary}


@router.post("/analyse/{biomodel_id}")
Expand Down
25 changes: 25 additions & 0 deletions backend/app/schemas/bmdb_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pydantic import BaseModel
from typing import Optional
from datetime import date
from enum import Enum


class CategoryEnum(str, Enum):
all = "all"
public = "public"
shared = "shared"
tutorials = "tutorial"
educational = "educational"


class OrderByEnum(str, Enum):
date_desc = "date_desc"
date_asc = "date_asc"
name_desc = "name_desc"
name_asc = "name_asc"


# Biomodel Request Parameters schema
class BMDBRequestParams(BaseModel, use_enum_values=True):
bmName: Optional[str] = "" # Name of the biomodel to search for
bmId: Optional[str] = "" # Biomodel ID
1 change: 0 additions & 1 deletion backend/app/schemas/vcelldb_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class BiomodelRequestParams(BaseModel, use_enum_values=True):
OrderByEnum.date_desc
) # Order of results (default is "date_desc")


class SimulationRequestParams(BaseModel):
bmId: str # Biomodel ID for which simulations will be fetched
simId: str # Simulation ID to fetch specific simulation details
Loading
Loading