-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: knowledge base for long-term memory (#1099) #1115
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
Open
bitloi
wants to merge
41
commits into
eigent-ai:main
Choose a base branch
from
bitloi:feature/knowledge-base-1099
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+235
−6
Open
Changes from 15 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
2c18d7c
feat: knowledge base for long-term memory (issue #1099)
bitloi d07d875
fix: use os.environ in knowledge_base for testability; add unit and A…
bitloi f45ca7c
Merge origin/main into feature/knowledge-base-1099
bitloi ece99c9
fix: resolve chat_service.py conflict with main (keep KB integration)
bitloi 852ab43
Merge upstream/main, resolve chat_service.py (keep KB integration)
bitloi f678309
Merge branch 'main' into feature/knowledge-base-1099
bitloi 3b9c0e4
Merge branch 'main' into feature/knowledge-base-1099
bitloi 3d10e6d
Merge branch 'main' into feature/knowledge-base-1099
bitloi 47f4f10
Merge branch 'main' into feature/knowledge-base-1099
bitloi fbd480b
Merge branch 'main' into feature/knowledge-base-1099
bitloi b7af46a
Merge branch 'main' into feature/knowledge-base-1099
bitloi 7216ce8
fix: resolve merge conflicts with main (router.py, chat_service.py)
bitloi 4e2dcb2
Merge upstream/main into feature/knowledge-base-1099, resolve conflicts
bitloi c363187
Merge branch 'main' into feature/knowledge-base-1099
bitloi 3d2f4b6
Merge branch 'main' into feature/knowledge-base-1099
bitloi d328676
Merge branch 'main' into feature/knowledge-base-1099
bitloi b2fd959
PR feedback: rename to sqlite_toolkit, FTS5/BM25 search, add tool onl…
bitloi 70cd6df
Remove knowledge base from developer agent for now (per review)
bitloi b4bfc4e
Merge branch 'main' into feature/knowledge-base-1099
bitloi e195c47
Merge branch 'main' into feature/knowledge-base-1099
bitloi dd804f2
Merge branch 'main' into feature/knowledge-base-1099
bitloi 606533f
Merge branch 'main' into feature/knowledge-base-1099
bitloi 06d19b1
Merge branch 'main' into feature/knowledge-base-1099
Wendong-Fan b4fba05
Merge branch 'main' into feature/knowledge-base-1099
bitloi 1b0f125
PR feedback: remove KB from chat context, rename tool to store_projec…
bitloi e134793
Merge branch 'main' into feature/knowledge-base-1099
bitloi 52d06b2
Merge branch 'main' into feature/knowledge-base-1099
bitloi 3086710
Merge branch 'main' into feature/knowledge-base-1099
bitloi a275992
Merge upstream/main into feature/knowledge-base-1099
bitloi ba023f5
Merge branch 'feature/knowledge-base-1099' of https://github.com/bitl…
bitloi 8d8b573
Merge branch 'main' into feature/knowledge-base-1099
bitloi 3564835
refactor(knowledge-base): switch from SQLite to markdown file-based m…
bitloi 60367cb
Merge branch 'main' into feature/knowledge-base-1099
nitpicker55555 b2d810a
refactor(memory): index-only prompt, no dedicated tools (reviewer fee…
bitloi 3bd0880
Merge branch 'feature/knowledge-base-1099' of https://github.com/bitl…
bitloi 0971ae6
Address nitpicker55555 review: remove unused memory helpers, wire pro…
bitloi 4cbdaf2
chore(backend): remove ruff from dev dependencies
bitloi 7e7991e
Merge branch 'main' into feature/knowledge-base-1099
bitloi 516caa2
Replace knowledge_base_toolkit with use_project_memory flag
bitloi d000b44
Merge branch 'feature/knowledge-base-1099' of https://github.com/bitl…
bitloi dafac62
Revert linter-only changes in router.py (review feedback)
bitloi 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
Some comments aren't visible on the classic Files Changed page.
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
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,88 @@ | ||
| # ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= | ||
|
|
||
| from fastapi import APIRouter, HTTPException, Query | ||
| from pydantic import BaseModel, Field | ||
|
|
||
| from app.utils.knowledge_base import add_entry, get_entries, delete_entry | ||
|
|
||
| router = APIRouter(prefix="/knowledge", tags=["Knowledge Base"]) | ||
|
|
||
|
|
||
| class KnowledgeAddIn(BaseModel): | ||
| """Request body for adding a knowledge entry.""" | ||
|
|
||
| project_id: str = Field(..., description="Project ID (scope for this entry)") | ||
| content: str = Field(..., min_length=1, description="Content to store as long-term memory") | ||
|
|
||
|
|
||
| class KnowledgeAddOut(BaseModel): | ||
| """Response after adding a knowledge entry.""" | ||
|
|
||
| id: int | ||
| project_id: str | ||
| message: str = "Knowledge entry added" | ||
|
|
||
|
|
||
| class KnowledgeEntryOut(BaseModel): | ||
| """A single knowledge entry.""" | ||
|
|
||
| id: int | ||
| project_id: str | ||
| content: str | ||
| created_at: float | ||
|
|
||
|
|
||
| @router.post("", name="add knowledge", response_model=KnowledgeAddOut) | ||
| async def knowledge_add(body: KnowledgeAddIn): | ||
| """Add a knowledge entry for long-term memory (issue #1099).""" | ||
| try: | ||
| entry_id = add_entry(project_id=body.project_id, content=body.content) | ||
| return KnowledgeAddOut(id=entry_id, project_id=body.project_id) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=str(e)) | ||
|
|
||
|
|
||
| @router.get("", name="list knowledge") | ||
| async def knowledge_list( | ||
| project_id: str = Query(..., description="Project ID"), | ||
| query: str | None = Query(None, description="Optional keyword filter"), | ||
| limit: int = Query(50, ge=1, le=200, description="Max entries to return"), | ||
| ): | ||
| """List knowledge entries for a project, optionally filtered by keyword.""" | ||
bitloi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
bitloi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| try: | ||
| entries = get_entries(project_id=project_id, query=query, limit=limit) | ||
| return {"project_id": project_id, "entries": entries} | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=str(e)) | ||
|
|
||
|
|
||
| @router.delete("/{entry_id}", name="delete knowledge") | ||
| async def knowledge_delete( | ||
| entry_id: int, | ||
| project_id: str = Query(..., description="Project ID"), | ||
| ): | ||
| """Delete a knowledge entry by id (scoped to project).""" | ||
bitloi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| try: | ||
| deleted = delete_entry(project_id=project_id, entry_id=entry_id) | ||
| if not deleted: | ||
| raise HTTPException( | ||
| status_code=404, | ||
| detail=f"Knowledge entry {entry_id} not found for project {project_id}", | ||
| ) | ||
| return {"deleted": True, "id": entry_id} | ||
| except HTTPException: | ||
| raise | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=str(e)) | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.