Skip to content

Commit

Permalink
Merge pull request #288 from edenai/SD2-894-ai-21-labs-not-found-error
Browse files Browse the repository at this point in the history
[fix] remove ai21labs spellcheck and summarize
  • Loading branch information
juandavidcruzgomez authored Dec 10, 2024
2 parents 273ed40 + 5dd1ecf commit b4a3eb5
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions edenai_apis/apis/ai21labs/ai21labs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,6 @@ def text__generation(
standardized_response=standardized_response,
)

def text__summarize(
self,
text: str,
output_sentences: int,
language: str,
model: Optional[str] = None
) -> ResponseType[SummarizeDataClass]:
payload = {"source": text, "sourceType": "TEXT"}
original_response = self.__ai21labs_api_request(
url="summarize", payload=payload
)
summary = original_response.get("summary")
standardized_response = SummarizeDataClass(result=summary)

return ResponseType[SummarizeDataClass](
original_response=original_response,
standardized_response=standardized_response,
)

def text__embeddings(
self, texts: List[str], model: Optional[str] = None
) -> ResponseType[EmbeddingsDataClass]:
Expand All @@ -152,28 +133,3 @@ def text__embeddings(
original_response=original_response,
standardized_response=standardized_response,
)

def text__spell_check(
self, text: str, language: str
) -> ResponseType[SpellCheckDataClass]:
payload = {"text": text}
original_response = self.__ai21labs_api_request(url="gec", payload=payload)
items = []
for correction in original_response.get("corrections"):
start_index = correction.get("startIndex")
end_index = correction.get("endIndex")
length = end_index - start_index
spell_check_item = SpellCheckItem(
text=correction.get("originalText"),
suggestions=[
SuggestionItem(suggestion=correction.get("suggestion"), score=None)
],
offset=start_index,
length=length,
type=correction.get("correctionType"),
)
items.append(spell_check_item)
return ResponseType[SpellCheckDataClass](
original_response=original_response,
standardized_response=SpellCheckDataClass(text=text, items=items),
)

0 comments on commit b4a3eb5

Please sign in to comment.