Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] remove ai21labs spellcheck and summarize #288

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
)
Loading