Skip to content

feat: Bepo v0.5 — POST /chat endpoint with shared search helper - #10

Merged
enlorik merged 1 commit into
mainfrom
copilot/add-chat-endpoint
May 30, 2026
Merged

feat: Bepo v0.5 — POST /chat endpoint with shared search helper#10
enlorik merged 1 commit into
mainfrom
copilot/add-chat-endpoint

Conversation

Copilot AI commented May 29, 2026

Copy link
Copy Markdown
Contributor

Adds a lightweight deterministic chat endpoint that answers natural-language questions about saved memories using local metadata — no LLM, no external APIs.

New: POST /chat

  • JSON body: message (required, non-empty), top_k (1–10, default 3)
  • Reuses memory scoring via extracted search_memory_matches(query, top_k) helper
  • Returns status, answer, count, memories (safe fields only — no embeddings)
  • Answer is built deterministically from top match: place_hintbepo_summary/user_note/notemood/tags → map hint
POST /chat
{"message": "Where was that calm cafe with the cat?", "top_k": 3}

{
  "status": "success",
  "answer": "You may mean the memory near the red couch hallway. I remember it as calm, cafe, cat, cozy.",
  "count": 1,
  "memories": [...]
}

Refactor: search_memory_matches helper

Extracted shared DB-query + cosine-scoring logic from /search into search_memory_matches(query, top_k) → list[dict]. Both /search and /chat delegate to it — no behavior change on /search.

Validation

  • ChatRequest Pydantic model: @field_validator rejects whitespace-only messages; Field(ge=1, le=10) enforces top_k range — both return 422
  • 9 new tests in TestChat covering empty DB, validation rejection, metadata in answer, embedding exclusion, and /search backward-compatibility

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 AI requested a review from enlorik May 29, 2026 16:19
@enlorik
enlorik marked this pull request as ready for review May 30, 2026 12:08
Copilot AI review requested due to automatic review settings May 30, 2026 12:08
@enlorik
enlorik merged commit 5ec126e into main May 30, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into search_memory_matches(query, top_k), used by both /search and /chat with no behavior change on /search.
  • Add ChatRequest Pydantic model (with whitespace and top_k 1–10 validation), build_chat_answer() helper, and the POST /chat endpoint that returns safe memory fields (no embeddings).
  • Update root endpoint version to 0.5, register /chat, add README docs, and add a TestChat suite covering validation, no-results, metadata-in-answer, embedding exclusion, and /search backward 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants