Upload 6 files
Browse files
entities/__init__.py
ADDED
|
File without changes
|
entities/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (158 Bytes). View file
|
|
|
entities/__pycache__/pipeline_request.cpython-311.pyc
ADDED
|
Binary file (2.37 kB). View file
|
|
|
entities/__pycache__/task.cpython-311.pyc
ADDED
|
Binary file (5.12 kB). View file
|
|
|
entities/pipeline_request.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pydantic import BaseModel
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class PipelineRequest(BaseModel):
|
| 5 |
+
customer_name: str
|
| 6 |
+
task_type: str
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class PubMedPipelineRequest(PipelineRequest):
|
| 10 |
+
query: str
|
| 11 |
+
direction: str
|
| 12 |
+
start_year: int
|
| 13 |
+
end_year: int
|
| 14 |
+
size: int
|
| 15 |
+
translate_to_cn: bool = False
|
| 16 |
+
task_type: str = "pubmed"
|
| 17 |
+
model_names: list[str] = ["gpt-4o-mini"]
|
| 18 |
+
do_compare: bool = False
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class PubMedPlusPipelineRequest(PipelineRequest):
|
| 22 |
+
query: str
|
| 23 |
+
direction: str
|
| 24 |
+
start_year: int
|
| 25 |
+
end_year: int
|
| 26 |
+
size: int
|
| 27 |
+
translate_to_cn: bool = False
|
| 28 |
+
task_type: str = "pubmed_plus"
|
| 29 |
+
model_names: list[str] = ["gpt-4o-mini"]
|
| 30 |
+
do_compare: bool = False
|
| 31 |
+
do_refine: bool = False
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class ArxivPipelineRequest(PipelineRequest):
|
| 35 |
+
query: str
|
| 36 |
+
direction: str
|
| 37 |
+
start_date: str
|
| 38 |
+
end_date: str
|
| 39 |
+
size: int
|
| 40 |
+
translate_to_cn: bool = False
|
| 41 |
+
task_type: str = "arxiv"
|
| 42 |
+
model_names: list[str] = ["gpt-4o-mini"]
|
| 43 |
+
do_compare: bool = False
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
pipeline_request_factory = {
|
| 47 |
+
"pubmed": PubMedPipelineRequest,
|
| 48 |
+
"pubmed_plus": PubMedPlusPipelineRequest,
|
| 49 |
+
"arxiv": ArxivPipelineRequest
|
| 50 |
+
}
|
entities/task.py
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
|
| 3 |
+
from typing import Dict
|
| 4 |
+
from loguru import logger
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# 定义任务
|
| 8 |
+
class Task:
|
| 9 |
+
|
| 10 |
+
@classmethod
|
| 11 |
+
def load_from_json(cls, json_data):
|
| 12 |
+
task = cls(**json_data)
|
| 13 |
+
return task
|
| 14 |
+
|
| 15 |
+
def __init__(self):
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
def save_to_json(self):
|
| 19 |
+
return json.dumps(vars(self))
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class PubMedTask(Task):
|
| 23 |
+
|
| 24 |
+
def __init__(
|
| 25 |
+
self,
|
| 26 |
+
query: str = "",
|
| 27 |
+
direction: str = "",
|
| 28 |
+
start_year: int = 2018,
|
| 29 |
+
end_year: int = 2023,
|
| 30 |
+
size: int = 10,
|
| 31 |
+
uuid: int = 0,
|
| 32 |
+
customer_name: str = "test",
|
| 33 |
+
status: dict[str:int] = {},
|
| 34 |
+
status_string: dict[str:str] = {"overall": "in queue"},
|
| 35 |
+
translate_to_cn: bool = False,
|
| 36 |
+
model_names: list[str] = ["gpt-4o-mini"],
|
| 37 |
+
task_type: str = "pubmed",
|
| 38 |
+
do_compare: bool = False
|
| 39 |
+
):
|
| 40 |
+
# basic query information
|
| 41 |
+
self.query = query
|
| 42 |
+
self.direction = direction
|
| 43 |
+
self.start_year = start_year
|
| 44 |
+
self.end_year = end_year
|
| 45 |
+
self.size = size
|
| 46 |
+
self.translate_to_cn = translate_to_cn
|
| 47 |
+
self.model_names = model_names
|
| 48 |
+
self.task_type = task_type
|
| 49 |
+
self.do_compare = do_compare
|
| 50 |
+
|
| 51 |
+
# task information
|
| 52 |
+
self.uuid = uuid
|
| 53 |
+
self.customer_name = customer_name
|
| 54 |
+
|
| 55 |
+
# task status
|
| 56 |
+
self.status = status
|
| 57 |
+
self.status_string = status_string
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class PubMedPlusTask(Task):
|
| 61 |
+
|
| 62 |
+
def __init__(
|
| 63 |
+
self,
|
| 64 |
+
query: str = "",
|
| 65 |
+
direction: str = "",
|
| 66 |
+
start_year: int = 2018,
|
| 67 |
+
end_year: int = 2023,
|
| 68 |
+
size: int = 10,
|
| 69 |
+
uuid: int = 0,
|
| 70 |
+
customer_name: str = "test",
|
| 71 |
+
status: dict[str:int] = {},
|
| 72 |
+
status_string: dict[str:str] = {"overall": "in queue"},
|
| 73 |
+
translate_to_cn: bool = False,
|
| 74 |
+
model_names: list[str] = ["gpt-4o-mini"],
|
| 75 |
+
task_type: str = "pubmed",
|
| 76 |
+
do_compare: bool = False,
|
| 77 |
+
do_refine: bool = False
|
| 78 |
+
):
|
| 79 |
+
# basic query information
|
| 80 |
+
self.query = query
|
| 81 |
+
self.direction = direction
|
| 82 |
+
self.start_year = start_year
|
| 83 |
+
self.end_year = end_year
|
| 84 |
+
self.size = size
|
| 85 |
+
self.translate_to_cn = translate_to_cn
|
| 86 |
+
self.model_names = model_names
|
| 87 |
+
self.task_type = task_type
|
| 88 |
+
self.do_compare = do_compare
|
| 89 |
+
self.do_refine = do_refine
|
| 90 |
+
|
| 91 |
+
# task information
|
| 92 |
+
self.uuid = uuid
|
| 93 |
+
self.customer_name = customer_name
|
| 94 |
+
|
| 95 |
+
# task status
|
| 96 |
+
self.status = status
|
| 97 |
+
self.status_string = status_string
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
class ArxivTask(Task):
|
| 101 |
+
|
| 102 |
+
def __init__(
|
| 103 |
+
self,
|
| 104 |
+
query: str = "",
|
| 105 |
+
direction: str = "",
|
| 106 |
+
start_date: str = "2018-01-01",
|
| 107 |
+
end_date: str = "2023-12-31",
|
| 108 |
+
size: int = 10,
|
| 109 |
+
uuid: int = 0,
|
| 110 |
+
customer_name: str = "test",
|
| 111 |
+
status: dict[str:int] = {},
|
| 112 |
+
status_string: dict[str:str] = {"overall": "in queue"},
|
| 113 |
+
translate_to_cn: bool = False,
|
| 114 |
+
model_names: list[str] = ["gpt-4o-mini"],
|
| 115 |
+
task_type: str = "arxiv",
|
| 116 |
+
do_compare: bool = False
|
| 117 |
+
):
|
| 118 |
+
# basic query information
|
| 119 |
+
self.query = query
|
| 120 |
+
if direction:
|
| 121 |
+
self.direction = direction
|
| 122 |
+
else:
|
| 123 |
+
self.direction = query
|
| 124 |
+
self.start_date = start_date
|
| 125 |
+
self.end_date = end_date
|
| 126 |
+
self.size = size
|
| 127 |
+
self.translate_to_cn = translate_to_cn
|
| 128 |
+
self.model_names = model_names
|
| 129 |
+
self.task_type = task_type
|
| 130 |
+
self.do_compare = do_compare
|
| 131 |
+
|
| 132 |
+
# task information
|
| 133 |
+
self.uuid = uuid
|
| 134 |
+
self.customer_name = customer_name
|
| 135 |
+
|
| 136 |
+
# task information
|
| 137 |
+
self.uuid = uuid
|
| 138 |
+
self.customer_name = customer_name
|
| 139 |
+
|
| 140 |
+
# task status
|
| 141 |
+
self.status = status
|
| 142 |
+
self.status_string = status_string
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
task_factory = {
|
| 146 |
+
"pubmed": PubMedTask,
|
| 147 |
+
"pubmed_plus": PubMedPlusTask,
|
| 148 |
+
"arxiv": ArxivTask
|
| 149 |
+
}
|