Advertisement
Sweetening

Google Bard Powershell Script

Nov 22nd, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. # Made by Taylor Christian Newsome Twitter.com/ClumsyLulz This script sets up google bard on the command line in powershell
  2.  
  3. $prompt = Read-Host "Enter your prompt for Google Bard:"
  4.  
  5. $url = "https://api.ailab.io/v1/dialog"
  6. $headers = New-Object System.Collections.Generic.Dictionary[[string], [string]]
  7. $headers.Add("Content-Type", "application/json")
  8.  
  9. $body = New-Object PSObject
  10. $body.prompt = $prompt
  11.  
  12. $request = New-Object System.Net.Http.HttpClient
  13.  
  14. $response = $request.PostAsync($url, (ConvertTo-Json -InputObject $body)).Result
  15.  
  16. if ($response.StatusCode -eq 200) {
  17. $responseBody = $response.Content.ReadAsStringAsync().Result | ConvertFrom-Json
  18.  
  19. Write-Output "Google Bard's response:"
  20. Write-Output $responseBody.data.text
  21. } else {
  22. Write-Output "Error: Failed to send request to Google Bard API."
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement