feat: Bepo v0.5 — POST /chat endpoint with shared search helper - #10
Merged
Conversation
Copilot
AI
changed the title
feat: add POST /chat endpoint (Bepo v0.5)
feat: Bepo v0.5 — POST /chat endpoint with shared search helper
May 29, 2026
Copilot created this pull request from a session on behalf of
enlorik
May 29, 2026 16:19
View session
enlorik
marked this pull request as ready for review
May 30, 2026 12:08
There was a problem hiding this comment.
Pull request overview
Adds a deterministic, local POST /chat endpoint that answers natural-language questions about saved memories by reusing search logic extracted into a shared helper. Bumps the app version to 0.5 and updates README.
Changes:
- Extract
/search's scoring/DB-query logic intosearch_memory_matches(query, top_k), used by both/searchand/chatwith no behavior change on/search. - Add
ChatRequestPydantic model (with whitespace andtop_k1–10 validation),build_chat_answer()helper, and thePOST /chatendpoint that returns safe memory fields (no embeddings). - Update root endpoint version to
0.5, register/chat, add README docs, and add aTestChatsuite covering validation, no-results, metadata-in-answer, embedding exclusion, and/searchbackward compatibility.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| main.py | Adds ChatRequest, search_memory_matches, build_chat_answer, /chat endpoint; refactors /search to delegate; bumps version to 0.5. |
| tests/test_api.py | Adds TestChat covering empty DB, validation, metadata in answers, embedding non-exposure, and /search regression check. |
| README.md | Documents the new /chat endpoint with request/response examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a lightweight deterministic chat endpoint that answers natural-language questions about saved memories using local metadata — no LLM, no external APIs.
New:
POST /chatmessage(required, non-empty),top_k(1–10, default 3)search_memory_matches(query, top_k)helperstatus,answer,count,memories(safe fields only — no embeddings)place_hint→bepo_summary/user_note/note→mood/tags→ map hintRefactor:
search_memory_matcheshelperExtracted shared DB-query + cosine-scoring logic from
/searchintosearch_memory_matches(query, top_k) → list[dict]. Both/searchand/chatdelegate to it — no behavior change on/search.Validation
ChatRequestPydantic model:@field_validatorrejects whitespace-only messages;Field(ge=1, le=10)enforcestop_krange — both return 422TestChatcovering empty DB, validation rejection, metadata in answer, embedding exclusion, and/searchbackward-compatibility