Skip to content

Commit

Permalink
Retrieve date context by question v4 (#1701)
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin authored Jan 16, 2025
2 parents d5bfdbc + 3564c82 commit e0b1bda
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backend/utils/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,27 @@ def retrieve_context_dates(messages: List[Message], tz: str) -> List[datetime]:


def retrieve_context_dates_by_question(question: str, tz: str) -> List[datetime]:
prompt = f'''
You MUST determine the appropriate date range in {tz} that provides context for answering the <question> provided.
If the <question> does not reference a date or a date range, respond with an empty list: []
Current date time in UTC: {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S')}
<question>
{question}
</question>
'''.replace(' ', '').strip()

# print(prompt)
# print(llm_mini.invoke(prompt).content)
with_parser = llm_mini.with_structured_output(DatesContext)
response: DatesContext = with_parser.invoke(prompt)
return response.dates_range


def retrieve_context_dates_by_question_v3(question: str, tz: str) -> List[datetime]:
prompt = f'''
You MUST determine the appropriate date range in {tz} that provides context for answering the question provided.
Expand Down

0 comments on commit e0b1bda

Please sign in to comment.