Skip to content

Commit

Permalink
feat: add threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesponti committed Sep 25, 2024
1 parent b141085 commit e59ad42
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/crons/focus_crons.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def delete_none_ids_from_chroma():

def refresh_focus_from_chroma():
session = SessionLocal()

try:
focus_items = session.query(Focus).filter(Focus.in_vector_store.is_(False)).all()
if not focus_items:
Expand Down
2 changes: 1 addition & 1 deletion src/data/focus_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def search_focus_items(
results = chroma_service.vector_store.similarity_search_with_relevance_scores(
query=keyword,
filter={"profile_id": str(profile_id)},
# score_threshold=0.4,
score_threshold=0,
)
ids = []
for res, score in results:
Expand Down
5 changes: 5 additions & 0 deletions src/services/user_intent/user_intent_prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ You MUST include at least 10 keywords in the task keywords list.
- "What do I need at the grocery store?" -> `keyword` = "grocery store", `due_on` = None, `due_after` = None, `due_before` = None
- "What do I need to do for work?" -> `keyword` = "work", `due_on` = None, `due_after` = None, `due_before` = None
- USE null value `due_on`, `due_after`, or `due_before` values if the user does not specify a specific date.
- The response format for the assistant message when users perform a search is as follows:
- If a keyword is used, `Found 10 results for the keyword 'focus'`
- If a date is used, `You had one event yesterday.`
- If no keyword is used, `Found 10 results`



---
Expand Down
16 changes: 8 additions & 8 deletions src/services/user_intent/user_intent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def create_tasks(
return [item.to_model() for item in created_items]


@tool("search_tasks")
@tool("search_tasks", parse_docstring=True)
def search_tasks(
keyword: str,
search_title: str,
Expand All @@ -58,13 +58,13 @@ def search_tasks(
Search for tasks based on a keyword or specific attributes.
Args:
keyword (str): The keyword to search for tasks
search_title (str): A user-friendly title for the search
profile_id (uuid.UUID): The user's Profile ID
due_on (Optional[datetime]): The due date in ISO Date Time Format for the task. Example: "2023-01-01T12:00" | None
due_after (Optional[datetime]): A ISO Date Time Format date used when the users wants to search for tasks after a specific date. Example: "2023-01-01T12:00" | None
due_before (Optional[datetime]): A ISO Date Time Format date used when the users wants to search for tasks before a specific date. Example: "2023-01-01T12:00" | None
status (Optional[FocusState]): The status of the task
keyword: The keyword to search for tasks
search_title: A user-friendly title for the search
profile_id: The user's Profile ID
due_on: The due date in ISO Date Time Format for the task. Example: "2023-01-01T12:00" | None
due_after: A ISO Date Time Format date used when the users wants to search for tasks after a specific date. Example: "2023-01-01T12:00" | None
due_before: A ISO Date Time Format date used when the users wants to search for tasks before a specific date. Example: "2023-01-01T12:00" | None
status: The status of the task
"""
focus_items = search_focus_items(
keyword=keyword,
Expand Down

0 comments on commit e59ad42

Please sign in to comment.