frogml-core 0.0.113__py3-none-any.whl → 0.0.115__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. frogml_core/__init__.py +1 -1
  2. frogml_core/clients/administration/authentication/client.py +2 -2
  3. frogml_core/clients/batch_job_management/client.py +4 -4
  4. frogml_core/clients/build_orchestrator/build_model_request_getter.py +6 -6
  5. frogml_core/clients/build_orchestrator/client.py +12 -12
  6. frogml_core/clients/build_orchestrator/internal_client.py +10 -10
  7. frogml_core/frogml_client/build_api_helpers/build_api_steps.py +3 -3
  8. frogml_core/inner/build_logic/constants/upload_tag.py +7 -7
  9. frogml_core/inner/build_logic/interface/context_interface.py +1 -1
  10. frogml_core/inner/build_logic/phases/phase_010_fetch_model/fetch_strategy_manager/strategy/strategy.py +4 -4
  11. frogml_core/inner/build_logic/phases/phase_010_fetch_model/set_version_step.py +3 -3
  12. frogml_core/inner/build_logic/phases/phase_020_remote_register_frogml_build/start_remote_build_step.py +3 -3
  13. frogml_core/inner/build_logic/phases/phase_020_remote_register_frogml_build/upload_step.py +11 -9
  14. frogml_core/inner/build_logic/tools/ignore_files.py +3 -3
  15. frogml_core/inner/di_configuration/__init__.py +0 -6
  16. frogml_core/model/adapters/__init__.py +1 -1
  17. frogml_core/model/analytics_logging.py +1 -1
  18. frogml_core/model/tools/adapters/input.py +6 -6
  19. frogml_core/model/tools/adapters/output.py +8 -8
  20. frogml_core/model/tools/run_model_locally.py +2 -2
  21. frogml_core/model/utils/feature_utils.py +1 -1
  22. {frogml_core-0.0.113.dist-info → frogml_core-0.0.115.dist-info}/METADATA +1 -1
  23. {frogml_core-0.0.113.dist-info → frogml_core-0.0.115.dist-info}/RECORD +30 -137
  24. frogml_services_mock/mocks/analytics_api.py +6 -6
  25. frogml_services_mock/mocks/ecosystem_service_api.py +2 -2
  26. frogml_services_mock/mocks/frogml_mocks.py +0 -11
  27. frogml_services_mock/services_mock.py +4 -52
  28. frogml_storage/__init__.py +1 -1
  29. frogml_core/clients/prompt_manager/__init__.py +0 -0
  30. frogml_core/clients/prompt_manager/model_descriptor_mapper.py +0 -196
  31. frogml_core/clients/prompt_manager/prompt_manager_client.py +0 -190
  32. frogml_core/clients/prompt_manager/prompt_proto_mapper.py +0 -264
  33. frogml_core/clients/vector_store/__init__.py +0 -2
  34. frogml_core/clients/vector_store/management_client.py +0 -127
  35. frogml_core/clients/vector_store/serving_client.py +0 -157
  36. frogml_core/clients/workspace_manager/__init__.py +0 -1
  37. frogml_core/clients/workspace_manager/client.py +0 -224
  38. frogml_core/llmops/__init__.py +0 -0
  39. frogml_core/llmops/generation/__init__.py +0 -0
  40. frogml_core/llmops/generation/_steaming.py +0 -78
  41. frogml_core/llmops/generation/base.py +0 -5
  42. frogml_core/llmops/generation/chat/__init__.py +0 -0
  43. frogml_core/llmops/generation/chat/openai/LICENSE.txt +0 -201
  44. frogml_core/llmops/generation/chat/openai/types/__init__.py +0 -0
  45. frogml_core/llmops/generation/chat/openai/types/chat/__init__.py +0 -0
  46. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion.py +0 -88
  47. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_assistant_message_param.py +0 -65
  48. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_chunk.py +0 -153
  49. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_content_part_text_param.py +0 -28
  50. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_function_call_option_param.py +0 -25
  51. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_function_message_param.py +0 -33
  52. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_message.py +0 -56
  53. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_message_param.py +0 -34
  54. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_message_tool_call.py +0 -46
  55. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_message_tool_call_param.py +0 -44
  56. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_named_tool_choice_param.py +0 -32
  57. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_role.py +0 -20
  58. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_system_message_param.py +0 -35
  59. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_token_logprob.py +0 -71
  60. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_tool_choice_option_param.py +0 -28
  61. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_tool_message_param.py +0 -31
  62. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_tool_param.py +0 -29
  63. frogml_core/llmops/generation/chat/openai/types/chat/chat_completion_user_message_param.py +0 -35
  64. frogml_core/llmops/generation/chat/openai/types/chat/completion_create_params.py +0 -279
  65. frogml_core/llmops/generation/chat/openai/types/completion_choice.py +0 -47
  66. frogml_core/llmops/generation/chat/openai/types/completion_create_params.py +0 -209
  67. frogml_core/llmops/generation/chat/openai/types/completion_usage.py +0 -30
  68. frogml_core/llmops/generation/chat/openai/types/model.py +0 -35
  69. frogml_core/llmops/generation/chat/openai/types/shared/__init__.py +0 -3
  70. frogml_core/llmops/generation/chat/openai/types/shared/error_object.py +0 -27
  71. frogml_core/llmops/generation/chat/openai/types/shared/function_definition.py +0 -49
  72. frogml_core/llmops/generation/chat/openai/types/shared/function_parameters.py +0 -20
  73. frogml_core/llmops/generation/chat/openai/types/shared_params/__init__.py +0 -2
  74. frogml_core/llmops/generation/chat/openai/types/shared_params/function_definition.py +0 -49
  75. frogml_core/llmops/generation/chat/openai/types/shared_params/function_parameters.py +0 -22
  76. frogml_core/llmops/generation/streaming.py +0 -26
  77. frogml_core/llmops/model/__init__.py +0 -0
  78. frogml_core/llmops/model/descriptor.py +0 -40
  79. frogml_core/llmops/prompt/__init__.py +0 -0
  80. frogml_core/llmops/prompt/base.py +0 -136
  81. frogml_core/llmops/prompt/chat/__init__.py +0 -0
  82. frogml_core/llmops/prompt/chat/message.py +0 -24
  83. frogml_core/llmops/prompt/chat/template.py +0 -113
  84. frogml_core/llmops/prompt/chat/value.py +0 -10
  85. frogml_core/llmops/prompt/manager.py +0 -138
  86. frogml_core/llmops/prompt/template.py +0 -24
  87. frogml_core/llmops/prompt/value.py +0 -14
  88. frogml_core/llmops/provider/__init__.py +0 -0
  89. frogml_core/llmops/provider/chat.py +0 -44
  90. frogml_core/llmops/provider/openai/__init__.py +0 -0
  91. frogml_core/llmops/provider/openai/client.py +0 -126
  92. frogml_core/llmops/provider/openai/provider.py +0 -93
  93. frogml_core/vector_store/__init__.py +0 -4
  94. frogml_core/vector_store/client.py +0 -151
  95. frogml_core/vector_store/collection.py +0 -429
  96. frogml_core/vector_store/filters.py +0 -359
  97. frogml_core/vector_store/inference_client.py +0 -105
  98. frogml_core/vector_store/rest_helpers.py +0 -81
  99. frogml_core/vector_store/utils/__init__.py +0 -0
  100. frogml_core/vector_store/utils/filter_utils.py +0 -23
  101. frogml_core/vector_store/utils/upsert_utils.py +0 -218
  102. frogml_proto/qwak/prompt/v1/prompt/prompt_manager_service_pb2.py +0 -77
  103. frogml_proto/qwak/prompt/v1/prompt/prompt_manager_service_pb2.pyi +0 -417
  104. frogml_proto/qwak/prompt/v1/prompt/prompt_manager_service_pb2_grpc.py +0 -441
  105. frogml_proto/qwak/prompt/v1/prompt/prompt_pb2.py +0 -69
  106. frogml_proto/qwak/prompt/v1/prompt/prompt_pb2.pyi +0 -415
  107. frogml_proto/qwak/prompt/v1/prompt/prompt_pb2_grpc.py +0 -4
  108. frogml_proto/qwak/vectors/v1/collection/collection_pb2.py +0 -46
  109. frogml_proto/qwak/vectors/v1/collection/collection_pb2.pyi +0 -287
  110. frogml_proto/qwak/vectors/v1/collection/collection_pb2_grpc.py +0 -4
  111. frogml_proto/qwak/vectors/v1/collection/collection_service_pb2.py +0 -60
  112. frogml_proto/qwak/vectors/v1/collection/collection_service_pb2.pyi +0 -258
  113. frogml_proto/qwak/vectors/v1/collection/collection_service_pb2_grpc.py +0 -304
  114. frogml_proto/qwak/vectors/v1/collection/event/collection_event_pb2.py +0 -28
  115. frogml_proto/qwak/vectors/v1/collection/event/collection_event_pb2.pyi +0 -41
  116. frogml_proto/qwak/vectors/v1/collection/event/collection_event_pb2_grpc.py +0 -4
  117. frogml_proto/qwak/vectors/v1/filters_pb2.py +0 -52
  118. frogml_proto/qwak/vectors/v1/filters_pb2.pyi +0 -297
  119. frogml_proto/qwak/vectors/v1/filters_pb2_grpc.py +0 -4
  120. frogml_proto/qwak/vectors/v1/vector_pb2.py +0 -38
  121. frogml_proto/qwak/vectors/v1/vector_pb2.pyi +0 -142
  122. frogml_proto/qwak/vectors/v1/vector_pb2_grpc.py +0 -4
  123. frogml_proto/qwak/vectors/v1/vector_service_pb2.py +0 -53
  124. frogml_proto/qwak/vectors/v1/vector_service_pb2.pyi +0 -243
  125. frogml_proto/qwak/vectors/v1/vector_service_pb2_grpc.py +0 -201
  126. frogml_proto/qwak/workspace/workspace_pb2.py +0 -50
  127. frogml_proto/qwak/workspace/workspace_pb2.pyi +0 -331
  128. frogml_proto/qwak/workspace/workspace_pb2_grpc.py +0 -4
  129. frogml_proto/qwak/workspace/workspace_service_pb2.py +0 -84
  130. frogml_proto/qwak/workspace/workspace_service_pb2.pyi +0 -393
  131. frogml_proto/qwak/workspace/workspace_service_pb2_grpc.py +0 -507
  132. frogml_services_mock/mocks/prompt_manager_service.py +0 -281
  133. frogml_services_mock/mocks/vector_serving_api.py +0 -159
  134. frogml_services_mock/mocks/vectors_management_api.py +0 -97
  135. frogml_services_mock/mocks/workspace_manager_service_mock.py +0 -202
  136. /frogml_core/model/adapters/output_adapters/{qwak_with_default_fallback.py → frogml_with_default_fallback.py} +0 -0
  137. {frogml_core-0.0.113.dist-info → frogml_core-0.0.115.dist-info}/WHEEL +0 -0
