Module: retrieval
Expand source code
# Copyright (C) 2023-present The Project Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from dataclasses import dataclass
from typing import List
from cl.runtime import RecordMixin
from cl.convince.retrievers.retrieval_key import RetrievalKey
@dataclass(slots=True, kw_only=True)
class Retrieval(RetrievalKey, RecordMixin[RetrievalKey]):
"""Retrieves the requested data from the text."""
input_text: str
"""Text from which the parameter is retrieved."""
param_description: str
"""Description of the retrieved parameter."""
param_samples: List[str] | None = None
"""Samples of possible retrieved parameter values for few-shot prompts."""
success: bool | None = None
"""True for success and False for failure (populated after the retrieval and may be used by a validating prompt)."""
param_value: str | None = None
"""Value of the extracted parameter (populated after the retrieval and may be used by a validating prompt)."""
justification: str | None = None
"""Justification (populated after the retrieval and may be used by a validating prompt)."""
def get_key(self) -> RetrievalKey:
return RetrievalKey(retrieval_id=self.retrieval_id)
Classes
class Retrieval (*, retrieval_id: str = None, input_text: str, param_description: str, param_samples: Optional[List[str]] = None, success: bool | None = None, param_value: str | None = None, justification: str | None = None)
-
Retrieves the requested data from the text.
Expand source code
@dataclass(slots=True, kw_only=True) class Retrieval(RetrievalKey, RecordMixin[RetrievalKey]): """Retrieves the requested data from the text.""" input_text: str """Text from which the parameter is retrieved.""" param_description: str """Description of the retrieved parameter.""" param_samples: List[str] | None = None """Samples of possible retrieved parameter values for few-shot prompts.""" success: bool | None = None """True for success and False for failure (populated after the retrieval and may be used by a validating prompt).""" param_value: str | None = None """Value of the extracted parameter (populated after the retrieval and may be used by a validating prompt).""" justification: str | None = None """Justification (populated after the retrieval and may be used by a validating prompt).""" def get_key(self) -> RetrievalKey: return RetrievalKey(retrieval_id=self.retrieval_id)
Ancestors
- RetrievalKey
- KeyMixin
- abc.ABC
- RecordMixin
- typing.Generic
Static methods
def get_key_type() -> Type
-
Inherited from:
RetrievalKey
.get_key_type
Return key type even when called from a record.
Fields
var input_text -> str
-
Text from which the parameter is retrieved.
var justification -> str | None
-
Justification (populated after the retrieval and may be used by a validating prompt).
var param_description -> str
-
Description of the retrieved parameter.
var param_samples -> Optional[List[str]]
-
Samples of possible retrieved parameter values for few-shot prompts.
var param_value -> str | None
-
Value of the extracted parameter (populated after the retrieval and may be used by a validating prompt).
var retrieval_id -> str
-
Inherited from:
RetrievalKey
.retrieval_id
Unique retrieval identifier.
var success -> bool | None
-
True for success and False for failure (populated after the retrieval and may be used by a validating prompt).
Methods
def get_key(self) -> RetrievalKey
-
Inherited from:
RecordMixin
.get_key
Return a new key object whose fields populated from self, do not return self.
def init_all(self) -> None
-
Inherited from:
RecordMixin
.init_all
Invoke ‘init’ for each class in the order from base to derived, then validate against schema.