Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active November 24, 2024 23:38
Show Gist options
  • Save dfinke/0456003ef8413695bd67be1e2b397de6 to your computer and use it in GitHub Desktop.
Save dfinke/0456003ef8413695bd67be1e2b397de6 to your computer and use it in GitHub Desktop.
function Save-JsonToExcel {
<#
.SYNOPSIS
Saves a JSON string to an Excel file.
.PARAMETER Json
The JSON string to save.
.PARAMETER Path
The path to save the Excel file to.
#>
param(
[string]$Json,
[string]$Path
)
$Json | ConvertFrom-Json | Export-Excel -Path $Path -AutoSize
Write-Output "Saved JSON to Excel file: $Path"
}
$Tools = Register-Tool Save-JsonToExcel, Export-Excel
$Tools += $(
New-StockTickerTool
New-TavilyAITool
)
$Instructions = @"
Date: $(Get-Date)
Path: $PSScriptRoot\Research-Summary-$((get-date).ToString("yyyyMMddhhmmss")).xlsx
This agent will do the research and generate a JSON summary. The JSON summary will be saved in an Excel file.
Only output the final file it is saved to.
"@
$agent = New-Agent -Name 'Research Agent' -Tools $Tools -Instructions $Instructions -ShowToolCalls
$agent | Get-AgentResponse @"
What did IBM, GM, Microsoft, Google, Meta, and Exxon close at and a news item for each
Include stock info for each
Each line should be a different stock
Each line should have a 25 word news summary
"@
@dfinke
Copy link
Author

dfinke commented Nov 24, 2024

Install-Module PSAI
Install-Module ImportExcel

.\Research-Agent.ps1

image

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