diff options
Diffstat (limited to 'vectordb.h')
| -rw-r--r-- | vectordb.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vectordb.h b/vectordb.h new file mode 100644 index 0000000..3b375bb --- /dev/null +++ b/vectordb.h @@ -0,0 +1,29 @@ +#ifndef VECTORDB_H +#define VECTORDB_H + +#include "llama.h" + +#define VDB_MAX_DOCS 1000 +#define VDB_EMBED_SIZE 768 +#define VDB_MAX_TEXT 1024 + +typedef struct { + float embedding[VDB_EMBED_SIZE]; + char text[VDB_MAX_TEXT]; +} VectorDoc; + +typedef struct { + VectorDoc docs[VDB_MAX_DOCS]; + int count; + struct llama_context *embed_ctx; +} VectorDB; + +void vdb_init(VectorDB *db, struct llama_context *embed_ctx); +void vdb_free(VectorDB *db); + +void vdb_add_document(VectorDB *db, const char *text); + +void vdb_embed_query(VectorDB *db, const char *text, float *out_embedding); +void vdb_search(VectorDB *db, float *query_embedding, int top_k, int *results); + +#endif |
