Skip to content
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

[ENH] Add GET endpoints for documents #547

Merged
merged 51 commits into from
Feb 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a9ebd9c
Give option for database to return all documents
smokestacklightnin Jan 27, 2025
ce37b0c
Add `get_documents`
smokestacklightnin Jan 27, 2025
d0197f5
Merge remote-tracking branch 'upstream/main' into ui/enh/document-viewer
smokestacklightnin Jan 28, 2025
b970b96
Add `GET` endpoint for `/documents`
smokestacklightnin Jan 28, 2025
f33e8ea
Add `GET` endpoint for a specific document `/documents/{id}`
smokestacklightnin Jan 28, 2025
c68f874
Fix mypy error
smokestacklightnin Jan 28, 2025
e7bf467
Add `get_document` to engine for convenience
smokestacklightnin Jan 28, 2025
ce6a4f2
Clean up
smokestacklightnin Jan 28, 2025
c4bbcaf
Add support for MIME types in `core.Document`s
smokestacklightnin Jan 28, 2025
1ab6f58
Add `GET` `/documents/{id}/content` endpoint
smokestacklightnin Jan 28, 2025
e57950c
Call correct method
smokestacklightnin Jan 28, 2025
1bc57b0
Use the builtin `mimetypes` library instead of custom logic
smokestacklightnin Jan 28, 2025
54e20a3
Merge remote-tracking branch 'upstream/main' into ui/enh/document-viewer
smokestacklightnin Jan 28, 2025
f67997e
Add mime_type to `Document` schema
smokestacklightnin Jan 28, 2025
23898f0
Add MIME type to `Document` ORM object
smokestacklightnin Jan 28, 2025
e53b180
Add MIME type to ORM <> Schema converters and Core <> Schema converters
smokestacklightnin Jan 28, 2025
2cfa02a
Add `mime_type` to initializer for `LocalDocument`
smokestacklightnin Jan 28, 2025
32dc1ab
Remove unnecessary type conversion
smokestacklightnin Jan 29, 2025
32e11ba
Make code more concise
smokestacklightnin Jan 29, 2025
162a3ff
Enforce keyword arguments
smokestacklightnin Jan 29, 2025
e122713
Help expression scale
smokestacklightnin Jan 29, 2025
06b5ab7
Use `__getitem__` instead of `next(iter(...))`
smokestacklightnin Jan 29, 2025
a9bf0fd
Use traditional `if` statement instead of ternary operator
smokestacklightnin Jan 29, 2025
94ca3f9
Add empty `test_endpoints.py` file
smokestacklightnin Jan 30, 2025
fffd104
Prevent naming collisions
smokestacklightnin Jan 30, 2025
e199054
Add test for `GET documents` endpoint
smokestacklightnin Jan 31, 2025
773a030
Add test for `GET document`
smokestacklightnin Jan 31, 2025
d0cd74c
Add test for `GET` document content
smokestacklightnin Jan 31, 2025
e107d5d
Fix typo in `PUT` methods
smokestacklightnin Jan 31, 2025
72d007f
Clean up `raise_for_status()`
smokestacklightnin Jan 31, 2025
f4028fd
Use `__getitem__` instead of `next(iter(...))`
smokestacklightnin Feb 1, 2025
6abfb00
Remove unique names where appropriate
smokestacklightnin Feb 1, 2025
565ccab
Make sorting key not private
smokestacklightnin Feb 1, 2025
3f0000f
Add and use `upload_documents` to minimize repeated code in repeated …
smokestacklightnin Feb 1, 2025
22a31b6
Store document text content in a variable to be reused
smokestacklightnin Feb 1, 2025
d6db904
Use `upload_documents` in `test_components.py`
smokestacklightnin Feb 2, 2025
435a268
Fix typo
smokestacklightnin Feb 2, 2025
a6acfd6
Allow for specification of MIME types in `upload_documents`
smokestacklightnin Feb 3, 2025
4cfa644
Test with user-specified MIME types in `test_get_documents`
smokestacklightnin Feb 3, 2025
0959572
Make `mime_types` parametrization reusable across multiple tests
smokestacklightnin Feb 3, 2025
2f9f2b7
Test with user-specified MIME types in `test_get_document`
smokestacklightnin Feb 3, 2025
a3456b7
Test with user-specified MIME types in `test_get_document_content`
smokestacklightnin Feb 3, 2025
4d1b1d5
Add `mime_type` to `DocumentRegistration`
smokestacklightnin Feb 4, 2025
d5c6c16
Include `mime_type` when registering documents
smokestacklightnin Feb 4, 2025
6cfb136
Use `read` instead of `iter_lines`
smokestacklightnin Feb 4, 2025
5eafb6d
Remove redundant assertion of equality
smokestacklightnin Feb 4, 2025
249c487
Use `zip(..., strict=True)` to force arguments to be the same length
smokestacklightnin Feb 4, 2025
5fd702e
Remove assertion that should be part of other tests
smokestacklightnin Feb 4, 2025
83e7607
Test equality of bytes, rather than of strings
smokestacklightnin Feb 4, 2025
3a2d98e
Assert equal lengths instead of using `zip(..., strict=True)`
smokestacklightnin Feb 4, 2025
68f302e
Use `iter_lines` instead of receiving bytes
smokestacklightnin Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add get_document to engine for convenience
smokestacklightnin committed Jan 28, 2025
commit e7bf467302644395bbdf5382460d10595d428030
2 changes: 1 addition & 1 deletion ragna/deploy/_api.py
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ async def get_documents(user: UserDependency) -> list[schemas.Document]:

@router.get("/documents/{id}")
async def get_document(user: UserDependency, id: uuid.UUID) -> schemas.Document:
return next(iter(engine.get_documents(user.name, [id])))
return engine.get_document(user.name, id)

@router.get("/components")
def get_components() -> schemas.Components:
3 changes: 3 additions & 0 deletions ragna/deploy/_engine.py
Original file line number Diff line number Diff line change
@@ -198,6 +198,9 @@ def get_documents(

return documents

def get_document(self, user: str, id: uuid.UUID) -> schemas.Document:
return next(iter(self.get_documents(user, [id])))

def create_chat(
self, *, user: str, chat_creation: schemas.ChatCreation
) -> schemas.Chat: