Generate embeddings for your application automatically
sync-period
(5 minutes by default) graphite queries your data and searches for new data (or existing data that changed recently).graphiteSearchXXX
(search using natural language) and graphiteSimilarXXX
(search for objects similar to a given object), where XXX
is a name given by you.
movies
with the following columns:
name
, genre
and overview
.
vector(1536)
and it can be NULL
. For our project we can simply go to the SQL tab and create a migration with the following content:
sync-period
graphite will perform a graphql query to get all the rows that have outdated embeddings. This means we can build this query in a way that:
NULL
.outdated
(boolean) to indicated whether the row is outdated or not.outdated
column to true everytime there is a change to our data.graphite
’s query will be (more on this later):
outdated
directly from your application or you could use some completely different mechanism (i.e. a computed field). The important bit is that graphite needs to be able to make a graphql query and get the relevant rows and data.movies
for this particular example but it can be anything. This will determine the name of the GraphQL queries graphiteSearchXXX
and graphiteSimilarXXX
.public
, movies
and embeddings
respectively.id
of the object, the embeddings and that updates the relevant object. For instance, in this particular example the following mutation would suffice:sync-period
:
embeddings
column set to NULL
:
graphiteSearchMovies
, graphiteSearchMoviesAggregate
, graphiteSimilarMovies
and graphiteSimilarMoviesAggregate
will be created. These queries will work similar to the standard movies
and moviesAggregate
queries provided by hasura and will respect the same permissions but they will also allow you to query movies using natural language or other movies for comparison. For instance:
maxDistance
. This argument allows you to filter responses that are too far from the query, useful for ensuring that very specific queries do not return entirely unrelated responses. The argument is a float between 0.0
(an exact match) and 1.0 (completely unrelated), with a default setting of 1.0
, ensuring the best matches are always returned even if they are unrelated to the query.