Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/utils/llm.py
  • Loading branch information
josancamon19 committed Aug 23, 2024
2 parents ec1119a + 268ae6d commit 6cdb28d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions backend/models/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class CategoryEnum(str, Enum):
social = 'social'
work = 'work'
sports = 'sports'
literature = 'literature'
history = 'history'
other = 'other'


Expand Down
8 changes: 5 additions & 3 deletions backend/routers/memories.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ def postprocess_memory(
# profile_duration = profile_aseg.duration_seconds + separate_seconds

signed_url = upload_postprocessing_audio(file_path)

# Ensure delete uploaded file in 15m
threads = threading.Thread(target=_delete_postprocessing_audio, args=(file_path, ))
threads.start()

speakers_count = len(set([segment.speaker for segment in memory.transcript_segments]))
words = fal_whisperx(signed_url, speakers_count, aseg.duration_seconds)
segments = fal_postprocessing(words, aseg.duration_seconds, profile_duration)
os.remove(file_path)

# Delete uploaded file in 15m
threads = threading.Thread(target=_delete_postprocessing_audio, args=(file_path, ))
threads.start()

if not segments:
memories_db.set_postprocessing_status(uid, memory.id, PostProcessingStatus.canceled)
Expand Down
14 changes: 9 additions & 5 deletions backend/utils/llm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from datetime import datetime
from typing import List, Optional
from typing import List, Tuple, Optional

from langchain_core.output_parsers import PydanticOutputParser
from langchain_core.prompts import ChatPromptTemplate
Expand Down Expand Up @@ -363,9 +363,14 @@ def retrieve_memory_context_params(memory: Memory) -> List[str]:
Conversation:
{transcript}
'''.replace(' ', '').strip()
with_parser = llm.with_structured_output(TopicsContext)
response: TopicsContext = with_parser.invoke(prompt)
return response.topics

try:
with_parser = llm.with_structured_output(TopicsContext)
response: TopicsContext = with_parser.invoke(prompt)
return response.topics
except Exception as e:
print(f'Error determining memory discard: {e}')
return []


class SummaryOutput(BaseModel):
Expand Down Expand Up @@ -490,5 +495,4 @@ def qa_emotional_rag(user_name: str, user_facts: List[Fact], context: str, memor
```
Answer:
""".replace(' ', '').strip()
print(prompt)
return llm.invoke(prompt).content

0 comments on commit 6cdb28d

Please sign in to comment.