Spaces:
Runtime error
Runtime error
Roland Ding commited on
Commit ·
1a75d5d
1
Parent(s): 0cd8cab
7.7.18.48
Browse filesmajor update. Introduce a new paradigm change from procedure to object
oriented design.
+ created all the base classes and their derivatives as per object
relationship
remark: this is my first attempt in OOD. may discard due to the
development cycle.
On branch OOD
Changes to be committed:
modified: .gitignore
new file: article.py
new file: instruction.py
modified: requirements.txt
new file: ui.py
- .gitignore +2 -3
- article.py +57 -0
- instruction.py +26 -0
- requirements.txt +8 -8
- ui.py +38 -0
.gitignore
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
.archive
|
| 2 |
.venv
|
|
|
|
|
|
|
| 3 |
.samples
|
| 4 |
.data
|
| 5 |
.outputs
|
|
@@ -11,7 +13,4 @@
|
|
| 11 |
__pycache__
|
| 12 |
__pycache__/*
|
| 13 |
|
| 14 |
-
prompt*.txt
|
| 15 |
-
feedback*.txt
|
| 16 |
-
output*.txt
|
| 17 |
```
|
|
|
|
| 1 |
.archive
|
| 2 |
.venv
|
| 3 |
+
.external
|
| 4 |
+
.vscode
|
| 5 |
.samples
|
| 6 |
.data
|
| 7 |
.outputs
|
|
|
|
| 13 |
__pycache__
|
| 14 |
__pycache__/*
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
```
|
article.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, List, Dict
|
| 2 |
+
from enum import Enum
|
| 3 |
+
|
| 4 |
+
from pydantic import BaseModel, Field
|
| 5 |
+
# from langchain. import
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Article(BaseModel):
|
| 9 |
+
id: int
|
| 10 |
+
title: str
|
| 11 |
+
content: str
|
| 12 |
+
|
| 13 |
+
class Table(BaseModel):
|
| 14 |
+
title: str = Field(None, alias="title")
|
| 15 |
+
fields: List[str] = Field(None, alias="Table column headings")
|
| 16 |
+
content: Optional[str] = Field(None, alias="Table content body")
|
| 17 |
+
|
| 18 |
+
class Summary(BaseModel):
|
| 19 |
+
tables: Optional[List[Table]] = Field(None, alias="tables")
|
| 20 |
+
|
| 21 |
+
class Assessment(Enum):
|
| 22 |
+
overview = "overview"
|
| 23 |
+
clinical = "clinical"
|
| 24 |
+
radiological = "radiological"
|
| 25 |
+
safety = "safety"
|
| 26 |
+
other = "other"
|
| 27 |
+
|
| 28 |
+
class Parameter(BaseModel):
|
| 29 |
+
name: str
|
| 30 |
+
value: str
|
| 31 |
+
unit: str
|
| 32 |
+
condition:Optional[str] = Field(None, alias="condition")
|
| 33 |
+
assessment:Assessment = Field(None, description="The clinical trail assessment steps")
|
| 34 |
+
|
| 35 |
+
class Preference(BaseModel):
|
| 36 |
+
name: str
|
| 37 |
+
params: List[Parameter] = Field(None, alias="parameters")
|
| 38 |
+
|
| 39 |
+
class ArticleCollection(BaseModel):
|
| 40 |
+
articles: List[Article] = Field(None, alias="articles")
|
| 41 |
+
summary: Optional[Summary] = Field(None, alias="summary")
|
| 42 |
+
preferences: Preference = Field(None, alias="preferences")
|
| 43 |
+
|
| 44 |
+
class ClinicalStudy(Article):
|
| 45 |
+
tables: Optional[List[Table]] = Field(None, alias="tables")
|
| 46 |
+
acceptance_year: Optional[int] = Field(None, alias="acceptance_year")
|
| 47 |
+
acceptance_month: Optional[int] = Field(None, alias="acceptance_month")
|
| 48 |
+
sections: Optional[Dict[str]] = Field(None, alias="sections")
|
| 49 |
+
sectionCollection: Optional[Dict[str]] = Field(None, alias="sectionCollection")
|
| 50 |
+
|
| 51 |
+
class DeviceIMF(Article):
|
| 52 |
+
tables: Optional[List[Table]] = Field(None, alias="tables")
|
| 53 |
+
sections: Optional[List[str]] = Field(None, alias="sections")
|
| 54 |
+
sectionCollection: Optional[List[str]] = Field(None, alias="sectionCollection")
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
instruction.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
from pydantic import BaseModel, Field
|
| 4 |
+
from typing import Optional, List, Dict
|
| 5 |
+
from enum import Enum
|
| 6 |
+
|
| 7 |
+
class Term(BaseModel):
|
| 8 |
+
id: int
|
| 9 |
+
terms: List[str] = Field(None, alias="terms")
|
| 10 |
+
|
| 11 |
+
class PostParser(BaseModel):
|
| 12 |
+
id: int
|
| 13 |
+
name: str
|
| 14 |
+
terms: List[str] = Field(None, alias="terms")
|
| 15 |
+
|
| 16 |
+
class PostParser(BaseModel):
|
| 17 |
+
id: int
|
| 18 |
+
name: str
|
| 19 |
+
terms: List[str] = Field(None, alias="terms")
|
| 20 |
+
|
| 21 |
+
class Instruction(BaseModel):
|
| 22 |
+
name: str
|
| 23 |
+
|
| 24 |
+
class InstructionClassifier(BaseModel):
|
| 25 |
+
terms: List[Term] = Field(None, alias="terms")
|
| 26 |
+
instruction: Instruction = Field(None, alias="instruction")
|
requirements.txt
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
gradio
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 1 |
+
gradio==3.35.2
|
| 2 |
+
boto3==1.26.165
|
| 3 |
+
requests==2.31.0
|
| 4 |
+
openai==1.3.2
|
| 5 |
+
pdfminer.six==20221105
|
| 6 |
+
tiktoken==0.4.0
|
| 7 |
+
pydantic==1.10.10
|
| 8 |
+
langchain==0.0.336
|
ui.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from article import *
|
| 4 |
+
from pydantic import BaseModel, Field
|
| 5 |
+
from typing import Optional, List, Dict
|
| 6 |
+
|
| 7 |
+
class FileUpload(BaseModel):
|
| 8 |
+
file: bytes = Field(None, alias="file")
|
| 9 |
+
|
| 10 |
+
class ArticleDisplay(BaseModel):
|
| 11 |
+
title: str = Field(None, alias="title")
|
| 12 |
+
content: str = Field(None, alias="content")
|
| 13 |
+
|
| 14 |
+
class TableDisplay(BaseModel):
|
| 15 |
+
table: Optional[Table] = Field(None, alias="table")
|
| 16 |
+
|
| 17 |
+
class StudyTabDisplay(ArticleDisplay):
|
| 18 |
+
file: FileUpload = Field(None, alias="file")
|
| 19 |
+
tables: Optional[List[Table]] = Field(None, alias="tables")
|
| 20 |
+
|
| 21 |
+
class IMFTabDsiplay(ArticleDisplay):
|
| 22 |
+
imf: Optional[DeviceIMF] = Field(None, alias="Device IMF article object")
|
| 23 |
+
|
| 24 |
+
class ArticleCollectionDisplay(BaseModel):
|
| 25 |
+
article_collection: Optional[ArticleCollection] = Field(None, alias="article_collection")
|
| 26 |
+
|
| 27 |
+
class ParameterDisplay(BaseModel):
|
| 28 |
+
parameter: Optional[Parameter] = Field(None, alias="parameter")
|
| 29 |
+
|
| 30 |
+
class PreferenceDisplay(BaseModel):
|
| 31 |
+
preference: Optional[Preference] = Field(None, alias="preference")
|
| 32 |
+
param_displays: Optional[List[ParameterDisplay]] = Field(None, alias="param_displays")
|
| 33 |
+
|
| 34 |
+
class SummaryDisplay(BaseModel):
|
| 35 |
+
articles: Optional[ArticleCollectionDisplay] = Field(None, alias="articles")
|
| 36 |
+
summary: Optional[Summary] = Field(None, alias="summary")
|
| 37 |
+
preference: Optional[PreferenceDisplay] = Field(None, alias="preference")
|
| 38 |
+
|