-
Notifications
You must be signed in to change notification settings - Fork 10
Add Milvus as a first-class Vektori storage backend #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ff4f5b2
feat(storage): add Milvus backend with factory wiring, tests, and docs
snigenigmatic fa15abf
fix(milvus): harden filtered ops, wire sentence embedder, and add hea…
snigenigmatic 8c53c57
fix(milvus): harden fallback handling and normalize episode filter co…
snigenigmatic 25ba2ab
fix(milvus): harden tenant isolation, CAS retries, and error handling
snigenigmatic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| """Local Vektori demo using Ollama + Milvus. | ||
|
|
||
| Prerequisites: | ||
| 1) Ollama running locally with: | ||
| - nomic-embed-text | ||
| - qwen2.5:1.5b (or adjust EXTRACTION_MODEL) | ||
| 2) Milvus available at http://localhost:19530 | ||
|
|
||
| Run: | ||
| python examples/ollama_milvus_session_demo.py | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
|
|
||
| from vektori import Vektori | ||
|
|
||
|
|
||
| EMBEDDING_MODEL = "ollama:nomic-embed-text" | ||
| EXTRACTION_MODEL = "ollama:qwen2.5:1.5b" | ||
| MILVUS_URL = "http://localhost:19530" | ||
|
|
||
|
|
||
| async def main() -> None: | ||
| # nomic-embed-text returns 768-dim vectors; Milvus schema must match. | ||
| client = Vektori( | ||
| storage_backend="milvus", | ||
| database_url=MILVUS_URL, | ||
| embedding_model=EMBEDDING_MODEL, | ||
| extraction_model=EXTRACTION_MODEL, | ||
| embedding_dimension=768, | ||
| async_extraction=False, | ||
| ) | ||
|
|
||
| user_id = "demo-user-ollama-milvus" | ||
| session_id = "session-ollama-milvus-001" | ||
|
|
||
| messages = [ | ||
| { | ||
| "role": "user", | ||
| "content": ( | ||
| "I live in Pune and work remotely as a backend engineer. " | ||
| "I prefer calls between 9am and 11am IST, and avoid meetings after 6pm." | ||
| ), | ||
| }, | ||
| { | ||
| "role": "assistant", | ||
| "content": "Understood. I will schedule calls in your preferred morning window.", | ||
| }, | ||
| { | ||
| "role": "user", | ||
| "content": "I also like concise weekly updates every Monday morning.", | ||
| }, | ||
| ] | ||
|
|
||
| try: | ||
| ingest_result = await client.add( | ||
| messages=messages, | ||
| session_id=session_id, | ||
| user_id=user_id, | ||
| metadata={"source": "local-demo"}, | ||
| ) | ||
| print("Ingestion:", ingest_result) | ||
|
|
||
| search_result = await client.search( | ||
| query="When should I contact this user and what communication style do they prefer?", | ||
| user_id=user_id, | ||
| depth="l1", | ||
| ) | ||
|
|
||
| facts = search_result.get("facts", []) | ||
| episodes = search_result.get("episodes", []) | ||
| sentences = search_result.get("sentences", []) | ||
|
|
||
| print("\nFacts:") | ||
| for fact in facts: | ||
| print(f" - {fact.get('text')}") | ||
|
|
||
| print("\nEpisodes:") | ||
| for episode in episodes: | ||
| print(f" - {episode.get('text')}") | ||
|
|
||
| print("\nSentences:") | ||
| for sentence in sentences[:5]: | ||
| print(f" - {sentence.get('text')}") | ||
|
|
||
| finally: | ||
| await client.close() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etcd is configured with
-advertise-client-urls=http://127.0.0.1:2379. In a Compose network this typically causes other containers (likemilvus) to receive/learn a loopback endpoint that isn’t reachable from outside the etcd container. Prefer advertising the service DNS name (e.g.,http://etcd:2379) so Milvus can reliably connect.