summaryrefslogtreecommitdiff
path: root/vectordb.h
blob: 3b375bb534000214b04cf3ec308a16600ccd5389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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