Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active August 9, 2025 17:13
Show Gist options
  • Save dfinke/6c57db3127ffdfe60ff723290710d595 to your computer and use it in GitHub Desktop.
Save dfinke/6c57db3127ffdfe60ff723290710d595 to your computer and use it in GitHub Desktop.
A PowerShell function that uses GPT to parse questions like 'a week ago' or 'in July' into precise YYYY-MM-DD formats.
#Requires -Module PSAISuite
function Find-Date {
param(
[string]$question,
[string]$model = 'github:openai/gpt-4.1'
)
$instructions = @"
Current Date: $(Get-Date -Format "yyyy-MM-dd")
## Clarifying End Dates:
Relative references ("a week ago", "one month ago"): Use the current conversation start date as the end date.
Absolute references ("in July", "between 12-05 to 12-08"): Use explicitly implied end dates.
Output just the dates in the format YYYY-MM-DD. If no dates are found, respond with "No dates found".
Question: $question
"@
Invoke-ChatCompletion -Model $model $instructions
}
@dfinke
Copy link
Author

dfinke commented Aug 9, 2025

This requires the PSAISuite module

📦Install-Module PSAISuite
🔗https://github.com/dfinke/psaisuite

https://x.com/dfinke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment