Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a7ac7ad
ENG-1852: Hotfix, added fail-fast option (#488)
kadirpekel Apr 11, 2025
b0887bd
Fix: BUG-503 failed to update utility tool after get (#491)
ahmetgunduz Apr 16, 2025
89daf2f
Bug-503-fix Update (#493)
ahmetgunduz Apr 16, 2025
6bf7d00
ENG-1920: added sentry cred (#476)
xainaz Apr 16, 2025
9e2b03c
Read input variables correctly (#496)
thiago-aixplain Apr 17, 2025
409a893
Fix: file not deleted in test_sql_tool_with_csv test (#492)
ahmetgunduz Apr 17, 2025
3acfacd
ENG-2007: Fix agent and team agent parametrized functional test - Syn…
lucas-aixplain Apr 17, 2025
da7ec38
ENG-1789: Add multiple index backbones support (#443)
basitanees Apr 23, 2025
d360780
ENG-2049: rename air functions (#500)
thiago-aixplain Apr 24, 2025
24e88da
ENG 1924: aixplain sdk new test cases for agents using utility and pi…
OsujiCC Apr 24, 2025
044d8d8
add pydantic requirement (#502)
basitanees Apr 25, 2025
4efdbc8
ENG-1978: Adding instructions to teams (#485)
thiago-aixplain Apr 25, 2025
ab2fcc5
BUG-504: Merged paramMappings for the same link vectors (#499)
kadirpekel Apr 25, 2025
268cc1a
ENG-1836: Set name of tools on the SDK (#501)
thiago-aixplain Apr 28, 2025
9796d19
Eng 2051 Improvements on CI flow (#509)
kadirpekel Apr 30, 2025
f0837fc
Add a finetuned version of BGE model (#512)
Muhammad-Elmallah May 5, 2025
511bf5f
ENG-2055-Aixplain-SDK-Centralized-Error-Handling (#510)
ahmetgunduz May 6, 2025
0c4edf4
ENG-1862:Added status to Tools and deployment check for Agent and Tea…
ahmetgunduz May 6, 2025
0989c51
Merge branch 'test' into development
hadi-aix May 8, 2025
84baed8
Fix: BUG-543 SQL Tool upload db issue (#519)
ahmetgunduz May 9, 2025
de6a1c4
ENG-2028: model streaming (#506)
thiago-aixplain May 9, 2025
b909a54
BUG-542-Utility-Model-Update-Test-Failing-in-SDK (#515)
ahmetgunduz May 9, 2025
8aa3d31
ENG-2115 fixing agent tests (#522)
thiago-aixplain May 9, 2025
4f20c65
Merge branch 'test' into development
thiago-aixplain May 9, 2025
87d5791
ENG-1551 ai xplain sdk caching onboarded models pipelines and agents …
xainaz May 12, 2025
6f600d9
Bug 531: standardize asset names (#521)
OsujiCC May 14, 2025
85d0406
fixed asset issue (#526)
xainaz May 15, 2025
4d650c9
Make functional test more stable (#525)
thiago-aixplain May 15, 2025
91d6864
ENG-2100: Enable JSON schema as output format (#513)
thiago-aixplain May 19, 2025
cecd3a6
Added serialize function for save (#529)
xainaz May 20, 2025
6aa648f
Add Embedding Params to Model (#534)
basitanees May 20, 2025
ad4ddbf
Prod 1785 enable adding any embedding in ai r not just embedding mode…
Muhammad-Elmallah May 21, 2025
bb74b68
Changed cache default to false (#536)
xainaz May 22, 2025
e3f072d
Merge branch 'test' into development
thiago-aixplain May 22, 2025
b2a00e3
added filelock (#538)
xainaz May 23, 2025
239b56a
Add filelock to requirements (#540)
thiago-aixplain May 23, 2025
1f6b614
cache duration (#541)
xainaz May 23, 2025
14485e2
ErrorCode returns code in string (#542)
yunsukim86 May 26, 2025
59be7cc
ENG-2003 : Add LLM's to Agents as Object (#524)
ahmetgunduz May 27, 2025
cdaaa81
ENG-2105: persist sql data (#528)
thiago-aixplain May 27, 2025
77ff8d8
Custom inspector interface (#484)
yunsukim86 Jun 2, 2025
f6422db
Eng 2040 ai r 2 add splitting features to the sdk (#546)
Muhammad-Elmallah Jun 2, 2025
59e40d6
pipeline to_dict change + fixed circular imports pipeline functional …
xainaz Jun 2, 2025
c8aa11c
ENG-1962: composio (#547)
thiago-aixplain Jun 4, 2025
b7a929d
Add input target for inspectors (#548)
yunsukim86 Jun 6, 2025
6067f16
ENG-1900 Refined agent deletion error messages (#543)
kadirpekel Jun 10, 2025
c570a70
ENG-2271: Add code interpreter model ID (#550)
lucas-aixplain Jun 16, 2025
80ddb8a
Update enums.py (#552)
hadi-aix Jun 18, 2025
39be1d0
Update enums.py (#554)
hadi-aix Jun 18, 2025
c45b709
Merge branch 'test' into development
hadi-aix Jun 18, 2025
095f9b8
removed pipeline cache test (#556)
xainaz Jun 19, 2025
01a7f9e
Functional test fix of agent in use error (#560)
ahmetgunduz Jun 20, 2025
585444a
BUG-574 Fixed functionType type handling (#561)
kadirpekel Jun 20, 2025
1e84627
PROD-1833: Optional Instructions in Agents (#559)
ahmetgunduz Jun 24, 2025
ea51442
fixing the tests (#569)
Muhammad-Elmallah Jun 25, 2025
ba406e2
Introducing prompt benchmarking (#497)
shreyasXplain Jun 26, 2025
3d6dc91
ENG-2371 functional test for pipeline run_async (#570)
kadirpekel Jun 27, 2025
a96dd07
Add new methods to Air (#578)
basitanees Jul 8, 2025
ac8b5ac
Bumped model-interfaces to latest release (#221)
mikelam-us-aixplain Jul 8, 2025
7e59519
Re-implement the integration.py file (#581)
elsheikhams99 Jul 13, 2025
5b6bcaa
Improve readability - fix OAUTH methods bug (#583)
elsheikhams99 Jul 14, 2025
29e6f13
Merge branch 'test' into mergetotest_20250714
hadi-aix Jul 14, 2025
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
48 changes: 47 additions & 1 deletion aixplain/modules/model/index_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def search(self, query: str, top_k: int = 10, filters: List[IndexFilter] = []) -
"data": query or uri,
"dataType": value_type,
"filters": [filter.to_dict() for filter in filters],
"payload": {"uri": uri, "value_type": value_type, "top_k": top_k}
"payload": {"uri": uri, "value_type": value_type, "top_k": top_k},
}
return self.run(data=data)

Expand Down Expand Up @@ -246,3 +246,49 @@ def delete_record(self, record_id: Text) -> ModelResponse:
if response.status == "SUCCESS":
return response
raise Exception(f"Failed to delete record: {response.error_message}")

def retrieve_records_with_filter(self, filter: IndexFilter) -> ModelResponse:
"""
Retrieve records from the index that match the given filter.

Args:
filter (IndexFilter): The filter criteria to apply when retrieving records.

Returns:
ModelResponse: Response containing the retrieved records.

Raises:
Exception: If retrieval fails.

Example:
>>> from aixplain.modules.model.index_model import IndexFilter, IndexFilterOperator
>>> my_filter = IndexFilter(field="category", value="world", operator=IndexFilterOperator.EQUALS)
>>> index_model.retrieve_records_with_filter(my_filter)
"""
data = {"action": "retrieve_by_filter", "data": filter.to_dict()}
response = self.run(data=data)
if response.status == "SUCCESS":
return response
raise Exception(f"Failed to retrieve records with filter: {response.error_message}")

def delete_records_by_date(self, date: float) -> ModelResponse:
"""
Delete records from the index that match the given date.

Args:
date (float): The date (as a timestamp) to match records for deletion.

Returns:
ModelResponse: Response containing the result of the deletion operation.

Raises:
Exception: If deletion fails.

Example:
>>> index_model.delete_records_by_date(1717708800)
"""
data = {"action": "delete_by_date", "data": date}
response = self.run(data=data)
if response.status == "SUCCESS":
return response
raise Exception(f"Failed to delete records by date: {response.error_message}")
81 changes: 30 additions & 51 deletions aixplain/modules/model/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,24 @@
from typing import Text, Optional, Union, Dict
from enum import Enum
from pydantic import BaseModel

import json

class AuthenticationSchema(Enum):
BEARER = "BEARER_TOKEN"
OAUTH = "OAUTH"
BEARER_TOKEN = "BEARER_TOKEN"
OAUTH1 = "OAUTH1"
OAUTH2 = "OAUTH2"


API_KEY = "API_KEY"
BASIC = "BASIC"
NO_AUTH = "NO_AUTH"

class BaseAuthenticationParams(BaseModel):
name: Optional[Text] = None
authentication_schema: AuthenticationSchema = AuthenticationSchema.OAUTH2
connector_id: Optional[Text] = None


class BearerAuthenticationParams(BaseAuthenticationParams):
token: Text
authentication_schema: AuthenticationSchema = AuthenticationSchema.BEARER


class OAuthAuthenticationParams(BaseAuthenticationParams):
client_id: Text
client_secret: Text
authentication_schema: AuthenticationSchema = AuthenticationSchema.OAUTH


class OAuth2AuthenticationParams(BaseAuthenticationParams):
authentication_schema: AuthenticationSchema = AuthenticationSchema.OAUTH2


def build_connector_params(**kwargs) -> BaseAuthenticationParams:
name = kwargs.get("name")
token = kwargs.get("token")
client_id = kwargs.get("client_id")
client_secret = kwargs.get("client_secret")
connector_id = kwargs.get("connector_id")
if token:
args = BearerAuthenticationParams(name=name, token=token, connector_id=connector_id)
elif client_id and client_secret:
args = OAuthAuthenticationParams(name=name, client_id=client_id, client_secret=client_secret, connector_id=connector_id)
else:
args = OAuth2AuthenticationParams(name=name, connector_id=connector_id)
return args
return BaseAuthenticationParams(name=name, connector_id=connector_id)


class Integration(Model):
Expand Down Expand Up @@ -94,8 +70,10 @@ def __init__(
)
self.url = config.MODELS_RUN_URL
self.backend_url = config.BACKEND_URL
self.authentication_methods = json.loads([item for item in additional_info['attributes'] if item['name'] == 'auth_schemes'][0]['code'])


def connect(self, args: Optional[BaseAuthenticationParams] = None, **kwargs) -> ModelResponse:
def connect(self, authentication_schema: AuthenticationSchema, args: Optional[BaseAuthenticationParams] = None, data: Optional[Dict] = None, **kwargs) -> ModelResponse:
"""Connect to the integration

Examples:
Expand All @@ -119,29 +97,29 @@ def connect(self, args: Optional[BaseAuthenticationParams] = None, **kwargs) ->
if args is None:
args = build_connector_params(**kwargs)

authentication_schema = args.authentication_schema
if authentication_schema == AuthenticationSchema.BEARER:
if authentication_schema.value not in self.authentication_methods:
raise ValueError(f"Authentication schema {authentication_schema.value} is not supported for this integration. Supported authentication methods: {self.authentication_methods}")

if data is None:
data = {}

if authentication_schema not in [AuthenticationSchema.OAUTH2, AuthenticationSchema.OAUTH1, AuthenticationSchema.NO_AUTH]:
required_params = json.loads([item for item in self.additional_info['attributes'] if item['name'] == authentication_schema.value + "-inputs"][0]['code'])
required_params_names = [param['name'] for param in required_params]
for param in required_params_names:
if param not in data:
if len(required_params_names) == 1:
raise ValueError(f"Parameter '{param}' is required for {self.name} {authentication_schema.value} authentication. Please provide the parameter in the data dictionary.")
else:
raise ValueError(f"Parameters {required_params_names} are required for {self.name} {authentication_schema.value} authentication. Please provide the parameters in the data dictionary.")
return self.run(
{
"name": args.name,
"authScheme": authentication_schema.value,
"data": {
"token": args.token,
},
"data": data,
}
)
elif authentication_schema == AuthenticationSchema.OAUTH:
return self.run(
{
"name": args.name,
"authScheme": authentication_schema.value,
"data": {
"client_id": args.client_id,
"client_secret": args.client_secret,
},
}
)
elif authentication_schema == AuthenticationSchema.OAUTH2:
else:
response = self.run(
{
"name": args.name,
Expand All @@ -154,8 +132,9 @@ def connect(self, args: Optional[BaseAuthenticationParams] = None, **kwargs) ->
)
return response


def __repr__(self):
try:
return f"Integration: {self.name} by {self.supplier['name']} (id={self.id})"
except Exception:
return f"Integration: {self.name} by {self.supplier} (id={self.id})"
return f"Integration: {self.name} by {self.supplier} (id={self.id})"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ aixplain = "aixplain.cli_groups:run_cli"

[project.optional-dependencies]
model-builder = [
"model-interfaces~=0.0.1"
"model-interfaces~=0.0.2"
]
test = [
"pytest>=6.1.0",
Expand Down
94 changes: 94 additions & 0 deletions tests/functional/model/run_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,97 @@ def test_index_model_air_with_splitter(embedding_model, supplier_params):
assert str(response.status) == "SUCCESS"
assert "berlin" in response.data.lower()
index_model.delete()


def _test_records():
from aixplain.modules.model.record import Record
from aixplain.enums import DataType

return [
Record(
value="Artificial intelligence is transforming industries worldwide, from healthcare to finance.",
value_type=DataType.TEXT,
id="doc1",
uri="",
attributes={"category": "technology", "date": 1751464788},
),
Record(
value="The Mona Lisa, painted by Leonardo da Vinci, is one of the most famous artworks in history.",
value_type=DataType.TEXT,
id="doc2",
uri="",
attributes={"category": "art", "date": 1751464790},
),
Record(
value="Machine learning algorithms are being used to predict patient outcomes in hospitals.",
value_type=DataType.TEXT,
id="doc3",
uri="",
attributes={"category": "technology", "date": 1751464795},
),
Record(
value="The Earth orbits the Sun once every 365.25 days, creating the calendar year.",
value_type=DataType.TEXT,
id="doc4",
uri="",
attributes={"category": "science", "date": 1751464798},
),
Record(
value="Quantum computing promises to solve complex problems that are currently intractable for classical computers.",
value_type=DataType.TEXT,
id="doc5",
uri="",
attributes={"category": "technology", "date": 1751464801},
),
]


@pytest.fixture(scope="function")
def setup_index_with_test_records():
from aixplain.factories import IndexFactory
from aixplain.enums import EmbeddingModel
from aixplain.factories.index_factory.utils import AirParams
from uuid import uuid4
import time

# Clean up all existing indexes
for index in IndexFactory.list()["results"]:
index.delete()

params = AirParams(
name=f"Test Index {uuid4()}",
description="Test index for filter/date tests",
embedding_model=EmbeddingModel.OPENAI_ADA002,
)
index_model = IndexFactory.create(params=params)
records = _test_records()

index_model.upsert(records)

yield index_model
index_model.delete()


def test_retrieve_records_with_filter(setup_index_with_test_records):
from aixplain.modules.model.index_model import IndexFilter, IndexFilterOperator

index_model = setup_index_with_test_records
filter_ = IndexFilter(field="category", value="technology", operator=IndexFilterOperator.EQUALS)
response = index_model.retrieve_records_with_filter(filter_)
assert response.status == "SUCCESS"
assert len(response.details) == 3
for item in response.details:
assert item["metadata"]["category"] == "technology"


def test_delete_records_by_date(setup_index_with_test_records):
from aixplain.modules.model.index_model import IndexFilter, IndexFilterOperator

index_model = setup_index_with_test_records
response = index_model.delete_records_by_date(1751464796)
assert response.status == "SUCCESS"
assert response.data == "2" # 2 records should remain
filter_all = IndexFilter(field="date", value=0, operator=IndexFilterOperator.GREATER_THAN)
response = index_model.retrieve_records_with_filter(filter_all)
assert response.status == "SUCCESS"
assert len(response.details) == 2