Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions aixplain/factories/pipeline_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class PipelineFactory:
aixplain_key = config.AIXPLAIN_API_KEY
backend_url = config.BACKEND_URL

@classmethod
def __get_typed_nodes(cls, response: Dict, type: str) -> List[Dict]:
# read "nodes" field from response and return the nodes that are marked by "type": type
return [node for node in response["nodes"] if node["type"].lower() == type.lower()]

@classmethod
def __from_response(cls, response: Dict) -> Pipeline:
"""Converts response Json to 'Pipeline' object
Expand All @@ -57,7 +62,9 @@ def __from_response(cls, response: Dict) -> Pipeline:
"""
if "api_key" not in response:
response["api_key"] = config.TEAM_API_KEY
return Pipeline(response["id"], response["name"], response["api_key"])
input = cls.__get_typed_nodes(response, "input")
output = cls.__get_typed_nodes(response, "output")
return Pipeline(response["id"], response["name"], response["api_key"], input=input, output=output)

@classmethod
def get(cls, pipeline_id: Text, api_key: Optional[Text] = None) -> Pipeline:
Expand All @@ -73,7 +80,9 @@ def get(cls, pipeline_id: Text, api_key: Optional[Text] = None) -> Pipeline:
resp = None
try:
url = urljoin(cls.backend_url, f"sdk/pipelines/{pipeline_id}")
if cls.aixplain_key != "":
if api_key is not None:
headers = {"Authorization": f"Token {api_key}", "Content-Type": "application/json"}
elif cls.aixplain_key != "":
headers = {"x-aixplain-key": f"{cls.aixplain_key}", "Content-Type": "application/json"}
else:
headers = {"Authorization": f"Token {config.TEAM_API_KEY}", "Content-Type": "application/json"}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespaces = true

[project]
name = "aiXplain"
version = "0.2.12"
version = "0.2.13rc2"
description = "aiXplain SDK adds AI functions to software."
readme = "README.md"
requires-python = ">=3.5, <4"
Expand Down