Skip to content

Commit db60ce1

Browse files
committed
RDoc-3621 Add missing embeddings_max_concurrent_batches parameter
1 parent a1b1f07 commit db60ce1

10 files changed

Lines changed: 66 additions & 27 deletions

ravendb/documents/operations/ai/abstract_ai_settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44

55
class AbstractAiSettings(ABC):
6-
def __init__(self):
7-
self.embeddings_max_concurrent_batches = None
6+
def __init__(self, embeddings_max_concurrent_batches: int = None):
7+
self.embeddings_max_concurrent_batches = embeddings_max_concurrent_batches
88

99
@classmethod
1010
@abstractmethod

ravendb/documents/operations/ai/azure_open_ai_settings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ def __init__(
1212
deployment_name: str = None,
1313
dimensions: int = None,
1414
temperature: float = None,
15+
embeddings_max_concurrent_batches: int = None,
1516
):
16-
super().__init__(api_key, endpoint, model, dimensions, temperature)
17+
super().__init__(api_key, endpoint, model, dimensions, temperature, embeddings_max_concurrent_batches)
1718
if deployment_name is None:
1819
raise ValueError("deployment_name cannot be None")
1920
self.deployment_name = deployment_name
@@ -27,6 +28,9 @@ def from_json(cls, json_dict: Dict[str, Any]) -> "AzureOpenAiSettings":
2728
dimensions=json_dict["Dimensions"] if "Dimensions" in json_dict else None,
2829
temperature=json_dict["Temperature"] if "Temperature" in json_dict else None,
2930
deployment_name=json_dict["DeploymentName"] if "DeploymentName" in json_dict else None,
31+
embeddings_max_concurrent_batches=(
32+
json_dict["EmbeddingsMaxConcurrentBatches"] if "EmbeddingsMaxConcurrentBatches" in json_dict else None
33+
),
3034
)
3135

3236
def to_json(self) -> Dict[str, Any]:
@@ -37,4 +41,5 @@ def to_json(self) -> Dict[str, Any]:
3741
"Dimensions": self.dimensions,
3842
"Temperature": self.temperature,
3943
"DeploymentName": self.deployment_name,
44+
"EmbeddingsMaxConcurrentBatches": self.embeddings_max_concurrent_batches,
4045
}

ravendb/documents/operations/ai/embedded_settings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55

66
class EmbeddedSettings(AbstractAiSettings):
7-
def __init__(self):
8-
super().__init__()
7+
def __init__(self, embeddings_max_concurrent_batches: int = None):
8+
super().__init__(embeddings_max_concurrent_batches)
99

1010
@classmethod
1111
def from_json(cls, json_dict: Dict[str, Any]) -> "EmbeddedSettings":
12-
return cls()
12+
return cls(
13+
embeddings_max_concurrent_batches=json_dict.get("EmbeddingsMaxConcurrentBatches") if json_dict.get("EmbeddingsMaxConcurrentBatches") else None,
14+
)
1315

1416
def to_json(self) -> Dict[str, Any]:
1517
return {"EmbeddingsMaxConcurrentBatches": self.embeddings_max_concurrent_batches}

ravendb/documents/operations/ai/google_settings.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ class GoogleAiVersion(Enum):
1111

