Skip to content

Commit

Permalink
add resiliency
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
potatoqualitee committed Jan 14, 2025
1 parent 7a91375 commit d63f174
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/update-news-gist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,22 @@ function Update-Gist {
Input: ['Trump', 'Trump Administration', 'Trump Campaign', 'mass shooting']
Output: ['Trump', 'mass shooting']
Reasoning: 'Trump' covers all Trump-related content, 'mass shooting' is distressing."
$params.Message = $processedKeywords.Keys -join " "
$params.Message = $processedKeywords.Keys | Out-String
$result = Request-ChatCompletion @params

# Create new hashtable with filtered keywords
$filteredKeywords = @{}
$resultCount = 0
foreach ($keyword in ($result.answer | ConvertFrom-Json).keywords) {
if ($processedKeywords.ContainsKey($keyword)) {
$resultCount++
$filteredKeywords[$keyword] = $processedKeywords[$keyword]
}
}
$processedKeywords = $filteredKeywords
if ($resultCount -gt 20) {
# i've seen it do 0 before
$processedKeywords = $filteredKeywords
}
Write-Output "Total updated combined keywords: $(($processedKeywords.Keys | Measure-Object).Count)"
}

Expand Down

0 comments on commit d63f174

Please sign in to comment.