Comments (4)
Thanks @ethagnawl and @jerinpetergeorge! Pushed a fix in the commit above.
from pgvector-python.
Thanks @ethagnawl and @jerinpetergeorge! Pushed a fix in the commit above.
Unfortunately, In my testing, a couple of things were failing.
- Admin wasn't working at all
- Updating the data via Django admin wasn't working
These two issues have been taken care of by #22
from pgvector-python.
It seems to be the package is not supported via forms and templates. The issue can be reproduced with the below setup.
# models.py
from pgvector.django import VectorField
class Vector(models.Model):
test = VectorField(dimensions=3)
def __str__(self):
return str(self.test)
# forms.py
from django import forms
class VectorForm(forms.ModelForm):
class Meta:
model = Vector
fields = ["test"]
Execution
vf = VectorForm(data={"test":[1,2,3]})
vf.is_valid()
Traceback
ValueError Traceback (most recent call last)
Cell In[3], line 1
----> 1 vf.is_valid()
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/forms.py:201, in BaseForm.is_valid(self)
199 def is_valid(self):
200 """Return True if the form has no errors, or False otherwise."""
--> 201 return self.is_bound and not self.errors
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/forms.py:196, in BaseForm.errors(self)
194 """Return an ErrorDict for the data provided for the form."""
195 if self._errors is None:
--> 196 self.full_clean()
197 return self._errors
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/forms.py:435, in BaseForm.full_clean(self)
433 self._clean_fields()
434 self._clean_form()
--> 435 self._post_clean()
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/models.py:486, in BaseModelForm._post_clean(self)
483 self._update_errors(e)
485 try:
--> 486 self.instance.full_clean(exclude=exclude, validate_unique=False)
487 except ValidationError as e:
488 self._update_errors(e)
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/base.py:1470, in Model.full_clean(self, exclude, validate_unique, validate_constraints)
1467 exclude = set(exclude)
1469 try:
-> 1470 self.clean_fields(exclude=exclude)
1471 except ValidationError as e:
1472 errors = e.update_error_dict(errors)
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/base.py:1522, in Model.clean_fields(self, exclude)
1520 continue
1521 try:
-> 1522 setattr(self, f.attname, f.clean(raw_value, self))
1523 except ValidationError as e:
1524 errors[f.name] = e.error_list
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/fields/__init__.py:777, in Field.clean(self, value, model_instance)
771 """
772 Convert the value's type and run validation. Validation errors
773 from to_python() and validate() are propagated. Return the correct
774 value if no error is raised.
775 """
776 value = self.to_python(value)
--> 777 self.validate(value, model_instance)
778 self.run_validators(value)
779 return value
File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/fields/__init__.py:767, in Field.validate(self, value, model_instance)
764 if value is None and not self.null:
765 raise exceptions.ValidationError(self.error_messages["null"], code="null")
--> 767 if not self.blank and value in self.empty_values:
768 raise exceptions.ValidationError(self.error_messages["blank"], code="blank")
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
from pgvector-python.
That was fast, @ankane. Thanks!
from pgvector-python.
Related Issues (20)
- How insert embedding data use sqlalchemy session.execute HOT 1
- Using with psycopg 3 pools throws thread error HOT 6
- Sqlalchemy example not working HOT 2
- Questions on HOT 1
- Django support for empty fields HOT 3
- pgvector-python client support for sparse vectors. HOT 3
- Migrating From `VectorField` -> `HalfVectorField` HOT 1
- SQLAlchemy does not recognize vector column HOT 1
- NameError: name 'psycopg' is not defined when register_vector fails HOT 1
- Can't adapt type 'numpy.ndarray' when used via polars HOT 3
- register_vector() Fails When Only 'vector' Extension is Installed, Missing 'halfvec' and 'sparsevec HOT 2
- Maybe spurious exception (ValueError: missing dimensions) when using sparsevec with django HOT 2
- Have you tought about supporting Piccolo? HOT 1
- Adding type annotations? HOT 2
- register_vector fails with asyncpg (v0.3.1) HOT 2
- Inserting binary vectors using SQLalchemy HOT 2
- Duplicate Search HOT 1
- Having trouble when try to insert OpenAI embedding by sqlalchemy to CloudSQL HOT 6
- Takes more time to get the value from Class django.db.models.query.QuerySet HOT 1
- sqladmin - pgvector field converter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgvector-python.