@@ -1,126 +0,0 @@
1
- import json
2
- import os
3
- from typing import Dict, Iterable, List, Optional, Union
4
- from urllib.parse import urljoin
5
-
6
- import requests
7
- from dacite import Config, from_dict
8
- from requests import Response
9
- from typing_extensions import Literal
10
-
11
- from frogml_core.exceptions.frogml_external_exception import FrogmlExternalException
12
- from frogml_core.llmops.generation._steaming import BaseSSEDecoder # noqa
13
- from frogml_core.llmops.generation.chat.openai.types.chat.chat_completion import (
14
- ChatCompletion,
15
- )
16
- from frogml_core.llmops.generation.chat.openai.types.chat.chat_completion_chunk import (
17
- ChatCompletionChunk,
18
- )
19
- from frogml_core.llmops.generation.chat.openai.types.chat.chat_completion_tool_choice_option_param import (
20
- ChatCompletionToolChoiceOptionParam,
21
- )
22
- from frogml_core.llmops.generation.chat.openai.types.chat.chat_completion_tool_param import (
23
- ChatCompletionToolParam,
24
- )
25
- from frogml_core.llmops.generation.streaming import ChatCompletionStream
26
- from frogml_core.utils.dict_utils import remove_none_value_keys
27
-
28
-
29
- class OpenAIChatCompletionStream(
30
- BaseSSEDecoder[ChatCompletionChunk], ChatCompletionStream
31
- ):
32
- def __init__(self, response: requests.Response):
33
- super().__init__(response=response, parse_to=ChatCompletionChunk)
34
-
35
-
36
- class OpenAIClient:
37
- base_url: str
38
-
39
- def __init__(self):
40
- self.base_url: str = os.environ.get(
41
- "_QWAK_OPEN_AI_BASE_URL", "https://api.openai.com"
42
- )
43
-
44
- def invoke_chat_completion(
45
- self,
46
- api_key: str,
47
- model: str,
48
- messages: List[Dict],
49
- frequency_penalty: Optional[float] = None,
50
- logit_bias: Optional[Dict[str, int]] = None,
51
- logprobs: Optional[bool] = None,
52
- max_tokens: Optional[int] = None,
53
- n: Optional[int] = None,
54
- presence_penalty: Optional[float] = None,
55
- response_format: Literal["text", "json_object"] = None,
56
- seed: Optional[int] = None,
57
- stop: Union[Optional[str], List[str]] = None,
58
- stream: Optional[bool] = False,
59
- temperature: Optional[float] = None,
60
- top_logprobs: Optional[int] = None,
61
- top_p: Optional[float] = None,
62
- user: Optional[str] = None,
63
- tool_choice: Optional[ChatCompletionToolChoiceOptionParam] = None,
64
- tools: Iterable[ChatCompletionToolParam] = None,
65
- extra_headers: Optional[Dict[str, str]] = None,
66
- extra_body: Optional[Dict[str, str]] = None,
67
- timeout_seconds: Optional[float] = None,
68
- ) -> Union[ChatCompletion, ChatCompletionStream]:
69
- url: str = urljoin(self.base_url, "v1/chat/completions")
70
- headers: Dict[str, str] = {
71
- "Content-Type": "application/json",
72
- "Authorization": f"Bearer {api_key}",
73
- }
74
- body = {
75
- "messages": messages,
76
- "model": model,
77
- "frequency_penalty": frequency_penalty,
78
- "logit_bias": logit_bias,
79
- "logprobs": logprobs,
80
- "max_tokens": max_tokens,
81
- "n": n,
82
- "presence_penalty": presence_penalty,
83
- "response_format": {"type": response_format} if response_format else None,
84
- "seed": seed,
85
- "stop": stop,
86
- "temperature": temperature,
87
- "tool_choice": tool_choice if tools else None,
88
- "tools": tools if tools else None,
89
- "top_logprobs": top_logprobs,
90
- "top_p": top_p,
91
- "user": user,
92
- "stream": stream if stream else None,
93
- }
94
- body = remove_none_value_keys(body)
95
-
96
- if extra_headers:
97
- headers.update(extra_headers)
98
-
99
- if extra_body:
100
- body.update(extra_body)
101
-
102
- http_request_timeout_seconds: float = (
103
- timeout_seconds
104
- if timeout_seconds
105
- else float(os.environ.get("_QWAK_OPEN_AI_TIMEOUT_SECONDS", 60.0))
106
- )
107
- response: Response = requests.post(
108
- url=url,
109
- data=json.dumps(body),
110
- headers=headers,
111
- stream=stream,
112
- timeout=http_request_timeout_seconds,
113
- )
114
-
115
- try:
116
- response.raise_for_status()
117
- except requests.exceptions.HTTPError as e:
118
- raise FrogmlExternalException(message=e.response.content.decode())
119
- if stream:
120
- return OpenAIChatCompletionStream(response=response)
121
- else:
122
- return from_dict(
123
- data_class=ChatCompletion,
124
- data=response.json(),
125
- config=Config(check_types=False),
126
- )
@@ -1,93 +0,0 @@
1
- import random
2
- from typing import Dict, List, Optional, Union
3
-
4
- from frogml_core.clients.integration_management.integration_utils import (
5
- IntegrationUtils,
6
- )
7
- from frogml_core.clients.integration_management.openai.openai_system_secret import (
8
- OpenAIApiKeySystemSecret,
9
- )
10
- from frogml_core.exceptions import FrogmlException
11
- from frogml_core.llmops.generation.chat.openai.types.chat.chat_completion import (
12
- ChatCompletion,
13
- )
14
- from frogml_core.llmops.generation.streaming import ChatCompletionStream
15
- from frogml_core.llmops.model.descriptor import OpenAIChat
16
- from frogml_core.llmops.prompt.chat.message import (
17
- AIMessage,
18
- BaseMessage,
19
- HumanMessage,
20
- SystemMessage,
21
- )
22
- from frogml_core.llmops.prompt.chat.value import ChatPromptValue
23
- from frogml_core.llmops.provider.openai.client import OpenAIClient
24
-
25
-
26
- class OpenAIProvider:
27
- client: OpenAIClient
28
-
29
- def __init__(self):
30
- self.client = OpenAIClient()
31
-
32
- def _get_random_openai_api_key(self) -> Optional[str]:
33
- openai_api_keys: List[OpenAIApiKeySystemSecret] = (
34
- IntegrationUtils().get_openai_api_keys()
35
- )
36
- if len(openai_api_keys) == 0:
37
- return None
38
-
39
- return random.choice(openai_api_keys).get_api_key() # nosec
40
-
41
- def _chat_value_to_json(self, chat_prompt_value: ChatPromptValue) -> List[Dict]:
42
- return [self._map_message(m) for m in chat_prompt_value.messages]
43
-
44
- def _map_message(self, message: BaseMessage) -> Dict[str, str]:
45
- role: str
46
- content: str = message.content
47
-
48
- if isinstance(message, AIMessage):
49
- role = "assistant"
50
- elif isinstance(message, SystemMessage):
51
- role = "system"
52
- elif isinstance(message, HumanMessage):
53
- role = "user"
54
- else:
55
- raise FrogmlException(f"Can't handle message of type: {repr(message)}")
56
-
57
- return {"role": role, "content": content}
58
-
59
- def create_chat_completion(
60
- self,
61
- chat_prompt_value: ChatPromptValue,
62
- chat_model_descriptor: OpenAIChat,
63
- stream: bool = False,
64
- ) -> Union[ChatCompletion, ChatCompletionStream]:
65
- openai_api_key: Optional[str] = self._get_random_openai_api_key()
66
- if not openai_api_key:
67
- raise FrogmlException(
68
- "Could not find Open AI integration, Please create one."
69
- )
70
-
71
- d = chat_model_descriptor
72
-
73
- return self.client.invoke_chat_completion(
74
- stream=stream,
75
- api_key=openai_api_key,
76
- model=d.model_id,
77
- messages=self._chat_value_to_json(chat_prompt_value),
78
- frequency_penalty=d.frequency_penalty,
79
- logit_bias=d.logit_bias,
80
- logprobs=d.logprobs,
81
- max_tokens=d.max_tokens,
82
- n=d.n,
83
- presence_penalty=d.presence_penalty,
84
- response_format=d.response_format,
85
- seed=d.seed,
86
- stop=d.stop,
87
- temperature=d.temperature,
88
- top_logprobs=d.top_logprobs,
89
- top_p=d.top_p,
90
- user=d.user,
91
- tool_choice=d.tool_choice,
92
- tools=d.tools,
93
- )
@@ -1,4 +0,0 @@
1
- from .client import VectorStoreClient
2
- from .collection import Collection
3
-
4
- __all__ = ["VectorStoreClient", "Collection"]
@@ -1,151 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Dict, List, Optional
4
-
5
- from typeguard import typechecked
6
-
7
- from frogml_proto.qwak.vectors.v1.collection.collection_pb2 import (
8
- VectorCollectionDefinition,
9
- VectorCollectionMetric,
10
- )
11
- from frogml_core.clients.vector_store import VectorManagementClient, VectorServingClient
12
- from frogml_core.exceptions import FrogmlException
13
- from frogml_core.vector_store.collection import Collection
14
-
15
-
16
- class VectorStoreClient:
17
- """
18
- The `VectorStoreClient` class is designed to interact with Qwak's vector store service. A vector store is a
19
- specialized storage service optimized for storing and querying high-dimensional vectors. These vectors can be
20
- representations extracted from images, text, or any other type of data.
21
- Vector stores are often used in machine learning applications for operations such as nearest neighbor searches,
22
- similarity measures, and clustering.
23
- """
24
-
25
- _vector_management_client: VectorManagementClient
26
-
27
- _metric_dict: Dict[str, VectorCollectionMetric] = {
28
- "l2_squared": VectorCollectionMetric.COLLECTION_METRIC_L2_SQUARED,
29
- "cosine": VectorCollectionMetric.COLLECTION_METRIC_COSINE,
30
- "dot_product": VectorCollectionMetric.COLLECTION_METRIC_DOT_PRODUCT,
31
- "l1": VectorCollectionMetric.COLLECTION_METRIC_L1,
32
- "hamming": VectorCollectionMetric.COLLECTION_METRIC_HAMMING,
33
- }
34
-
35
- def __init__(self, edge_services_url: Optional[str] = None):
36
- """
37
- Initializes a `VectorStoreClient` client object to interact with Qwak's vector store service
38
- """
39
- self._vector_management_client = VectorManagementClient()
40
- self._vector_serving_client = VectorServingClient(
41
- edge_services_url=edge_services_url
42
- )
43
-
44
- @typechecked
45
- def create_collection(
46
- self,
47
- name: str,
48
- dimension: int,
49
- description: str = None,
50
- metric: str = "l2_squared",
51
- vectorizer: Optional[str] = None,
52
- multi_tenant: bool = False,
53
- ) -> Collection:
54
- """
55
- Creates a new collection with the given name and dimension.
56
- Each collection in the vector store can be thought of as a table or a namespace that holds vectors of a
57
- particular dimension. For example, you may have a collection named "image_embeddings" where each vector is of
58
- dimension 512, representing an embedding of an image.
59
-
60
- Parameters:
61
- name (str): The name of the collection to create.
62
- dimension (int): The dimension of the vectors in the collection.
63
- description (str, optional): A human-readable description of the collection.
64
- metric (int): The distance metric used by the collection when executing similarity search
65
- vectorizer (str): an optional Qwak model used for vector embedding in case natural input is provided
66
- multi_tenant (bool): Whether this collection has multitenancy. defaults to False and cannot be changed
67
- after the collection is created
68
-
69
- Returns:
70
- Collection: The Collection object which is used to interact with the vector store.
71
-
72
- Raises:
73
- QwakException: if any of the collection creation parameters are invalid
74
- """
75
- proto_definition = self._vector_management_client.create_collection(
76
- name=name,
77
- description=description,
78
- dimension=dimension,
79
- metric=self._metrics_mapper(metric),
80
- vectorizer=vectorizer,
81
- multi_tenant=multi_tenant,
82
- ).definition
83
-
84
- return self._collection_from_definition(proto_definition)
85
-
86
- @typechecked
87
- def delete_collection(self, name: str) -> None:
88
- """
89
- Deletes a collection with the given name.
90
-
91
- Parameters:
92
- name (str): The name of the collection to delete.
93
-
94
- Raises:
95
- QwakException: in case the deletion failed for any reason
96
- """
97
- self._vector_management_client.delete_collection_by_name(name=name)
98
-
99
- @typechecked
100
- def get_collection_by_name(self, name: str) -> Collection:
101
- """
102
- Fetches a collection by its name.
103
-
104
- Parameters:
105
- name (str): The name of the collection to fetch.
106
-
107
- Returns:
108
- collection: a Collection object
109
-
110
- Raises:
111
- QwakException: in case the collection doesn't exist
112
- """
113
- proto_definition = self._vector_management_client.get_collection_by_name(
114
- name
115
- ).definition
116
- return self._collection_from_definition(proto_definition)
117
-
118
- def list_collections(self) -> List[Collection]:
119
- """
120
- Lists all available collections in the current Qwak account
121
-
122
- Returns:
123
- list: A list of Collection objects.
124
- """
125
- proto_definitions = self._vector_management_client.list_collections()
126
- return [
127
- self._collection_from_definition(collection.definition)
128
- for collection in proto_definitions
129
- ]
130
-
131
- def _collection_from_definition(
132
- self, collection_definition: VectorCollectionDefinition
133
- ):
134
- return Collection(
135
- id=collection_definition.id,
136
- name=collection_definition.collection_spec.name,
137
- metric=collection_definition.collection_spec.metric,
138
- dimension=collection_definition.collection_spec.dimension,
139
- description=collection_definition.collection_spec.description,
140
- vectorizer=collection_definition.collection_spec.vectorizer.qwak_model_name,
141
- vector_serving_client=self._vector_serving_client,
142
- muli_tenant=collection_definition.collection_spec.multi_tenancy_enabled,
143
- )
144
-
145
- def _metrics_mapper(self, metric: str) -> VectorCollectionMetric:
146
- if metric in self._metric_dict:
147
- return self._metric_dict[metric]
148
-
149
- raise FrogmlException(
150
- f"Unsupported metric type '{metric}'. Currently supported metrics are {list(self._metric_dict.keys())}"
151
- )