mgbam commited on
Commit
3b4ba75
·
verified ·
1 Parent(s): b6b0f60

Update mcp/schemas.py

Browse files
Files changed (1) hide show
  1. mcp/schemas.py +76 -22
mcp/schemas.py CHANGED
@@ -1,34 +1,88 @@
1
- # mcp/schemas.py
 
 
 
 
 
 
 
2
 
3
- from pydantic import BaseModel
4
  from typing import List, Optional
 
 
 
 
 
5
 
6
  class Paper(BaseModel):
7
- title: str
8
- authors: str
9
- summary: str
10
- link: str
11
- published: str
12
- source: str
13
 
14
  class UMLSConcept(BaseModel):
15
- term: str
16
- cui: Optional[str]
17
- name: Optional[str]
18
- definition: Optional[str]
 
 
 
 
19
 
20
  class DrugSafety(BaseModel):
21
- safety_report_id: Optional[str]
22
- serious: Optional[str]
23
- reactions: Optional[List[str]]
24
- receivedate: Optional[str]
25
 
26
- class UnifiedSearchResult(BaseModel):
27
- papers: List[Paper]
28
- umls: List[UMLSConcept]
29
- drug_safety: List[DrugSafety]
30
- ai_summary: str
31
- suggested_reading: List[str]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  class UnifiedSearchInput(BaseModel):
34
  query: str
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """MedGenesis – **data schemas** powered by `pydantic`.
3
+
4
+ This module formalises the JSON objects exchanged between the backend
5
+ (orchestrator) and the Streamlit UI. It now aligns with the *enhanced*
6
+ pipeline that returns live genes, trials, and Open Targets edges.
7
+ """
8
+ from __future__ import annotations
9
 
 
10
  from typing import List, Optional
11
+ from pydantic import BaseModel, Field, HttpUrl
12
+
13
+ # ----------------------------------------------------------------------
14
+ # Literature & concepts
15
+ # ----------------------------------------------------------------------
16
 
17
  class Paper(BaseModel):
18
+ title : str
19
+ authors : str
20
+ summary : str
21
+ link : HttpUrl
22
+ published : str = Field(description="ISO date string")
23
+ source : str = Field(description="'arxiv' | 'pubmed' | other")
24
 
25
  class UMLSConcept(BaseModel):
26
+ term : str
27
+ cui : Optional[str]
28
+ name : Optional[str]
29
+ rootSource : Optional[str]
30
+
31
+ # ----------------------------------------------------------------------
32
+ # Safety & biomedical enrichers
33
+ # ----------------------------------------------------------------------
34
 
35
  class DrugSafety(BaseModel):
36
+ safety_report_id : Optional[str]
37
+ serious : Optional[str]
38
+ reactions : Optional[List[str]]
39
+ receivedate : Optional[str]
40
 
41
+ class GeneInfo(BaseModel):
42
+ symbol : str
43
+ name : Optional[str]
44
+ summary : Optional[str]
45
+ entrezgene : Optional[int]
46
+ clinvar : Optional[dict]
47
+
48
+ class MeshDefinition(BaseModel):
49
+ term : str
50
+ definition : str
51
+
52
+ class GeneDiseaseLink(BaseModel):
53
+ gene_symbol : str
54
+ disease_id : str
55
+ score : float
56
+
57
+ class ClinicalTrial(BaseModel):
58
+ nct_id : str = Field(alias="nctId")
59
+ brief_title: str = Field(alias="briefTitle")
60
+ phase : Optional[str]
61
+ status : Optional[str]
62
+ start_date : Optional[str]
63
+
64
+ class OTAssociation(BaseModel):
65
+ score : float
66
+ datatypeId : str
67
+ datasourceId: str
68
+ disease : dict # {id, name}
69
+ target : dict # {id, symbol}
70
+
71
+ # ----------------------------------------------------------------------
72
+ # Search I/O
73
+ # ----------------------------------------------------------------------
74
 
75
  class UnifiedSearchInput(BaseModel):
76
  query: str
77
+
78
+ class UnifiedSearchResult(BaseModel):
79
+ papers : List[Paper]
80
+ umls : List[UMLSConcept]
81
+ drug_safety : List[DrugSafety]
82
+ genes : List[GeneInfo]
83
+ mesh_defs : List[MeshDefinition]
84
+ gene_disease : List[GeneDiseaseLink]
85
+ clinical_trials : List[ClinicalTrial]
86
+ ot_associations : Optional[List[OTAssociation]] = []
87
+ ai_summary : str
88
+ llm_used : str