mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-18 11:51:41 +03:00
803f304390
# Description
Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.
## Checklist before requesting a review
Please delete options that are not relevant.
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged
## Screenshots (if appropriate):
<!--
ELLIPSIS_HIDDEN
-->
----
| 🚀 This description was created by
[Ellipsis](https://www.ellipsis.dev) for commit
3e95f1a5aa
|
|--------|
### Summary:
This PR introduces the 'Quivr Assistants' feature with new frontend
components and pages, backend routes and DTOs changes, and a minor
update in the `processAssistant` function.
**Key points**:
- Introduced the 'Quivr Assistants' feature with new frontend components
and pages, backend routes and DTOs changes.
- Added new `AssistantModal` component in
`/frontend/app/assistants/AssistantModal/AssistantModal.tsx`.
- Added new `InputsStep` and `OutputsStep` components for handling
assistant inputs and outputs.
- Added new `AssistantModal` page in
`/frontend/app/assistants/page.tsx`.
- Added new API endpoints and types for assistants in
`/frontend/lib/api/assistants/assistants.ts` and
`/frontend/lib/api/assistants/types.ts`.
- Updated backend assistant routes and DTOs in
`backend/modules/assistant/controller/assistant_routes.py`,
`backend/modules/assistant/dto/inputs.py`,
`backend/modules/assistant/ito/difference.py`, and
`backend/modules/assistant/ito/summary.py`.
- Made a minor update in the `processAssistant` function in the
`/frontend/lib/api/assistants/assistants.ts` file.
----
Generated with ❤️ by [ellipsis.dev](https://www.ellipsis.dev)
<!--
ELLIPSIS_HIDDEN
-->
65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
from typing import List
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, UploadFile
|
|
from logger import get_logger
|
|
from middlewares.auth import AuthBearer, get_current_user
|
|
from modules.assistant.dto.inputs import InputAssistant
|
|
from modules.assistant.dto.outputs import AssistantOutput
|
|
from modules.assistant.ito.difference import DifferenceAssistant
|
|
from modules.assistant.ito.summary import SummaryAssistant, summary_inputs
|
|
from modules.assistant.service.assistant import Assistant
|
|
from modules.user.entity.user_identity import UserIdentity
|
|
|
|
assistant_router = APIRouter()
|
|
logger = get_logger(__name__)
|
|
|
|
assistant_service = Assistant()
|
|
|
|
|
|
@assistant_router.get(
|
|
"/assistants", dependencies=[Depends(AuthBearer())], tags=["Assistant"]
|
|
)
|
|
async def list_assistants(
|
|
current_user: UserIdentity = Depends(get_current_user),
|
|
) -> List[AssistantOutput]:
|
|
"""
|
|
Retrieve and list all the knowledge in a brain.
|
|
"""
|
|
|
|
summary = summary_inputs()
|
|
# difference = difference_inputs()
|
|
# crawler = crawler_inputs()
|
|
# audio_transcript = audio_transcript_inputs()
|
|
return [summary]
|
|
|
|
|
|
@assistant_router.post(
|
|
"/assistant/process",
|
|
dependencies=[Depends(AuthBearer())],
|
|
tags=["Assistant"],
|
|
)
|
|
async def process_assistant(
|
|
input: InputAssistant,
|
|
files: List[UploadFile] = None,
|
|
current_user: UserIdentity = Depends(get_current_user),
|
|
):
|
|
if input.name.lower() == "summary":
|
|
summary_assistant = SummaryAssistant(
|
|
input=input, files=files, current_user=current_user
|
|
)
|
|
try:
|
|
summary_assistant.check_input()
|
|
return await summary_assistant.process_assistant()
|
|
except ValueError as e:
|
|
raise HTTPException(status_code=400, detail=str(e))
|
|
elif input.name.lower() == "difference":
|
|
difference_assistant = DifferenceAssistant(
|
|
input=input, files=files, current_user=current_user
|
|
)
|
|
try:
|
|
difference_assistant.check_input()
|
|
return await difference_assistant.process_assistant()
|
|
except ValueError as e:
|
|
raise HTTPException(status_code=400, detail=str(e))
|
|
return {"message": "Assistant not found"}
|