diff --git a/src/ontogpt/engines/knowledge_engine.py b/src/ontogpt/engines/knowledge_engine.py index 36de8425a..5df2ab24a 100644 --- a/src/ontogpt/engines/knowledge_engine.py +++ b/src/ontogpt/engines/knowledge_engine.py @@ -80,7 +80,7 @@ class KnowledgeEngine(ABC): knowledge sources plus LLMs """ - template: TEMPLATE_NAME = None + template: TEMPLATE_NAME = "" """LinkML Template to use for this engine. Must be of the form .""" @@ -92,7 +92,7 @@ class KnowledgeEngine(ABC): """Python class for the template. This is derived from the template and does not need to be set manually.""" - template_module: ModuleType = None + template_module: ModuleType """Python module for the template. This is derived from the template and does not need to be set manually.""" @@ -100,32 +100,32 @@ class KnowledgeEngine(ABC): """LinkML SchemaView over the template. This is derived from the template and does not need to be set manually.""" - api_key: str = None + api_key: str = "" """OpenAI API key.""" - model: MODEL_NAME = None + model: MODEL_NAME = "" """Language Model. This may be overridden in subclasses.""" # annotator: TextAnnotatorInterface = None # """Default annotator. TODO: deprecate?""" - annotators: Dict[str, List[TextAnnotatorInterface]] = None + annotators: Dict[str, List[TextAnnotatorInterface]] """Annotators for each class. An annotator will ground/map labels to CURIEs. These override the annotators annotated in the template """ - skip_annotators: Optional[List[TextAnnotatorInterface]] = None + skip_annotators: Optional[List[TextAnnotatorInterface]] """Annotators to skip. This overrides any specified in the schema""" - mappers: List[BasicOntologyInterface] = None + mappers: List[BasicOntologyInterface] """List of concept mappers, to assist in grounding to desired ID prefix""" - labelers: List[BasicOntologyInterface] = None + labelers: List[BasicOntologyInterface] """Labelers that map CURIEs to labels""" - client: OpenAIClient = None + client: OpenAIClient """All calls to LLMs are delegated through this client""" dictionary: Dict[str, str] = field(default_factory=dict) @@ -139,13 +139,13 @@ class KnowledgeEngine(ABC): named_entities: List[NamedEntity] = field(default_factory=list) """Cache of all named entities""" - auto_prefix: str = None + auto_prefix: str = "" """If set then non-normalized named entities will be mapped to this prefix""" - last_text: str = None + last_text: str = "" """Cache of last text.""" - last_prompt: str = None + last_prompt: str = "" """Cache of last prompt used.""" encoding = None @@ -321,9 +321,10 @@ def promptable_slots(self, cls: Optional[ClassDefinition] = None) -> List[SlotDe return [s for s in sv.class_induced_slots(cls.name) if not self.slot_is_skipped(s)] def slot_is_skipped(self, slot: SlotDefinition) -> bool: - sv = self.schemaview if ANNOTATION_KEY_PROMPT_SKIP in slot.annotations: return True + else: + return False def normalize_named_entity(self, text: str, range: ElementName) -> str: """ @@ -558,7 +559,7 @@ def groundings(self, text: str, cls: ClassDefinition) -> Iterator[str]: # raise NotImplementedError def merge_resultsets( - self, resultset: List[ExtractionResult], unique_fields: List[str] = None + self, resultset: List[ExtractionResult], unique_fields: List[str] = [""] ) -> ExtractionResult: """ Merge all resultsets into a single resultset. diff --git a/src/ontogpt/engines/mapping_engine.py b/src/ontogpt/engines/mapping_engine.py index 415a50300..e41e24894 100644 --- a/src/ontogpt/engines/mapping_engine.py +++ b/src/ontogpt/engines/mapping_engine.py @@ -57,22 +57,22 @@ class Confidence(str, Enum): class CategorizedMapping(BaseModel): subject: CURIE = None object: CURIE = None - completion: str = None + completion: str = "" predicate: Union[MappingPredicate, str] = None confidence: Union[Confidence, str] = None - similarities: List[str] = None - differences: List[str] = None + similarities: List[str] = [""] + differences: List[str] = [""] class MappingTask(BaseModel): subject: CURIE object: CURIE - subject_label: str = None - object_label: str = None - subject_source: str = None - object_source: str = None - subject_adapter: str = None - object_adapter: str = None + subject_label: str = "" + object_label: str = "" + subject_source: str = "" + object_source: str = "" + subject_adapter: str = "" + object_adapter: str = "" predicate: Union[str, MappingPredicate] = None difficulty: Confidence = None score: float = None @@ -97,11 +97,11 @@ class Relationship(BaseModel): class Concept(BaseModel): id: CURIE label: str - definition: str = None - synonyms: List[str] = [] - parents: List[str] = [] + definition: str = "" + synonyms: List[str] = [""] + parents: List[str] = [""] relationships: List[Relationship] = [] - categories: List[str] = [] + categories: List[str] = [""] @dataclass @@ -112,7 +112,7 @@ class MappingEngine(KnowledgeEngine): object_adapter: BasicOntologyInterface = None def categorize_mapping( - self, subject: CURIE, object: CURIE, template_path: str = None + self, subject: CURIE, object: CURIE, template_path: str = "" ) -> CategorizedMapping: if template_path is None: template_path = DEFAULT_MAPPING_EVAL_PROMPT diff --git a/src/ontogpt/engines/spires_engine.py b/src/ontogpt/engines/spires_engine.py index 71a771f0c..6a0d1213a 100644 --- a/src/ontogpt/engines/spires_engine.py +++ b/src/ontogpt/engines/spires_engine.py @@ -371,7 +371,7 @@ def _raw_extract( return payload def get_completion_prompt( - self, cls: ClassDefinition = None, text: str = None, object: OBJECT = None + self, cls: ClassDefinition = None, text: str = "", object: OBJECT = None ) -> str: """Get the prompt for the given template.""" if cls is None: