Skip to content

Eng 2040 ai r 2 add splitting features to the sdk #546

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

Conversation

Muhammad-Elmallah
Copy link
Collaborator

No description provided.

class Splitter:
def __init__(self, split: bool, split_by: str, split_length: int, split_overlap: int):
self.split = split
self.split_by = split_by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make split_by an enumerator. Should it have a default value?

Should split_length and split_overlap have a default value?

@@ -144,25 +152,39 @@ def search(self, query: str, top_k: int = 10, filters: List[IndexFilter] = []) -
}
return self.run(data=data)

def upsert(self, documents: List[Record]) -> ModelResponse:
def upsert(self, documents: List[Record], splitter: Splitter = None) -> ModelResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

splitter: Optional[Splitter] = None


Returns:
ModelResponse: Response from the indexing service

Example:
index_model.upsert([Record(value="Hello, world!", value_type="text", uri="", id="1", attributes={})])
index_model.upsert([Record(value="Hello, world!", value_type="text", uri="", id="1", attributes={})], splitter=Splitter(split=True, split_by="word", split_length=1, split_overlap=0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain in a line what the splitter does in this example.

@@ -149,8 +150,8 @@ def test_index_model_with_filter(embedding_model, supplier_params):
from aixplain.factories import IndexFactory
from aixplain.modules.model.index_model import IndexFilter, IndexFilterOperator

for index in IndexFactory.list()["results"]:
index.delete()
# for index in IndexFactory.list()["results"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment

for index in IndexFactory.list()["results"]:
index.delete()
# for index in IndexFactory.list()["results"]:
# index.delete()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment

@Muhammad-Elmallah Muhammad-Elmallah merged commit f6422db into development Jun 2, 2025
@Muhammad-Elmallah Muhammad-Elmallah deleted the ENG-2040-ai-r-2-add-splitting-features-to-the-sdk branch June 2, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants