Investigate vector given as string
From a user report:
I just tried inserting ["0.4", "0.2"...] instead of [0.4, 0.2].. again silly but Weaviate accepted this but was then unable to query the vectors it seemed.
Hey @dirkkul,
I tried to reproduce it, but I Weaviate rejected both of my attempts:
Example 1
qt = client.collections.get("QuickTest")
qt.data.insert(
properties={
"title": "Try Array of strings as a vector"
},
vector=["0.1", "0.2"]
)
Throws the following error:
UnexpectedStatusCodeError: Object was not added! Unexpected status code: 400, with response body: {'code': 400, 'message': 'parsing body body from "" failed, because json: cannot unmarshal string into Go struct field Object.vector of type float32'}.
Example 2
qt = client.collections.get("QuickTest")
qt.data.insert(
properties={
"title": "Try a string with an array text inside"
},
vector="[0.1, 0.2]"
)
Throws the following error:
WeaviateInvalidInputError: Invalid input provided: The vector you supplied was malformatted! Vector: [0.1, 0.2].
Thanks for checking @sebawita - if you have time, could you also try insert_many?
I have investigated the issue on chore/investigate-strings-in-vector and cannot reproduce the exact behaviour quoted in the OP. There is a nuance which is that batching accepts the vector, since it uses pydantic to coerce the list[str] into list[float], but the tests I've added on that branch show that the vector is saved to the DB and is returnable with queries