Skip to content

Commit

Permalink
Update find_emotions.py : 30개 추출 성능 향상 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
minseok128 committed Dec 4, 2024
1 parent fe6dd08 commit 3933920
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ai_cores/diary_cores/find_emotions.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@

async def find_emotions_from_sentence(sentence: str, category_id: int) -> List[str]:
result_list = []
emotions_db_copy = emotion_dict[emotion_categories[category_id]]
emotions_db_copy = copy.deepcopy(emotion_dict[emotion_categories[category_id]])
random.shuffle(emotions_db_copy)
emotions_chain = find_emotions_prompt | llms[0] | find_emotions_output_parser
result = await emotions_chain.ainvoke(
{
Expand Down Expand Up @@ -141,11 +142,12 @@ async def find_category_from_sentence(sentence: str) -> List[str]:
category_id = 2
result_list += await find_emotions_from_sentence(sentence, category_id)

return result_list
unique_list = []
[unique_list.append(x) for x in result_list if x not in unique_list]
return unique_list


async def diary_find_emotions(request: List[str]) -> List[DiaryContent]:

tasks = [find_category_from_sentence(content) for content in request]
results = await asyncio.gather(*tasks)

Expand Down

0 comments on commit 3933920

Please sign in to comment.