|
1 | 1 | from enum import Enum |
2 | | -from typing import List, Literal, Optional, Union |
| 2 | +from typing import Dict, List, Literal, Optional, Union |
3 | 3 |
|
4 | | -from deepsearch.model.base.types import BaseInfReq, BaseModelConfig, Kind, StrictModel |
| 4 | +from deepsearch.model.base.types import ( |
| 5 | + BaseAppPredInput, |
| 6 | + BaseModelConfig, |
| 7 | + BaseModelMetadata, |
| 8 | + CtrlInfoOutput, |
| 9 | + CtrlInfoOutputDefs, |
| 10 | + Kind, |
| 11 | + ModelInfoOutputDefsSpec, |
| 12 | + StrictModel, |
| 13 | +) |
5 | 14 |
|
6 | 15 |
|
7 | 16 | class NLPType(str, Enum): |
@@ -48,7 +57,7 @@ class NLPRelationshipsReqSpec(StrictModel): |
48 | 57 | ] |
49 | 58 |
|
50 | 59 |
|
51 | | -class NLPRequest(BaseInfReq): |
| 60 | +class NLPAppPredInput(BaseAppPredInput): |
52 | 61 | kind: Literal[Kind.NLPModel] |
53 | 62 | spec: NLPReqSpec |
54 | 63 |
|
@@ -80,33 +89,60 @@ class AnnotationLabels(StrictModel): |
80 | 89 | properties: List[PropertyLabel] |
81 | 90 |
|
82 | 91 |
|
83 | | -# TODO Annotate*Input pydantic models needed? |
| 92 | +class AnnotateEntitiesEntry(StrictModel): |
| 93 | + type: str |
| 94 | + match: str |
| 95 | + original: str |
| 96 | + range: List[int] |
84 | 97 |
|
85 | | -AnnotateEntitiesOutput = List[dict] # TODO provide real implementation |
86 | | -AnnotateRelationshipsOutput = List[dict] # TODO provide real implementation |
87 | | -AnnotatePropertiesOutput = List[dict] # TODO provide real implementation |
88 | 98 |
|
| 99 | +class AnnotateRelationshipsEntry(StrictModel): |
| 100 | + header: list |
| 101 | + data: list |
89 | 102 |
|
90 | | -class NLPEntitiesControllerOutput(StrictModel): |
| 103 | + |
| 104 | +AnnotateEntitiesOutput = List[Dict[str, List[AnnotateEntitiesEntry]]] |
| 105 | +AnnotateRelationshipsOutput = List[Dict[str, AnnotateRelationshipsEntry]] |
| 106 | +AnnotatePropertiesOutput = List[Dict] # TODO specify |
| 107 | + |
| 108 | + |
| 109 | +class NLPEntsCtrlPredOuput(StrictModel): |
91 | 110 | entities: AnnotateEntitiesOutput |
92 | 111 |
|
93 | 112 |
|
94 | | -class NLPRelationshipsControllerOutput(StrictModel): |
| 113 | +class NLPRelsCtrlPredOutput(StrictModel): |
95 | 114 | relationships: AnnotateRelationshipsOutput |
96 | 115 |
|
97 | 116 |
|
98 | | -class NLPPropertiesControllerOutput(StrictModel): |
| 117 | +class NLPPropsCtrlPredOutput(StrictModel): |
99 | 118 | properties: AnnotatePropertiesOutput |
100 | 119 |
|
101 | 120 |
|
102 | | -NLPControllerOutput = Union[ |
103 | | - NLPEntitiesControllerOutput, |
104 | | - NLPRelationshipsControllerOutput, |
105 | | - NLPPropertiesControllerOutput, |
| 121 | +NLPCtrlPredOutput = Union[ |
| 122 | + NLPEntsCtrlPredOuput, |
| 123 | + NLPRelsCtrlPredOutput, |
| 124 | + NLPPropsCtrlPredOutput, |
106 | 125 | ] |
107 | 126 |
|
108 | 127 |
|
109 | 128 | class NLPConfig(BaseModelConfig): |
110 | 129 | kind: Literal[Kind.NLPModel] |
111 | 130 | supported_types: List[NLPType] |
112 | 131 | labels: AnnotationLabels |
| 132 | + |
| 133 | + |
| 134 | +class NLPModelMetadata(BaseModelMetadata): |
| 135 | + supported_object_types: List[Literal["text", "table", "image"]] |
| 136 | + |
| 137 | + |
| 138 | +class NLPInfoOutputDefinitionsSpec(ModelInfoOutputDefsSpec): |
| 139 | + metadata: NLPModelMetadata |
| 140 | + |
| 141 | + |
| 142 | +class NLPInfoOutputDefinitions(CtrlInfoOutputDefs): |
| 143 | + kind: Literal[Kind.NLPModel] |
| 144 | + spec: NLPInfoOutputDefinitionsSpec |
| 145 | + |
| 146 | + |
| 147 | +class NLPInfoOutput(CtrlInfoOutput): |
| 148 | + definitions: NLPInfoOutputDefinitions |
0 commit comments