From 561edc8a43d2fda6da6ef19727bba92969905fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?th=E1=BB=8Bnh?= Date: Sat, 16 Nov 2024 12:10:16 +0700 Subject: [PATCH] Add the context example model to Mentor01 app --- plugins/example/basic/mentor.py | 6 +++--- plugins/example/models.py | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/example/basic/mentor.py b/plugins/example/basic/mentor.py index 11fc91fb8..36b601c3c 100644 --- a/plugins/example/basic/mentor.py +++ b/plugins/example/basic/mentor.py @@ -2,7 +2,7 @@ from fastapi import APIRouter -from models import TranscriptSegment, MentorEndpointResponse, RealtimePluginRequest +from models import TranscriptSegment, ProactiveNotificationEndpointResponse, RealtimePluginRequest from db import get_upsert_segment_to_transcript_plugin router = APIRouter() @@ -10,10 +10,10 @@ scan_segment_session = {} # ******************************************************* -# ************ Basic Mentor Plugin ************ +# ************ Basic Proactive Notification Plugin ************ # ******************************************************* -@router.post('/mentor', tags=['mentor', 'basic', 'realtime'], response_model=MentorEndpointResponse) +@router.post('/mentor', tags=['mentor', 'basic', 'realtime', 'proactive_notification'], response_model=ProactiveNotificationEndpointResponse) def mentoring(data: RealtimePluginRequest): def normalize(text): return re.sub(r' +', ' ',re.sub(r'[,?.!]', ' ', text)).lower().strip() diff --git a/plugins/example/models.py b/plugins/example/models.py index aba0e6f21..abf5f64bf 100644 --- a/plugins/example/models.py +++ b/plugins/example/models.py @@ -168,10 +168,20 @@ class RealtimePluginRequest(BaseModel): segments: List[TranscriptSegment] -class MentorResponse(BaseModel): +class ProactiveNotificationContextFitlersResponse(BaseModel): + people: List[str] = Field(description="A list of people. ", default=[]) + entities: List[str] = Field(description="A list of entity. ", default=[]) + topics: List[str] = Field(description="A list of topic. ", default=[]) + +class ProactiveNotificationContextResponse(BaseModel): + question: str = Field(description="A question to query the embeded vector database.", default='') + filters: ProactiveNotificationContextFitlersResponse = Field(description="Filter options to query the embeded vector database. ", default=None) + +class ProactiveNotificationResponse(BaseModel): prompt: str = Field(description="A prompt or a template with the parameters such as {{user_name}} {{user_facts}}.", default='') params: List[str] = Field(description="A list of string that match with proactive notification scopes. ", default=[]) + context: ProactiveNotificationContextResponse = Field(description="An object to guide the system in retrieving the users context", default=None) -class MentorEndpointResponse(BaseModel): +class ProactiveNotificationEndpointResponse(BaseModel): message: str = Field(description="A short message to be sent as notification to the user, if needed.", default='') - notification: MentorResponse = Field(description="An object to guide the system in generating the proactive notification", default=None) + notification: ProactiveNotificationResponse = Field(description="An object to guide the system in generating the proactive notification", default=None)