Skip to content

Commit

Permalink
Merge pull request #40 from studio-recoding/feat/recommendation
Browse files Browse the repository at this point in the history
Feat/recommendation
  • Loading branch information
uommou authored Apr 7, 2024
2 parents 2e75853 + 4f99b38 commit 4dd3a88
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/database/chroma_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ async def search_db_query(query):
# description: DB에 저장하는 함수
# 스프링 백엔드로부터 chroma DB에 저장할 데이터를 받아 DB에 추가한다.
async def add_db_data(schedule_data: AddScheduleDTO):
schedule_date = schedule_data.schedule_datetime_start.split("T")[0]
schedules.add(
documents=[schedule_data.data],
ids=[str(schedule_data.schedule_id)],
metadatas=[{"datetime_start": schedule_data.schedule_datetime_start, "datetime_end": schedule_data.schedule_datetime_end, "member": schedule_data.member_id, "category": schedule_data.category, "location": schedule_data.location, "person": schedule_data.person}]
metadatas=[{"date": schedule_date, "datetime_start": schedule_data.schedule_datetime_start, "datetime_end": schedule_data.schedule_datetime_end, "member": schedule_data.member_id, "category": schedule_data.category, "location": schedule_data.location, "person": schedule_data.person}]
)
return True

Expand All @@ -60,17 +61,17 @@ async def db_recommendation_main(user_data: RecommendationMainRequestDTO):
member = user_data.member_id
schedule_datetime_start = user_data.schedule_datetime_start
schedule_datetime_end = user_data.schedule_datetime_end
schedule_date = schedule_datetime_start.split("T")[0]
persona = user_data.user_persona or "hard working"
results = schedules.query(
query_texts=["hard working"],
query_texts=[persona],
n_results=5,
where={"$and" :
where={"$and":
[
{"member": {"$eq": int(member)}},
{"datetime_start": {
"$eq": schedule_datetime_start, # greater than or equal
# "$lt": schedule_datetime_end # less than
}}
]}
{"date": {"$eq": schedule_date}}
]
}
# where_document={"$contains":"search_string"} # optional filter
)
return results['documents']
Expand Down

0 comments on commit 4dd3a88

Please sign in to comment.