From 854adeb884129f9f1a0c854195db21eb66beefda Mon Sep 17 00:00:00 2001 From: Yassine Souissi Date: Thu, 5 Sep 2024 18:00:13 +0200 Subject: [PATCH] Lint --- app/pipeline/chat/course_chat_pipeline.py | 3 ++- app/pipeline/lecture_ingestion_pipeline.py | 5 +++-- app/web/routers/ingestion_status.py | 24 ++++++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/pipeline/chat/course_chat_pipeline.py b/app/pipeline/chat/course_chat_pipeline.py index 42a046b0..2484adb0 100644 --- a/app/pipeline/chat/course_chat_pipeline.py +++ b/app/pipeline/chat/course_chat_pipeline.py @@ -266,7 +266,8 @@ def get_competency_list() -> list: def lecture_content_retrieval() -> str: """ Retrieve content from indexed lecture slides. - This will run a RAG retrieval based on the chat history on the indexed lecture slides and return the most relevant paragraphs. + This will run a RAG retrieval based on the chat history on the indexed lecture slides and return the most + relevant paragraphs. Use this if you think it can be useful to answer the student's question, or if the student explicitly asks a question about the lecture content or slides. Only use this once. diff --git a/app/pipeline/lecture_ingestion_pipeline.py b/app/pipeline/lecture_ingestion_pipeline.py index 3a954389..5c07d07d 100644 --- a/app/pipeline/lecture_ingestion_pipeline.py +++ b/app/pipeline/lecture_ingestion_pipeline.py @@ -29,9 +29,10 @@ CapabilityRequestHandler, RequirementList, ) -from ..web.status import ingestion_status_callback from langchain_text_splitters import RecursiveCharacterTextSplitter +from ..web.status import ingestion_status_callback + batch_update_lock = threading.Lock() @@ -93,7 +94,7 @@ def __init__( self, client: WeaviateClient, dto: Optional[IngestionPipelineExecutionDto], - callback: IngestionStatusCallback, + callback: ingestion_status_callback, ): super().__init__() self.collection = init_lecture_schema(client) diff --git a/app/web/routers/ingestion_status.py b/app/web/routers/ingestion_status.py index aac887f1..42d793d6 100644 --- a/app/web/routers/ingestion_status.py +++ b/app/web/routers/ingestion_status.py @@ -10,17 +10,23 @@ router = APIRouter(prefix="/api/v1", tags=["ingestion_status"]) -@router.get("/courses/{course_id}/lectures/{lecture_id}/lectureUnits/{lecture_unit_id}/ingestion-state", - dependencies=[Depends(TokenValidator())]) -def get_lecture_unit_ingestion_state(course_id: int, lecture_id: int, lecture_unit_id: int, baseUrl: str): +@router.get( + "/courses/{course_id}/lectures/{lecture_id}/lectureUnits/{lecture_unit_id}/ingestion-state", + dependencies=[Depends(TokenValidator())], +) +def get_lecture_unit_ingestion_state( + course_id: int, lecture_id: int, lecture_unit_id: int, baseUrl: str +): db = VectorDatabase() decoded_base_url = unquote(baseUrl) result = db.lectures.query.fetch_objects( filters=( - Filter.by_property(LectureSchema.BASE_URL.value).equal(decoded_base_url) - & Filter.by_property(LectureSchema.COURSE_ID.value).equal(course_id) - & Filter.by_property(LectureSchema.LECTURE_ID.value).equal(lecture_id) - & Filter.by_property(LectureSchema.LECTURE_UNIT_ID.value).equal(lecture_unit_id) + Filter.by_property(LectureSchema.BASE_URL.value).equal(decoded_base_url) + & Filter.by_property(LectureSchema.COURSE_ID.value).equal(course_id) + & Filter.by_property(LectureSchema.LECTURE_ID.value).equal(lecture_id) + & Filter.by_property(LectureSchema.LECTURE_UNIT_ID.value).equal( + lecture_unit_id + ) ), limit=1, return_properties=[LectureSchema.LECTURE_UNIT_NAME.value], @@ -30,11 +36,11 @@ def get_lecture_unit_ingestion_state(course_id: int, lecture_id: int, lecture_un return Response( status_code=status.HTTP_200_OK, content='"DONE"', - media_type="application/json" + media_type="application/json", ) else: return Response( status_code=status.HTTP_200_OK, content='"NOT_STARTED"', - media_type="application/json" + media_type="application/json", )