How to setup "AshPostgres.Extensions.Vector"

I want to use Ash.AI to build RAG feature for my app. Currently, I am not sure how to setup AshPostgres for vector. According to the document: https://hexdocs.pm/ash_postgres/AshPostgres.Extensions.Vector.html An extension that adds support for the vector type. Create a file with these contents, not inside of a module:
Postgrex.Types.define(<YourApp>.PostgrexTypes, [AshPostgres.Extensions.Vector] ++ Ecto.Adapters.Postgres.extensions(), [])
Postgrex.Types.define(<YourApp>.PostgrexTypes, [AshPostgres.Extensions.Vector] ++ Ecto.Adapters.Postgres.extensions(), [])
I am confused by this: - which file should I create? a .exs or .ex file ? - where should I put that file, in the root of my project? or in lib folder ? Thanks a lot for your help 🙂
Solution:
It goes in the lib/ folder, and in a .ex file
Jump to solution
5 Replies
Solution
ZachDaniel
ZachDaniel•4mo ago
It goes in the lib/ folder, and in a .ex file
hyperion_zw
hyperion_zwOP•4mo ago
Hi, Zach: so what should be the name of that file? any name? and put
Postgrex.Types.define(Hello.PostgrexTypes, [AshPostgres.Extensions.Vector] ++ Ecto.Adapters.Postgres.extensions(), []
Postgrex.Types.define(Hello.PostgrexTypes, [AshPostgres.Extensions.Vector] ++ Ecto.Adapters.Postgres.extensions(), []
will be fine? It seems magic...
ZachDaniel
ZachDaniel•4mo ago
Yep, it's weird, but it literally does not matter what it's called But since it's confusing, once you get it sorted maybe you could make a PR to explain it a bit better for others?
hyperion_zw
hyperion_zwOP•4mo ago
Of course, once I tested. I will record it down.
kernel
kernel•4mo ago
I just put that stuff in my repo.ex tbh

Did you find this page helpful?