1212
class GoogleSettings(AbstractAiSettings):
1313
def __init__(
14-
self, model: str = None, api_key: str = None, ai_version: GoogleAiVersion = None, dimensions: int = None
14+
self,
15+
model: str = None,
16+
api_key: str = None,
17+
ai_version: GoogleAiVersion = None,
18+
dimensions: int = None,
19+
embeddings_max_concurrent_batches: int = None,
1520
):
16-
super().__init__()
21+
super().__init__(embeddings_max_concurrent_batches)
1722
self.model = model
1823
self.api_key = api_key
1924
self.ai_version = ai_version
@@ -22,10 +27,13 @@ def __init__(
2227
@classmethod
2328
def from_json(cls, json_dict: Dict[str, Any]) -> "GoogleSettings":
2429
return cls(
25-
model=json_dict["Model"],
26-
api_key=json_dict["ApiKey"],
27-
ai_version=GoogleAiVersion(json_dict["AiVersion"]),
28-
dimensions=json_dict["Dimensions"],
30+
model=json_dict["Model"] if "Model" in json_dict else None,
31+
api_key=json_dict["ApiKey"] if "ApiKey" in json_dict else None,
32+
ai_version=GoogleAiVersion(json_dict["AiVersion"]) if "AiVersion" in json_dict else None,
33+
dimensions=json_dict["Dimensions"] if "Dimensions" in json_dict else None,
34+
embeddings_max_concurrent_batches=(
35+
json_dict["EmbeddingsMaxConcurrentBatches"] if "EmbeddingsMaxConcurrentBatches" in json_dict else None
36+
),
2937
)
3038

3139
def to_json(self) -> Dict[str, Any]:

ravendb/documents/operations/ai/hugging_face_settings.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@
44

55

66
class HuggingFaceSettings(AbstractAiSettings):
7-
def __init__(self, api_key: str = None, model: str = None, endpoint: str = None):
8-
super().__init__()
7+
def __init__(
8+
self,
9+
api_key: str = None,
10+
model: str = None,
11+
endpoint: str = None,
12+
embeddings_max_concurrent_batches: int = None,
13+
):
14+
super().__init__(embeddings_max_concurrent_batches)
915
self.api_key = api_key
1016
self.model = model
1117
self.endpoint = endpoint
1218

1319
@classmethod
1420
def from_json(cls, json_dict: Dict[str, Any]) -> "HuggingFaceSettings":
1521
return cls(
16-
api_key=json_dict["ApiKey"],
17-
model=json_dict["Model"],
18-
endpoint=json_dict["Endpoint"],
22+
api_key=json_dict["ApiKey"] if "ApiKey" in json_dict else None,
23+
model=json_dict["Model"] if "Model" in json_dict else None,
24+
endpoint=json_dict["Endpoint"] if "Endpoint" in json_dict else None,
25+
embeddings_max_concurrent_batches=(
26+
json_dict["EmbeddingsMaxConcurrentBatches"] if "EmbeddingsMaxConcurrentBatches" in json_dict else None
27+
),
1928
)
2029

2130
def to_json(self) -> Dict[str, Any]:

ravendb/documents/operations/ai/mistral_ai_settings.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@
44

55

66
class MistralAiSettings(AbstractAiSettings):
7-
def __init__(self, api_key: str = None, model: str = None, endpoint: str = None):
8-
super().__init__()
7+
def __init__(
8+
self,
9+
api_key: str = None,
10+
model: str = None,
11+
endpoint: str = None,
12+
embeddings_max_concurrent_batches: int = None,
13+
):
14+
super().__init__(embeddings_max_concurrent_batches)
915
self.api_key = api_key
1016
self.model = model
1117
self.endpoint = endpoint
1218

1319
@classmethod
1420
def from_json(cls, json_dict: Dict[str, Any]) -> "MistralAiSettings":
1521
return cls(
16-
api_key=json_dict["ApiKey"],
17-
model=json_dict["Model"],
18-
endpoint=json_dict["Endpoint"],
22+
api_key=json_dict["ApiKey"] if "ApiKey" in json_dict else None,
23+
model=json_dict["Model"] if "Model" in json_dict else None,
24+
endpoint=json_dict["Endpoint"] if "Endpoint" in json_dict else None,
25+
embeddings_max_concurrent_batches=(
26+
json_dict["EmbeddingsMaxConcurrentBatches"] if "EmbeddingsMaxConcurrentBatches" in json_dict else None
27+
),
1928
)
2029

2130
def to_json(self) -> Dict[str, Any]:

ravendb/documents/operations/ai/ollama_settings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ def __init__(
1212
temperature: float = None,
1313
embeddings_max_concurrent_batches: int = None,
1414
):
15-
super().__init__()
15+
super().__init__(embeddings_max_concurrent_batches)
1616
self.uri = uri
1717
self.model = model
1818
self.think = think
1919
self.temperature = temperature
20-
self.embeddings_max_concurrent_batches = embeddings_max_concurrent_batches
2120

2221
@classmethod
2322
def from_json(cls, json_dict: Dict[str, Any]) -> "OllamaSettings":

ravendb/documents/operations/ai/open_ai_base_settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ def __init__(
1111
model: str = None,
1212
dimensions: int = None,
1313
temperature: float = None,
14+
embeddings_max_concurrent_batches: int = None,
1415
):
15-
super().__init__()
16+
super().__init__(embeddings_max_concurrent_batches)
1617
self.api_key = api_key
1718
self.endpoint = endpoint
1819
self.model = model

ravendb/documents/operations/ai/open_ai_settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ def __init__(
1313
project_id: str = None,
1414
dimensions: int = None,
1515
temperature: float = None,
16+
embeddings_max_concurrent_batches: int = None,
1617
):
17-
super().__init__(api_key, endpoint, model, dimensions, temperature)
18+
super().__init__(api_key, endpoint, model, dimensions, temperature, embeddings_max_concurrent_batches)
1819
self.organization_id = organization_id
1920
self.project_id = project_id
2021

@@ -28,6 +29,9 @@ def from_json(cls, json_dict: Dict[str, Any]) -> "OpenAiSettings":
2829
temperature=json_dict["Temperature"] if "Temperature" in json_dict else None,
2930
organization_id=json_dict["OrganizationId"] if "OrganizationId" in json_dict else None,
3031
project_id=json_dict["ProjectId"] if "ProjectId" in json_dict else None,
32+
embeddings_max_concurrent_batches=(
33+
json_dict["EmbeddingsMaxConcurrentBatches"] if "EmbeddingsMaxConcurrentBatches" in json_dict else None
34+
),
3135
)
3236

3337
def to_json(self) -> Dict[str, Any]:

ravendb/documents/operations/ai/vertex_settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def __init__(
1616
google_credentials_json: Optional[str] = None,
1717
location: Optional[str] = None,
1818
ai_version: Optional[VertexAIVersion] = None,
19+
embeddings_max_concurrent_batches: Optional[int] = None,
1920
):
20-
super().__init__()
21+
super().__init__(embeddings_max_concurrent_batches)
2122
self.model = model
2223
self.google_credentials_json = google_credentials_json
2324
self.location = location
@@ -30,6 +31,7 @@ def from_json(cls, json_dict: Dict[str, Any]) -> "VertexSettings":
3031
google_credentials_json=json_dict.get("GoogleCredentialsJson"),
3132
location=json_dict.get("Location"),
3233
ai_version=VertexAIVersion(json_dict["AiVersion"]) if json_dict.get("AiVersion") else None,
34+
embeddings_max_concurrent_batches=json_dict.get("EmbeddingsMaxConcurrentBatches") if json_dict.get("EmbeddingsMaxConcurrentBatches") else None,
3335
)
3436

3537
def to_json(self) -> Dict[str, Any]:

0 commit comments

Comments
 (0)