Releases: weaviate/weaviate-python-client
v3.2.0
Fixes/updates in weaviate.wcs.WCS class:
- Fixed progress bar for
weaviate.wcs.WCS.create, it is being updated in Notebooks too, instead of printing each iteration on new line. - Method
weaviate.wcs.WCS.createnow prints the creation status above the bar.
Updates in weaviate.gql sub-package:
- New key-value
autocorrect: <bool>introduced for theweaviate.gql.filter.NearTextandweaviate.gql.filter.Askfilters.
Theautocorrectis enabled only if Weaviate server has thetext-spellcheckmodule enabled. IfautocorrectisTruethe query is corrected before the query is made. Usage example:
# with 'nearText' filter
client.query\
.get('Article', ['title', 'author'])\
.near_text(
{
'concepts': ['Ecconomy'],
'autocorrect': True
}
)
# the concept should be corrected to 'Economy'
# with 'ask' filter
client.query\
.get('Article', ['title', 'author'])\
.with_ask(
{
'question': 'When was the last financial crysis?',
'autocorrect': True
}
)
# the question should be corrected to 'When was the last financial crisis?'- New method
weaviate.gql.get.GetBuilder.with_additionalis added to GET the_additionalproperties. Usage example:
# single additional property with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
id
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional('id']) # argument as `str`# multiple additional property with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
id
certainty
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional(['id', 'certainty']) # argument as `List[str]`# additional properties as clause with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
classification {
basedOn
classifiedFields
completed
id
scope
}
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional(
{
'classification' : ['basedOn', 'classifiedFields', 'completed', 'id']
}
) # argument as `dict[str, List[str]]`
# or with this GraphQL query
'''
{
Get {
Article {
title
author
_additional {
classification {
completed
}
}
}
}
}
'''
client.query\
.get('Article', ['title', 'author'])\
.with_additional(
{
'classification' : 'completed'
}
) # argument as `Dict[str, str]`Consider the following GraphQL clause:
'''
{
Get {
Article {
title
author
_additional {
token (
properties: ["content"]
limit: 10
certainty: 0.8
) {
certainty
endPosition
entity
property
startPosition
word
}
}
}
}
}
'''
# Then the python translation of this is the following:
clause = {
'token': [ # if only one, can be passes as `str`
'certainty',
'endPosition',
'entity',
'property',
'startPosition',
'word',
]
}
settings = {
'properties': ["content"], # is required
'limit': 10, # optional, int
'certainty': 0.8 # optional, float
}
client.query\
.get('Article', ['title', 'author'])\
.with_additional(
(clause, settings)
) # argument as `Tuple[Dict[str, List[str]], Dict[str, Any]]`If the desired clause does not match any example above, then the clause can always be
converted to string before passing it to the .with_additional() method.
v3.1.1
Fixes in WCS class:
- Make
WCS’s methods’ argumentcluster_namecase insensitive (lowercased inside the method) to match Weaviate Cloud Service’ naming convention, this fixes the error when Weaviate Cloud Service lowercases thecluster_namebut the users are not aware of this and get the exceptionKeyError.
v3.1.0
-
New
weaviate.batch.Batchmethods:weaviate.batch.Batch.pop_object/weaviate.batch.Batch.pop_referenceto remove and return an added object/reference from theweaviate.batch.Batchat positionindex(by default-1).weaviate.batch.Batch.empty_objects/weaviate.batch.Batch.empty_referencesto remove all the existing objects/references from theweaviate.batch.Batchinstance.weaviate.batch.Batch.is_empty_objects/weaviate.batch.Batch.is_empty_referencesto check there are any objects/reference in theweaviate.batch.Batchinstance.
-
Fixes in
weaviate.wcs.WCSclass:- Authentication only with
weaviate.auth.AuthClientPassword. - The
weaviate.wcs.WCS.createargumentmoduleis renamed tomodulesand can also be a list of modules to enable for the WCS cluster. The argument can be used on the PROD WCS too. - The
weaviate.wcs.WCS.get_cluster_configdoes not raise an exception if the cluster does not exist but returns a empty configuration. - The
weaviate.wcs.WCS.delete_clusterdoes not raise an exception if the cluster does not exist.
- Authentication only with
-
Add
phoneNumberto the Weaviate's primitive types. Thanks to GitHub user @cdpierse. -
Bug fix in
weaviate.connect.Connection. -
Fix
ConnectionErrorhandling. -
Optimization in
weaviate.batch.requestsandweaviate.connect.connection.
v3.0.0
weaviate.toolsmodule is REMOVED.Batcherclass is REMOVED.WCSclass is moved from theweaviate.toolsto the new moduleweaviate.wcsweaviate.tools.generate_uuidis REMOVED.
weaviate.util.generate_uuid5is ADDED.- New
weaviate.batch.Batchclass implementation to replace the old one. This implementation uses theBatchRequest
objects under the hood, which means that there is no need to createBatchRequest's anymore. This new class implementation
allows 3 different batch creations methods: manual, auto-create and auto-create with dynamic batching.
See theweaviate.batch.Batchdocumentation for more information. BatchRequestclasses (ObjectsBatchRequestandReferenceBatchRequest) are hidden from the user and should not be
used anymore. This is due to the newweaviate.batch.Batchclass implementation.- New
weaviate.schema.Schemafield is ADDED,"shardingConfig". It can bu used with Weaviate version >= 1.6.0. - New method
weaviate.schema.Schema.update_configused to update mutable schema configuration (likeefConstruction, ...).
Weaviate python client compatible with Weaviate v1.4.x
Changelog: weaviate-python-client v2.5.x
The new version is compatible with Weaviate v1.4.0.
weaviate.gql.get.GetBuilder
- New method
with_near_image(content: dict, encode: bool = True)is added for the GET query. E.g.:
content = { "image": "IMAGE_PATH/image.png", "certainty": 0.7, } client.query.get("Article", "coverImage").with_near_image(content=content, encode=True).do()
weaviate.util
- New function
image_encoder_b64to encode a image to base64, the argument is the image path OR the file object in"br"mode.
weaviate.util.image_encoder_b64(
image_or_image_path: Union[str, BufferedReader]
) -> str- New function
image_decoder_b64to decode a image from base64 to bytes stream, the argument is the base64 encoded image string.
weaviate.util.image_decoder_b64(
encoded_image: str
) -> bytesNew features for QnA module and WCS cluster creation
Changelog: weaviate-python-client v2.4.x
The new version is compatible with Weaviate v1.3.0.
- New method
with_askis added for the GET query. E.g.:
ask = { "question": "Who is the king of the Netherlands?", "certainty": 0.7, "properties": ["summary"] } client.query.get("Article", ["title", "_additional {hasAnswer certainty property result startPosition endPosition}"]).with_ask(ask).do()
- New
with_authargument forWCS.createthat enables/disables the authentication of the to be created Weaviate instance.
WCS.create(self,
cluster_name: str=None,
cluster_type: str='sandbox',
with_auth: bool=False, # <- NEW
module: Optional[Union[str, dict]]=None,
config: dict=None,
wait_for_completion: bool=True
) -> strNew features for WCS and Batcher, Removal of RDF
Changelog: weaviate-python-client v2.3.x
- Bug fixes.
- Fixes for some functions/methods docstrings.
- Updated dependences to newer versions.
weaviate.rdf
weaviate.rdf was removed.
weaviate.tools
-
ADDED
Batcher.addmethod to add either Data Objects or References, based on thekwargsvalues. -
WCS.createhas a new argumentmoduleused to specify the module the weaviate should use. It is supported only for the DEV environment at the moment. -
WCS.createshows a progress bar ifwait_for_complitionis set to True.
v2.2.0
Changelog: weaviate-python-client v2.2.x
weaviate.gql
- ADDED
NearObjectfilter. - ADDED GetBuilder.
with_near_object(content: dict)method.
weaviate.tools
- ADDED new Object
WCSto create/delete WCS clusters from python.WCS(auth_client_secret: AuthCredentials, dev: bool=False)
devis for development URL.WCS.create(cluster_name: str=None, cluster_type: str='sandbox', config: dict=None, wait_for_completion: bool=True) -> str:
Create a cluster. Returns the cluster URL.WCS.is_ready(self, cluster_name: str) -> bool:
Check if cluster is created and ready to use.WCS.get_clusters(self, email: str) -> Optional[List[str]]:
Lists all weaviate clusters registerd with theemail.WCS.get_cluster_config(self, cluster_name: str) -> dict:
Get details of a cluster.WCS.delete(self, cluster_name: str) -> None:
Delete the WCS instance.
v2.1.0
Changelog: weaviate-python-client v2.1.x
__version__global variable is introduced.
weaviate.util
- get_valid_uuid(...) raises
ValueErrorinstead of returningNone. - get_vector(vector: Sequence) -> list; is ADDED.
Get weaviate compatible format of the embedding vector. - get_uuid_from_weaviate_url is REMOVED because get_valid_uuid implements it.
- _get_valid_timeout_config(timeout_config: Union[Tuple[int, int], List[int]]) is ADDED.
Validate and return TimeOut configuration.
weaviate.client_config
- ClientConfig class is REMOVED.
weaviate.client
- Client._init_(..., client_config: ClientConfig=None) -> Client._init_(..., timeout_config: Optional[Tuple[int, int]]=None)
Due to removal of ClientConfig. - ADDED setter/getter for Client.timeout_config.
weaviate.data.references
- _validate_and_get_uuid() is REMOVED.
weaviate.data
- DataObject.create(..., vector_weights: dict[str]=None) -> DataObject.create(..., vector: Sequence=None).
- DataObject.merge(...) -> DataObject.update(..., vector: Sequence=None).
- DataObject.update(...) -> DataObject.replace(..., vector: Sequence=None).
- DataObject.validate(...) -> DataObject.validate(..., vector: Sequence=None).
- DataObject.get(...) -> DataObject.get(..., uuid: str=None).
Nowgetcan act as DataObject.get_by_id(...) too. - DataObject._get_object_response() is REMOVED.
weaviate.connect
- ADDED setter/getter for Connection.timeout_config.
weaviate.batch
- Batch.add_references() is REMOVED.
- BatchRequest._len_() is ADDED.
- BatchRequest.add() is ADDED.
- ReferenceBatchRequest.add_reference() is REMOVED.
- ObjectsBatchRequest.add(...) -> ObjectsBatchRequest.add(..., vector: Sequence=None)
- ObjectsBatchRequest.add_object() is REMOVED.
weaviate python client compatible with weaviate v1.x.x
Changelog: weaviate-python-client v2.0.x
weaviate.batch
-
Batch.create_things() -> Batch.create_objects() (or Batch.create() )
Due to removal of semantic kind (“things/actions”). -
Batch.create_actions() -> Batch.create_objects() (or Batch.create() )
Due to removal of semantic kind (“things/actions”). -
Batch.add_reference() is DEPRECATED -> Batch.create_references() (or Batch.create())
Deprecated to make the name consistent with object creation method. -
Batch.create() ADDED
This method creates eitherobjectsorreferences. -
ReferenceBatchRequest.get_batch_size() REMOVED
Uselen(<ReferenceBatchRequest>). -
ReferenceBatchRequest.get_reference() DEPRECATED -> ReferenceBatchRequest.add()
Due to redundancy on name level. -
ActionsBatchReference -> ObjectsBatchRequest
Due to removal of semantic kind (“things/actions”). -
ThingsBatchReference -> ObjectsBatchRequest
Due to removal of semantic kind (“things/actions”). -
ObjectsBatchRequest.get_objects() DEPRECATED -> ObjectsBatchRequest.add()
Due to redundancy on name level.
weaviate.classification
-
Classification.schedule.with_settings() ADDED
Set additional settings for your classification. -
SOURCE_WHERE_FILTER, TRAINING_SET_WHERE_FILTER, TARGET_WHERE_FILTER global variables were REMOVED.
These global variables were not used anywhere.
weaviate.data.references
-
Reference.delete(..., from_semantic_type, to_semantic_type) arguments were REMOVED.
Due to removal of semantic kind (“things/actions”). -
Reference.update(..., from_semantic_type, to_semantic_type) arguments were REMOVED.
Due to removal of semantic kind (“things/actions”). -
Reference.add(..., from_semantic_type, to_semantic_type) arguments were REMOVED.
Due to removal of semantic kind (“things/actions”).
weaviate.data
-
DataObject.create(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
DataObject.merge(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
DataObject.update(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
DataObject.get_by_id(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
DataObject.get_by_id(..., underscore_properties) -> DataObject.get_by_id(..., additional_properties).
All underscore properties are now clustered into a single fieldadditional. -
DataObject.get(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
DataObject.get(..., underscore_properties) -> DataObject.get(..., additional_properties).
All underscore properties are now clustered into a single fieldadditional. -
DataObject.delete(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
DataObject.exists(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
DataObject.validate(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”).
weaviate.gql
-
Query.METHOD .thing(...).with_XXX() -> Query.METHOD(...).with_XXX()
Due to removal of semantic kind (“things/actions”). -
Query.METHOD .action(...).with_XXX() -> Query.METHOD(...).with_XXX()
Due to removal of semantic kind (“things/actions”). -
build.Builder -> get.GetBuilder
The module and the class was renamed to reflect the GraphQL functionality. -
get.GetBuilder.with_explore() -> get.GetBuilder.with_near_text() [this means that it can be accessed as Query.get(...).with_near_text()]
Due to the renaming of explore to nearText. -
get.GetBuilder.with_near_vector() is ADDED [this means that it can be accessed as Query.get(...).with_near_vector()]
Due to the addition of a new method nearVector. -
filter.Explore -> filter.NearText
Due to the renaming of explore to nearText. -
filter.NearVector is ADDED
Due to the addition of a new method nearVector.
weaviate.schema.properties
- Property.create(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”).
weaviate.schema
-
Schema.create_class(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
Schema.delete_class(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”).
weaviate.tools
-
Batcher.add_data_object(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
Batcher.add_reference(..., from_semantic_type, to_semantic_type) arguments were REMOVED.
Due to removal of semantic kind (“things/actions”). -
Batcher.add_reference(from_thing_class_name, from_thing_uuid, to_thing_uuid, ...) -> Batcher.add_reference(from_object_class_name, from_object_uuid, to_object_uuid, ...).
Due to removal of semantic kind (“things/actions”).
weaviate.exceptions
- ThingAlreadyExistsException -> ObjectAlreadyExistsException.
Due to removal of semantic kind (“things/actions”).
weaviate.util
-
generate_local_beacon(..., semantic_type) argument was REMOVED.
Due to removal of semantic kind (“things/actions”). -
is_weaviate_entity_url -> is_weaviate_object_url.
Due to removal of semantic kind (“things/actions”). -
ParsedUUID was REMOVED.
Was used only to check if UUID is valid and return it, now theget_valid_uuidcan be used instead -
is_semantic_type was REMOVED.
Due to removal of semantic kind (“things/actions”). -
get_valid_uuid was ADDED.
Replacement for the ParsedUUID class.