Skip to content

Commit 82ad3d6

Browse files
committed
doc : add custom vector store in java doc
1 parent 5229f1b commit 82ad3d6

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

docs/content/docs/development/vector_stores.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ public class MyAgent extends Agent {
373373
List<Document> documents = event.getDocuments();
374374
// Process the retrieved documents...
375375
}
376-
}
377376
```
378377

379378
{{< /tab >}}
@@ -392,6 +391,10 @@ If you want to use vector stores not offered by the built-in providers, you can
392391

393392
The base class handles text-to-vector conversion and provides the high-level query interface. You only need to implement the core vector search functionality.
394393

394+
{{< tabs "Custom Vector Store" >}}
395+
396+
{{< tab "Python" >}}
397+
395398
```python
396399
class MyVectorStore(BaseVectorStore):
397400
# Add your custom configuration fields here
@@ -409,4 +412,42 @@ class MyVectorStore(BaseVectorStore):
409412
# - kwargs: Vector store-specific parameters
410413
# - Returns: List of Document objects matching the search criteria
411414
pass
412-
```
415+
```
416+
417+
{{< /tab >}}
418+
419+
{{< tab "Java" >}}
420+
421+
```java
422+
public class MyVectorStore extends BaseVectorStore {
423+
424+
public MyVectorStore(
425+
ResourceDescriptor descriptor,
426+
BiFunction<String, ResourceType, Resource> getResource) {
427+
super(descriptor, getResource);
428+
}
429+
430+
@Override
431+
public Map<String, Object> getStoreKwargs() {
432+
// Return vector store-specific configuration
433+
// These parameters are merged with query-specific parameters
434+
Map<String, Object> kwargs = new HashMap<>();
435+
kwargs.put("index", "my_index");
436+
return kwargs;
437+
}
438+
439+
@Override
440+
public List<Document> queryEmbedding(float[] embedding, int limit, Map<String, Object> args) {
441+
// Core method: perform vector search using pre-computed embedding
442+
// - embedding: Pre-computed embedding vector for semantic search
443+
// - limit: Maximum number of results to return
444+
// - args: Vector store-specific parameters
445+
// - Returns: List of Document objects matching the search criteria
446+
return null;
447+
}
448+
}
449+
```
450+
451+
{{< /tab >}}
452+
453+
{{< /tabs >}}

0 commit comments

Comments
 (0)