@ -9,7 +9,7 @@ from langchain.schema import BaseRetriever
def clean_excerpt ( excerpt : str ) - > str :
""" Clean s an excerpt from Kendra.
""" Clean an excerpt from Kendra.
Args :
excerpt : The excerpt to clean .
@ -25,7 +25,7 @@ def clean_excerpt(excerpt: str) -> str:
def combined_text ( item : " ResultItem " ) - > str :
""" Combine s a ResultItem title and excerpt into a single string.
""" Combine a ResultItem title and excerpt into a single string.
Args :
item : the ResultItem of a Kendra search .
@ -45,15 +45,15 @@ def combined_text(item: "ResultItem") -> str:
DocumentAttributeValueType = Union [ str , int , List [ str ] , None ]
""" Possible types of a DocumentAttributeValue. Dates are also represented as str. """
""" Possible types of a DocumentAttributeValue.
Dates are also represented as str .
"""
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class Highlight ( BaseModel , extra = Extra . allow ) : # type: ignore[call-arg]
"""
Represents the information that can be
used to highlight key words in the excerpt .
"""
""" Information that highlights the key words in the excerpt. """
BeginOffset : int
""" The zero-based location in the excerpt where the highlight starts. """
@ -79,7 +79,7 @@ class TextWithHighLights(BaseModel, extra=Extra.allow): # type: ignore[call-arg
class AdditionalResultAttributeValue ( # type: ignore[call-arg]
BaseModel , extra = Extra . allow
) :
""" The v alue of an additional result attribute."""
""" V alue of an additional result attribute."""
TextWithHighlightsValue : TextWithHighLights
""" The text with highlights value. """
@ -87,7 +87,7 @@ class AdditionalResultAttributeValue( # type: ignore[call-arg]
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class AdditionalResultAttribute ( BaseModel , extra = Extra . allow ) : # type: ignore[call-arg]
""" A n a dditional result attribute."""
""" A dditional result attribute."""
Key : str
""" The key of the attribute. """
@ -102,7 +102,7 @@ class AdditionalResultAttribute(BaseModel, extra=Extra.allow): # type: ignore[c
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class DocumentAttributeValue ( BaseModel , extra = Extra . allow ) : # type: ignore[call-arg]
""" The v alue of a document attribute."""
""" V alue of a document attribute."""
DateValue : Optional [ str ]
""" The date expressed as an ISO 8601 string. """
@ -133,7 +133,7 @@ class DocumentAttributeValue(BaseModel, extra=Extra.allow): # type: ignore[call
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class DocumentAttribute ( BaseModel , extra = Extra . allow ) : # type: ignore[call-arg]
""" A d ocument attribute."""
""" D ocument attribute."""
Key : str
""" The key of the attribute. """
@ -143,7 +143,7 @@ class DocumentAttribute(BaseModel, extra=Extra.allow): # type: ignore[call-arg]
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class ResultItem ( BaseModel , ABC , extra = Extra . allow ) : # type: ignore[call-arg]
""" Abstract class that represents a result item."""
""" Base class of a result item."""
Id : Optional [ str ]
""" The ID of the relevant result item. """
@ -199,7 +199,7 @@ class ResultItem(BaseModel, ABC, extra=Extra.allow): # type: ignore[call-arg]
class QueryResultItem ( ResultItem ) :
""" A Query API result item."""
""" Query API result item."""
DocumentTitle : TextWithHighLights
""" The document title. """
@ -248,7 +248,7 @@ class QueryResultItem(ResultItem):
class RetrieveResultItem ( ResultItem ) :
""" A Retrieve API result item."""
""" Retrieve API result item."""
DocumentTitle : Optional [ str ]
""" The document title. """
@ -264,11 +264,12 @@ class RetrieveResultItem(ResultItem):
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class QueryResult ( BaseModel , extra = Extra . allow ) : # type: ignore[call-arg]
"""
Represents an Amazon Kendra Query API search result , which is composed of :
""" `Amazon Kendra Query API` search result.
It is composed of :
* Relevant suggested answers : either a text excerpt or table excerpt .
* Matching FAQs or questions - answer from your FAQ file .
* Documents including an excerpt of each document with the its title .
* Documents including an excerpt of each document with its title .
"""
ResultItems : List [ QueryResultItem ]
@ -277,8 +278,9 @@ class QueryResult(BaseModel, extra=Extra.allow): # type: ignore[call-arg]
# Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class RetrieveResult ( BaseModel , extra = Extra . allow ) : # type: ignore[call-arg]
"""
Represents an Amazon Kendra Retrieve API search result , which is composed of :
""" `Amazon Kendra Retrieve API` search result.
It is composed of :
* relevant passages or text excerpts given an input query .
"""
@ -289,7 +291,7 @@ class RetrieveResult(BaseModel, extra=Extra.allow): # type: ignore[call-arg]
class AmazonKendraRetriever ( BaseRetriever ) :
""" Retriever for the Amazon Kendra Index .
""" `Amazon Kendra Index` retriever .
Args :
index_id : Kendra index id